Skip to content

Commit d9bf86d

Browse files
😊对约稿页面的一些子页面进行了有限的支持
1 parent 1ceb6ae commit d9bf86d

File tree

9 files changed

+234
-28
lines changed

9 files changed

+234
-28
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,25 @@ PS:该功能目前只能在电脑端页面里使用。我没有将其适配到
134134

135135
现在我把 z-index 改为 0 以解决此问题。
136136

137+
### 😊对约稿页面的一些子页面进行了有限的支持
138+
139+
约稿页面现在依然不支持批量下载(比如一次下载多少页),一方面是我懒,另一方面确实必要性不大,我觉得约稿页面就是得挑着看的,没必要全部下载。
140+
141+
不过其他一些功能支持了更多页面。比如预览作品、快速下载单个作品、显示更大的缩略图等。
142+
143+
之前只支持约稿页面:
144+
https://www.pixiv.net/request
145+
146+
现在在下面两个页面里也可以使用了:
147+
148+
1. 正在接稿中用户的作品:
149+
https://www.pixiv.net/request/creators/works/illust
150+
151+
2. 已完成的约稿页面:
152+
https://www.pixiv.net/request/complete/illust
153+
154+
因为这两个页面里是大量的作品列表,所以我进行了支持。
155+
137156
### 🐞修复了预览作品时,快速连续按两次 C 可能会下载所有图片的问题
138157

139158
https://github.com/xuejianxianzun/PixivBatchDownloader/issues/497

dist/js/content.js

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ class ArtworkThumbnail extends _WorkThumbnail__WEBPACK_IMPORTED_MODULE_0__.WorkT
394394
'li>div>div:first-child',
395395
'li>div>div:first-child>div',
396396
'li>div>div>div:first-child',
397+
'.worksUL li>div>div:first-child',
397398
'div[data-ga4-entity-id^="illust"]>div:nth-child(2)',
398399
'div[data-ga4-entity-id^="manga"]>div:nth-child(2)',
399400
];
@@ -403,8 +404,16 @@ class ArtworkThumbnail extends _WorkThumbnail__WEBPACK_IMPORTED_MODULE_0__.WorkT
403404
// 这里还会显示小说,但小说的含有 novel 关键词,可以区别开来,例如:
404405
// data-ga4-entity-id="novel/18205969"
405406
}
406-
this.findThumbnail(document.body);
407407
this.createObserver(document.body);
408+
// 立即查找一次元素
409+
this.findThumbnail(document.body);
410+
// 之后在某些页面里定时查找
411+
const findOnPageType = [_PageType__WEBPACK_IMPORTED_MODULE_1__.pageType.list.Request];
412+
window.setInterval(() => {
413+
if (document.hidden === false && findOnPageType.includes(_PageType__WEBPACK_IMPORTED_MODULE_1__.pageType.type)) {
414+
this.findThumbnail(document.body);
415+
}
416+
}, 1000);
408417
}
409418
findThumbnail(parent) {
410419
if (!parent.querySelectorAll) {
@@ -440,7 +449,9 @@ class ArtworkThumbnail extends _WorkThumbnail__WEBPACK_IMPORTED_MODULE_0__.WorkT
440449
continue;
441450
}
442451
// 只在 约稿 页面里使用
443-
if (selector === 'li>div>div:first-child>div' &&
452+
// .worksUL li>div>div:first-child 是在“已完成的约稿”里使用的
453+
if ((selector === 'li>div>div:first-child>div' ||
454+
selector === '.worksUL li>div>div:first-child') &&
444455
_PageType__WEBPACK_IMPORTED_MODULE_1__.pageType.type !== _PageType__WEBPACK_IMPORTED_MODULE_1__.pageType.list.Request) {
445456
continue;
446457
}
@@ -7251,11 +7262,11 @@ class ShowLargerThumbnails {
72517262
// 当页面元素变化时,允许重新查找。
72527263
// 这主要是因为切换页面时,下载器可能先查找到了目标元素,但之后页面内容马上发生了变化,移除了目标元素。
72537264
// 所以当元素变化时,需要重新查找,否则偶尔会显示异常
7254-
const targetNode = document.querySelector('body');
7265+
const body = document.querySelector('body');
72557266
const observer = new MutationObserver(() => {
72567267
this.needFind = true;
72577268
});
7258-
observer.observe(targetNode, {
7269+
observer.observe(body, {
72597270
childList: true,
72607271
subtree: true,
72617272
});
@@ -7464,6 +7475,38 @@ class ShowLargerThumbnails {
74647475
}
74657476
}
74667477
}
7478+
// 约稿页面,分为数种子页面
7479+
if (_PageType__WEBPACK_IMPORTED_MODULE_2__.pageType.type === _PageType__WEBPACK_IMPORTED_MODULE_2__.pageType.list.Request) {
7480+
// 正在接稿中用户的作品
7481+
// https://www.pixiv.net/request/creators/works/illust
7482+
// 已完成的约稿页面
7483+
// https://www.pixiv.net/request/complete/illust
7484+
if (window.location.pathname.includes('/request/complete') ||
7485+
window.location.pathname.includes('/request/creators')) {
7486+
// 首先查找作品列表的 UL 元素
7487+
const illustLink = document.querySelector('ul li a[href^="/artworks/"]');
7488+
if (!illustLink) {
7489+
return;
7490+
}
7491+
const ul = illustLink.closest('ul');
7492+
ul.classList.add('worksUL');
7493+
// 查找容器元素
7494+
// ul 的祖父元素是个 div,这个 div 里面的 3 个div 都是容器元素
7495+
const grandfather = ul.parentElement.parentElement;
7496+
grandfather.childNodes.forEach((div) => div.classList.add('worksWrapper'));
7497+
this.needFind = false;
7498+
}
7499+
else {
7500+
// 约稿页面
7501+
// 为作品容器添加自定义 className
7502+
const allSection = document.querySelectorAll('section');
7503+
for (const section of allSection) {
7504+
if (section.parentElement?.nodeName == 'DIV') {
7505+
section.parentElement.classList.add('requestContainer');
7506+
}
7507+
}
7508+
}
7509+
}
74677510
}
74687511
}
74697512
new ShowLargerThumbnails();
@@ -15532,28 +15575,31 @@ __webpack_require__.r(__webpack_exports__);
1553215575
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
1553315576
/* harmony export */ InitRequestPage: () => (/* binding */ InitRequestPage)
1553415577
/* harmony export */ });
15535-
/* harmony import */ var _setting_Options__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../setting/Options */ "./src/ts/setting/Options.ts");
15536-
/* harmony import */ var _InitPageBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./InitPageBase */ "./src/ts/crawl/InitPageBase.ts");
15578+
/* harmony import */ var _EVT__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../EVT */ "./src/ts/EVT.ts");
15579+
/* harmony import */ var _PageType__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PageType */ "./src/ts/PageType.ts");
15580+
/* harmony import */ var _setting_Options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../setting/Options */ "./src/ts/setting/Options.ts");
15581+
/* harmony import */ var _InitPageBase__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InitPageBase */ "./src/ts/crawl/InitPageBase.ts");
15582+
15583+
1553715584

