Skip to content

Commit c03e723

Browse files
committed
优化 Discuz! 论坛检测代码(应该没有遗漏了); 优化 代码
1 parent d3ca358 commit c03e723

1 file changed

Lines changed: 142 additions & 138 deletions

File tree

Autopage.user.js

Lines changed: 142 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// ==UserScript==
22
// @name 自动无缝翻页
3-
// @version 1.3.8
3+
// @version 1.3.9
44
// @author X.I.U
55
// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV...
66
// @match *://*/*
7-
// @exclude *://www.423down.com/*.html
8-
// @exclude *://apphot.cc/*.html
97
// @connect www.gamersky.com
108
// @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png
119
// @grant GM_xmlhttpRequest
@@ -34,29 +32,28 @@
3432
'fitgirl-repacks.site',
3533
'www.yxssp.com',
3634
'weibo.com',
37-
'www.afreecatv.com'];
35+
'www.afreecatv.com'], webType, curSite = {SiteTypeID: 0};
3836

3937
if (GM_getValue('menu_disable') == null){GM_setValue('menu_disable', [])};
4038
// 注册脚本菜单
4139
if (menu_disable('check')) { // 当前网站是否已存在禁用列表中
4240
GM_registerMenuCommand('❎ 已禁用 (点击对当前网站启用)', function(){menu_disable('del')});
4341
return
4442
} else {
45-
if (websiteList.indexOf(location.host) > -1 // 其他网站列表
46-
|| document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]') // 所有 Discuz! 论坛
47-
|| document.getElementById('flarum-loading') // 所有 Flarum 论坛
48-
) {
49-
GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')});
43+
if (websiteList.indexOf(location.host) > -1) {
44+
webType = 1 // 其他网站
45+
} else if (document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]') || document.getElementById('ft') && document.getElementById('ft').textContent.indexOf('Discuz!') > -1) {
46+
webType = 2 // 所有 Discuz! 论坛
47+
} else if (document.getElementById('flarum-loading')) {
48+
webType = 3 // 所有 Flarum 论坛
5049
} else {
5150
GM_registerMenuCommand('❌ 当前网站暂不支持 [点击申请支持]', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});});
5251
return
5352
}
53+
GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')});
5454
}
5555
GM_registerMenuCommand('💬 反馈 & 欢迎申请支持', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});});
5656