1553815585

1553915586
// 投稿页面
15540-
class InitRequestPage extends _InitPageBase__WEBPACK_IMPORTED_MODULE_1__.InitPageBase {
15587+
class InitRequestPage extends _InitPageBase__WEBPACK_IMPORTED_MODULE_3__.InitPageBase {
1554115588
constructor() {
1554215589
super();
1554315590
this.init();
1554415591
}
1554515592
initAny() {
15546-
// 为作品容器添加自定义 className,让显示更大的缩率图功能不那么容易失效
15547-
const allSection = document.querySelectorAll('section');
15548-
for (const section of allSection) {
15549-
if (section.parentElement?.nodeName == 'DIV') {
15550-
section.parentElement.classList.add('requestContainer');
15593+
// 约稿页面 和 已完成的约稿页面 互相切换时,需要重新隐藏第一个选项
15594+
window.addEventListener(_EVT__WEBPACK_IMPORTED_MODULE_0__.EVT.list.pageSwitch, () => {
15595+
if (_PageType__WEBPACK_IMPORTED_MODULE_1__.pageType.type === _PageType__WEBPACK_IMPORTED_MODULE_1__.pageType.list.Request) {
15596+
this.setFormOption();
1555115597
}
15552-
}
15598+
});
1555315599
}
1555415600
addCrawlBtns() { }
1555515601
setFormOption() {
15556-
_setting_Options__WEBPACK_IMPORTED_MODULE_0__.options.hideOption([1]);
15602+
_setting_Options__WEBPACK_IMPORTED_MODULE_2__.options.hideOption([1]);
1555715603
}
1555815604
}
1555915605

dist/js/content.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/style/showLargerThumbnails.css

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,13 @@ body[data-page-type='20'] div[width='184'] img {
591591
height: auto !important;
592592
max-height: 540px;
593593
}
594-
body[data-page-type='21'] .fKsmTC {
594+
body[data-page-type='21'] {
595+
/* img */
596+
/* div[width="184"] a div img */
597+
}
598+
body[data-page-type='21'] .fKsmTC,
599+
body[data-page-type='21'] .requestContainer,
600+
body[data-page-type='21'] .worksWrapper {
595601
width: 92vw;
596602
}
597603
body[data-page-type='21'] section ul {
@@ -602,6 +608,25 @@ body[data-page-type='21'] section ul {
602608
body[data-page-type='21'] section ul > div {
603609
margin: 24px;
604610
}
611+
body[data-page-type='21'] .worksUL {
612+
display: flex;
613+
flex-wrap: wrap;
614+
align-items: center;
615+
}
616+
body[data-page-type='21'] .worksUL > li {
617+
max-width: 540px;
618+
width: auto !important;
619+
}
620+
body[data-page-type='21'] .worksUL > li > div > div {
621+
width: auto !important;
622+
height: auto !important;
623+
}
624+
body[data-page-type='21'] .worksUL > li > div > div a > img {
625+
position: relative;
626+
width: auto !important;
627+
height: auto !important;
628+
max-height: 540px;
629+
}
605630
body[data-page-type='23'] .wrapperwrapper > div,
606631
body[data-page-type='23'] .ldgmym,
607632
body[data-page-type='23'] .bYCbxa {

src/style/showLargerThumbnails.css

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,13 @@ body[data-page-type='20'] div[width='184'] img {
620620
height: auto !important;
621621
max-height: 540px;
622622
}
623-
body[data-page-type='21'] .fKsmTC {
623+
body[data-page-type='21'] {
624+
/* img */
625+
/* div[width="184"] a div img */
626+
}
627+
body[data-page-type='21'] .fKsmTC,
628+
body[data-page-type='21'] .requestContainer,
629+
body[data-page-type='21'] .worksWrapper {
624630
width: 92vw;
625631
}
626632
body[data-page-type='21'] section ul {
@@ -631,6 +637,25 @@ body[data-page-type='21'] section ul {
631637
body[data-page-type='21'] section ul > div {
632638
margin: 24px;
633639
}
640+
body[data-page-type='21'] .worksUL {
641+
display: flex;
642+
flex-wrap: wrap;
643+
align-items: center;
644+
}
645+
body[data-page-type='21'] .worksUL > li {
646+
max-width: 540px;
647+
width: auto !important;
648+
}
649+
body[data-page-type='21'] .worksUL > li > div > div {
650+
width: auto !important;
651+
height: auto !important;
652+
}
653+
body[data-page-type='21'] .worksUL > li > div > div a > img {
654+
position: relative;
655+
width: auto !important;
656+
height: auto !important;
657+
max-height: 540px;
658+
}
634659
body[data-page-type='23'] .wrapperwrapper > div,
635660
body[data-page-type='23'] .ldgmym,
636661
body[data-page-type='23'] .bYCbxa {

src/style/showLargerThumbnails.less

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,10 +878,14 @@ body[data-page-type='20'] {
878878
// https://www.pixiv.net/request
879879
body[data-page-type='21'] {
880880
// 解除列表容器的宽度限制
881-
.fKsmTC {
881+
.fKsmTC,
882+
.requestContainer,
883+
.worksWrapper {
882884
width: 92vw;
883885
}
884886

887+
// 约稿页面
888+
885889
// ul
886890
// 图片列表容器(通常是 UL)元素是 grid 布局,改为 flex
887891
// 注意这个选择器会选择到图片列表之外的元素,例如作者卡片
@@ -895,6 +899,41 @@ body[data-page-type='21'] {
895899
section ul > div {
896900
margin: 24px;
897901
}
902+
903+
// 正在接稿中用户的作品
904+
// https://www.pixiv.net/request/creators/works/illust
905+
// 已完成的约稿页面
906+
// https://www.pixiv.net/request/complete/illust
907+
908+
// ul
909+
// 图片列表容器(通常是 UL)元素是 grid 布局,改为 flex
910+
.worksUL {
911+
display: flex;
912+
flex-wrap: wrap;
913+
align-items: center;
914+
}
915+
916+
// ul li
917+
// 解除作品项目的宽度限制
918+
.worksUL > li {
919+
max-width: 540px;
920+
width: auto !important;
921+
}
922+
923+
// 解除 img 父级元素 184px 的宽度限制
924+
.worksUL > li > div > div {
925+
width: auto !important;
926+
height: auto !important;
927+
}
928+
929+
/* img */
930+
/* div[width="184"] a div img */
931+
.worksUL > li > div > div a > img {
932+
position: relative;
933+
width: auto !important;
934+
height: auto !important;
935+
max-height: 540px;
936+
}
898937
}
899938

900939
// DiscoverUsers 发现用户

src/ts/ArtworkThumbnail.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ArtworkThumbnail extends WorkThumbnail {
3131
'li>div>div:first-child',
3232
'li>div>div:first-child>div',
3333
'li>div>div>div:first-child',
34+
'.worksUL li>div>div:first-child',
3435
'div[data-ga4-entity-id^="illust"]>div:nth-child(2)',
3536
'div[data-ga4-entity-id^="manga"]>div:nth-child(2)',
3637
]
@@ -41,8 +42,17 @@ class ArtworkThumbnail extends WorkThumbnail {
4142
// data-ga4-entity-id="novel/18205969"
4243
}
4344

44-
this.findThumbnail(document.body)
4545
this.createObserver(document.body)
46+
47+
// 立即查找一次元素
48+
this.findThumbnail(document.body)
49+
// 之后在某些页面里定时查找
50+
const findOnPageType = [pageType.list.Request]
51+
window.setInterval(() => {
52+
if (document.hidden === false && findOnPageType.includes(pageType.type)) {
53+
this.findThumbnail(document.body)
54+
}
55+
}, 1000)
4656
}
4757

4858
protected readonly selectors: string[] = []
@@ -93,8 +103,10 @@ class ArtworkThumbnail extends WorkThumbnail {
93103
}
94104

95105
// 只在 约稿 页面里使用
106+
// .worksUL li>div>div:first-child 是在“已完成的约稿”里使用的
96107
if (
97-
selector === 'li>div>div:first-child>div' &&
108+
(selector === 'li>div>div:first-child>div' ||
109+
selector === '.worksUL li>div>div:first-child') &&
98110
pageType.type !== pageType.list.Request
99111
) {
100112
continue

src/ts/ShowLargerThumbnails.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ class ShowLargerThumbnails {
4747
// 当页面元素变化时,允许重新查找。
4848
// 这主要是因为切换页面时,下载器可能先查找到了目标元素,但之后页面内容马上发生了变化,移除了目标元素。
4949
// 所以当元素变化时,需要重新查找,否则偶尔会显示异常
50-
const targetNode = document.querySelector('body')!
50+
const body = document.querySelector('body')!
5151
const observer = new MutationObserver(() => {
5252
this.needFind = true
5353
})
54-
observer.observe(targetNode, {
54+
observer.observe(body, {
5555
childList: true,
5656
subtree: true,
5757
})
@@ -297,6 +297,45 @@ class ShowLargerThumbnails {
297297
}
298298
}
299299
}
300+
301+
// 约稿页面,分为数种子页面
302+
if (pageType.type === pageType.list.Request) {
303+
// 正在接稿中用户的作品
304+
// https://www.pixiv.net/request/creators/works/illust
305+
// 已完成的约稿页面
306+
// https://www.pixiv.net/request/complete/illust
307+
if (
308+
window.location.pathname.includes('/request/complete') ||
309+
window.location.pathname.includes('/request/creators')
310+
) {
311+
// 首先查找作品列表的 UL 元素
312+
const illustLink = document.querySelector('ul li a[href^="/artworks/"]')
313+
if (!illustLink) {
314+
return
315+
}
316+
317+
const ul = illustLink.closest('ul')!
318+
ul.classList.add('worksUL')
319+
320+
// 查找容器元素
321+
// ul 的祖父元素是个 div,这个 div 里面的 3 个div 都是容器元素
322+
const grandfather = ul.parentElement!.parentElement!
323+
grandfather.childNodes.forEach((div) =>
324+
(div as HTMLDivElement).classList.add('worksWrapper')
325+
)
326+
327+
this.needFind = false
328+
} else {
329+
// 约稿页面
330+
// 为作品容器添加自定义 className
331+
const allSection = document.querySelectorAll('section')
332+
for (const section of allSection) {
333+
if (section.parentElement?.nodeName == 'DIV') {
334+
section.parentElement.classList.add('requestContainer')
335+
}
336+
}
337+
}
338+
}
300339
}
301340
}
302341

0 commit comments

Comments
 (0)