57-
// 默认 ID 为 0
58-
var curSite = {SiteTypeID: 0};
59-
6057
/*
6158
自动翻页规则
6259
type:
@@ -74,7 +71,7 @@
7471
after = 插入后执行函数;
7572
parameter = 参数
7673
*/
77-
let DBSite = {
74+
const DBSite = {
7875
discuz_forum: {
7976
SiteTypeID: 1,
8077
pager: {
@@ -470,135 +467,142 @@
470467
};
471468

472469

473-
switch (location.host) {
474-
case "www.423down.com":
475-
curSite = DBSite._423down_postslist;
476-
break;
477-
case "apphot.cc":
478-
curSite = DBSite.apphot_postslist;
479-
break;
480-
case "iao.su":
481-
curSite = DBSite.iao_su_postslist;
482-
break;
483-
case "www.appinn.com":
484-
curSite = DBSite.appinn_postslist;
485-
break;
486-
case "www.iplaysoft.com":
487-
if (location.pathname.indexOf(".html") > -1 || location.pathname.indexOf("/p/") > -1) { // 文章内
488-
curSite = DBSite.iplaysoft_postcomments;
489-
} else { // 其他页面
490-
curSite = DBSite.iplaysoft_postslist;
491-
}
492-
break;
493-
case "www.weidown.com":
494-
if (location.pathname.indexOf("/search/") > -1) {
495-
curSite = DBSite.weidown_search;
496-
} else if (location.pathname.indexOf("/special/") > -1) {
497-
curSite = DBSite.weidown_special;
498-
} else {
499-
curSite = DBSite.weidown;
500-
}
501-
break;
502-
case "www.yxssp.com":
503-
curSite = DBSite.yxssp;
504-
break;
505-
case "fitgirl-repacks.site":
506-
curSite = DBSite.fitgirl;
507-
break;
508-
case "art.alphacoders.com":
509-
curSite = DBSite.art_alphacoders;
510-
setTimeout(art_alphacoders_beforeFunction_0, 1000);
511-
break;
512-
case "wall.alphacoders.com":
513-
case "avatars.alphacoders.com":
514-
case "mobile.alphacoders.com":
515-
curSite = DBSite.wall_alphacoders;
516-
break;
517-
case "pubmed.ncbi.nlm.nih.gov":
518-
curSite = DBSite.pubmed_postslist;
519-
break;
520-
case "movie.douban.com":
521-
if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评
522-
curSite = DBSite.douban_subject_comments;
523-
} else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评
524-
curSite = DBSite.douban_subject_reviews;
525-
}else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论
526-
curSite = DBSite.douban_subject_episode;
527-
}
528-
break;
529-
case "search.douban.com":
530-
curSite = DBSite.douban_search;
531-
break;
532-
case "www.3dmgame.com":
533-
curSite = DBSite._3dmgame;
534-
break;
535-
case "www.gamersky.com":
536-
if (location.pathname.indexOf("/ent/") > -1) {
537-
curSite = DBSite.gamersky_ent;
538-
} else {
539-
curSite = DBSite.gamersky_gl;
540-
}
541-
//document.lastElementChild.appendChild(document.createElement('style')).textContent = `.Comment {display: none !important;}` // 隐藏评论区
542-
break;
543-
case "www.ali213.net":
544-
curSite = DBSite.ali213_www;
545-
break;
546-
case "gl.ali213.net":
547-
curSite = DBSite.ali213_gl;
548-
document.lastElementChild.appendChild(document.createElement('style')).textContent = `.n_show_b {display: none !important;}` // 隐藏部分碍事元素
549-
break;
550-
case "www.58pic.com":
551-
if (location.pathname.indexOf("/tupian/") > -1) {
552-
curSite = DBSite._58pic;
553-
} else if (location.pathname.indexOf("/c/") > -1) {
554-
curSite = DBSite._58pic_c;
555-
}
556-
break;
557-
case "rarbgprx.org":
558-
curSite = DBSite.rarbgprx;
559-
break;
560-
case "weibo.com":
561-
curSite = DBSite.weibo_comment;
562-
break;
563-
case "www.afreecatv.com":
564-
curSite = DBSite.afreecatv;
565-
break;
566-
default:
567-
if (document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]')) {
568-
// < 所有 Discuz!论坛 >
569-
if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾)
570-
if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表
571-
curSite = DBSite.discuz_forum;
572-
} else if (location.pathname.indexOf('thread') > -1) { // 帖子内
573-
curSite = DBSite.discuz_thread;
574-
hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮
575-
}else if(location.pathname.indexOf('search') > -1) { // 搜索结果
576-
curSite = DBSite.discuz_search;
577-
}
470+
if (webType === 1) { // < 其他网站 >
471+
switch (location.host) {
472+
case 'www.423down.com':
473+
if (location.pathname.indexOf('.html') === -1) curSite = DBSite._423down_postslist;
474+
break;
475+
case 'apphot.cc':
476+
if (location.pathname.indexOf('.html') === -1) curSite = DBSite.apphot_postslist;
477+
break;
478+
case 'iao.su':
479+
curSite = DBSite.iao_su_postslist;
480+
break;
481+
case 'www.appinn.com':
482+
curSite = DBSite.appinn_postslist;
483+
break;
484+
case 'www.iplaysoft.com':
485+
if (location.pathname.indexOf('.html') > -1 || location.pathname.indexOf('/p/') > -1) { // 文章内
486+
curSite = DBSite.iplaysoft_postcomments;
487+
} else { // 其他页面
488+
curSite = DBSite.iplaysoft_postslist;
489+
}
490+
break;
491+
case 'www.weidown.com':
492+
if (location.pathname.indexOf('/search/') > -1) {
493+
curSite = DBSite.weidown_search;
494+
} else if (location.pathname.indexOf('/special/') > -1) {
495+
curSite = DBSite.weidown_special;
578496
} else {
579-
if (location.search.indexOf('mod=forumdisplay') > -1) { // 各版块帖子列表
580-
curSite = DBSite.discuz_forum;
581-
} else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内
582-
curSite = DBSite.discuz_thread;
583-
hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮
584-
} else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表
585-
curSite = DBSite.discuz_guide;
586-
} else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复
587-
curSite = DBSite.discuz_youspace;
588-
} else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表
589-
curSite = DBSite.discuz_collection;
590-
} else if (location.pathname.indexOf('search') > -1) { // 搜索结果
591-
curSite = DBSite.discuz_search;
592-
} else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的
593-
curSite = DBSite.discuz_forum;
594-
}
497+
curSite = DBSite.weidown;
498+
}
499+
break;
500+
case 'www.yxssp.com':
501+
curSite = DBSite.yxssp;
502+
break;
503+
case 'fitgirl-repacks.site':
504+
curSite = DBSite.fitgirl;
505+
break;
506+
case 'art.alphacoders.com':
507+
curSite = DBSite.art_alphacoders;
508+
setTimeout(art_alphacoders_beforeFunction_0, 1000);
509+
break;
510+
case 'wall.alphacoders.com':
511+
case 'avatars.alphacoders.com':
512+
case 'mobile.alphacoders.com':
513+
curSite = DBSite.wall_alphacoders;
514+
break;
515+
case 'pubmed.ncbi.nlm.nih.gov':
516+
curSite = DBSite.pubmed_postslist;
517+
break;
518+
case 'movie.douban.com':
519+
if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评
520+
curSite = DBSite.douban_subject_comments;
521+
} else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评
522+
curSite = DBSite.douban_subject_reviews;
523+
} else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论
524+
curSite = DBSite.douban_subject_episode;
595525
}
596-
} else if (document.getElementById('flarum-loading') && location.pathname.indexOf('/d/') === -1) {
597-
// < 所有 Flarum 论坛 >
598-
curSite = DBSite.flarum;
526+
break;
527+
case 'search.douban.com':
528+
curSite = DBSite.douban_search;
529+
break;
530+
case 'www.3dmgame.com':
531+
curSite = DBSite._3dmgame;
532+
break;
533+
case 'www.gamersky.com':
534+
if (location.pathname.indexOf('/ent/') > -1) {
535+
curSite = DBSite.gamersky_ent;
536+
} else {
537+
curSite = DBSite.gamersky_gl;
538+
}
539+
break;
540+
case 'www.ali213.net':
541+
curSite = DBSite.ali213_www;
542+
break;
543+
case 'gl.ali213.net':
544+
curSite = DBSite.ali213_gl;
545+
document.lastElementChild.appendChild(document.createElement('style')).textContent = `.n_show_b {display: none !important;}` // 隐藏部分碍事元素
546+
break;
547+
case 'www.58pic.com':
548+
if (location.pathname.indexOf('/tupian/') > -1) {
549+
curSite = DBSite._58pic;
550+
} else if (location.pathname.indexOf('/c/') > -1) {
551+
curSite = DBSite._58pic_c;
552+
}
553+
break;
554+
case 'rarbgprx.org':
555+
curSite = DBSite.rarbgprx;
556+
break;
557+
case 'weibo.com':
558+
curSite = DBSite.weibo_comment;
559+
break;
560+
case 'www.afreecatv.com':
561+
curSite = DBSite.afreecatv;
562+
break;
563+
}
564+
} else if (webType === 2) { // < 所有 Discuz!论坛 >
565+
if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾)
566+
if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表
567+
if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮
568+
curSite = DBSite.discuz_forum;
569+
} else {
570+
curSite = DBSite.discuz_guide;
571+
}
572+
} else if (location.pathname.indexOf('thread') > -1) { // 帖子内
573+
curSite = DBSite.discuz_thread;
574+
hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮
575+
}else if(location.pathname.indexOf('search') > -1) { // 搜索结果
576+
curSite = DBSite.discuz_search;
599577
}
578+
} else {
579+
if (location.search.indexOf('mod=forumdisplay') > -1) { // 各版块帖子列表
580+
if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮
581+
curSite = DBSite.discuz_forum;
582+
} else {
583+
curSite = DBSite.discuz_guide;
584+
}
585+
} else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内
586+
curSite = DBSite.discuz_thread;
587+
hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮
588+
} else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表
589+
curSite = DBSite.discuz_guide;
590+
} else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复
591+
curSite = DBSite.discuz_youspace;
592+
} else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表
593+
curSite = DBSite.discuz_collection;
594+
} else if (location.pathname.indexOf('search') > -1) { // 搜索结果
595+
curSite = DBSite.discuz_search;
596+
} else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的
597+
curSite = DBSite.discuz_forum;
598+
}
599+
}
600+
} else if (webType === 3) { // < 所有 Flarum 论坛 >
601+
curSite = DBSite.flarum;
600602
}
601-
curSite.pageUrl = ""; // 下一页URL
603+
604+
605+
curSite.pageUrl = ''; // 下一页URL
602606
pageLoading(); // 自动无缝翻页
603607

604608

0 commit comments

Comments
 (0)