From cc6a0812710cd88dbf7380f54423e80b03507e25 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Wed, 28 Jul 2021 19:08:21 +0800 Subject: [PATCH 0001/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E5=BE=AE?= =?UTF-8?q?=E5=8D=9A=E8=AF=84=E8=AE=BA]=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 5c41adad6..107f03bb4 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.3.3 +// @version 1.3.4 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有 Discuz!论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed... +// @description 自动无缝翻页,目前支持:所有 Discuz!论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed... // @match *://*/* // @exclude *://www.423down.com/*.html // @exclude *://apphot.cc/*.html @@ -41,7 +41,8 @@ 'www.58pic.com', 'rarbgprx.org', 'www.yxssp.com', - 'pan.yuankongjian.com']; + 'pan.yuankongjian.com', + 'weibo.com']; if (GM_getValue('menu_disable') == null){GM_setValue('menu_disable', [])}; // 注册脚本菜单 @@ -420,6 +421,15 @@ nextText: '加载更多', scrollDelta: 500 } + }, + weibo_comment: { + SiteTypeID: 29, + pager: { + type: 2, + nextLink: 'a[action-type="click_more_comment"]', + nextText: '查看更多c', + scrollDelta: 1000 + } } }; @@ -516,6 +526,9 @@ curSite = DBSite.yuankongjian; } break; + case "weibo.com": + curSite = DBSite.weibo_comment; + break; default: // < Discuz! 论坛专用 > if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表 From 37ab90e9186220f09239f976df46eca27d5b32e6 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Thu, 29 Jul 2021 07:02:36 +0800 Subject: [PATCH 0002/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[AfreecaTV]=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 107f03bb4..9ba846c67 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.3.4 +// @version 1.3.5 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有 Discuz!论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed... +// @description 自动无缝翻页,目前支持:所有 Discuz!论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... // @match *://*/* // @exclude *://www.423down.com/*.html // @exclude *://apphot.cc/*.html @@ -23,26 +23,19 @@ (function() { 'use strict'; // 目前支持的网站 - var websiteList = ['www.423down.com', - 'apphot.cc', - 'iao.su', - 'www.appinn.com', - 'www.iplaysoft.com', - 'www.weidown.com', - 'fitgirl-repacks.site', + var websiteList = ['www.423down.com', 'apphot.cc', 'iao.su', 'www.appinn.com', 'www.iplaysoft.com', 'www.weidown.com', 'art.alphacoders.com', 'wall.alphacoders.com', 'avatars.alphacoders.com', 'mobile.alphacoders.com', 'pubmed.ncbi.nlm.nih.gov', 'movie.douban.com', 'search.douban.com', - 'www.3dmgame.com', - 'www.gamersky.com', - 'www.ali213.net', - 'gl.ali213.net', + 'www.3dmgame.com', 'www.gamersky.com', 'www.ali213.net', 'gl.ali213.net', 'www.58pic.com', 'rarbgprx.org', + 'fitgirl-repacks.site', 'www.yxssp.com', 'pan.yuankongjian.com', - 'weibo.com']; + 'weibo.com', + 'www.afreecatv.com']; if (GM_getValue('menu_disable') == null){GM_setValue('menu_disable', [])}; // 注册脚本菜单 @@ -430,6 +423,15 @@ nextText: '查看更多c', scrollDelta: 1000 } + }, + afreecatv: { + SiteTypeID: 30, + pager: { + type: 2, + nextLink: '.btn-more > button', + nextText: '查看更多', + scrollDelta: 1000 + } } }; @@ -529,6 +531,9 @@ case "weibo.com": curSite = DBSite.weibo_comment; break; + case "www.afreecatv.com": + curSite = DBSite.afreecatv; + break; default: // < Discuz! 论坛专用 > if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表 From d649e170d1eab9cbc181f60a8533168d0b00a9dd Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Thu, 29 Jul 2021 19:32:58 +0800 Subject: [PATCH 0003/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DarkMode.user.js | 13 +-- GithubEnhanced-High-Speed-Download.user.js | 25 +----- Zhihu-Beautification.user.js | 94 ++++++++-------------- 3 files changed, 36 insertions(+), 96 deletions(-) diff --git a/DarkMode.user.js b/DarkMode.user.js index 270cfcb7a..c5d240ff1 100644 --- a/DarkMode.user.js +++ b/DarkMode.user.js @@ -95,18 +95,9 @@ } + // 菜单数字图标 function menu_num(num) { - switch(num) { - case 1: - return '1️⃣' - break; - case 2: - return '2️⃣' - break; - case 3: - return '3️⃣' - break; - } + return ['0️⃣','1️⃣','2️⃣','3️⃣','4️⃣','5️⃣','6️⃣','7️⃣','8️⃣','9️⃣','🔟'][num] } diff --git a/GithubEnhanced-High-Speed-Download.user.js b/GithubEnhanced-High-Speed-Download.user.js index 41d4f8294..e98e8dd99 100644 --- a/GithubEnhanced-High-Speed-Download.user.js +++ b/GithubEnhanced-High-Speed-Download.user.js @@ -109,30 +109,9 @@ registerMenuCommand(); // 重新注册脚本菜单 }; + // 菜单数字图标 function menu_num(num) { - switch(num) { - case 0: - return '0️⃣' - break; - case 1: - return '1️⃣' - break; - case 2: - return '2️⃣' - break; - case 3: - return '3️⃣' - break; - case 4: - return '4️⃣' - break; - case 5: - return '5️⃣' - break; - case 6: - return '6️⃣' - break; - } + return ['0️⃣','1️⃣','2️⃣','3️⃣','4️⃣','5️⃣','6️⃣','7️⃣','8️⃣','9️⃣','🔟'][num] } addRelease(); // Release 加速 diff --git a/Zhihu-Beautification.user.js b/Zhihu-Beautification.user.js index a54af2007..0a16498db 100644 --- a/Zhihu-Beautification.user.js +++ b/Zhihu-Beautification.user.js @@ -67,9 +67,9 @@ } GM_setValue(`${Name}`, menu_status); if (menu_status === 1) { // 设置 Cookie - if (getTheme() === 'light') document.cookie="theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/"; + if (getTheme() === 'light') document.cookie='theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/'; } else { - if (getTheme() === 'dark') document.cookie="theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; + if (getTheme() === 'dark') document.cookie='theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; } if (menu_value('menu_darkMode')) { location.reload(); // 刷新网页 @@ -79,21 +79,9 @@ } }; + // 菜单数字图标 function menu_num(num) { - switch(num) { - case 1: - return '1️⃣' - break; - case 2: - return '2️⃣' - break; - case 3: - return '3️⃣' - break; - case 4: - return '4️⃣' - break; - } + return ['0️⃣','1️⃣','2️⃣','3️⃣','4️⃣','5️⃣','6️⃣','7️⃣','8️⃣','9️⃣','🔟'][num] } // 菜单开关 @@ -102,7 +90,7 @@ GM_setValue(`${Name}`, false); if (Name === 'menu_darkMode') { // 暗黑模式 - if (getTheme() === 'dark') document.cookie="theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; + if (getTheme() === 'dark') document.cookie='theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; location.reload(); // 刷新网页 } else { GM_notification({text: `已关闭 [${Tips}] 功能\n(刷新网页后生效)`, timeout: 3500}); @@ -112,9 +100,9 @@ if (Name === 'menu_darkMode') { if (menu_value('menu_darkModeType') === 1) { - if (getTheme() === 'light') document.cookie="theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/"; + if (getTheme() === 'light') document.cookie='theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/'; } else { - if (getTheme() === 'dark') document.cookie="theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; + if (getTheme() === 'dark') document.cookie='theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; } location.reload(); // 刷新网页 } else { @@ -254,6 +242,10 @@ html[data-theme=dark] body::-webkit-scrollbar-thumb, html[data-theme="dark"] .Me html[data-theme=dark] body::-webkit-scrollbar-track {background: #22272e !important;} html[data-theme=dark] .MessagesBox::-webkit-scrollbar-track, html[data-theme="dark"] .Messages-list::-webkit-scrollbar-track, html[data-theme=dark] .PushNotifications-list::-webkit-scrollbar-track, html[data-theme=dark] .CommentListV2::-webkit-scrollbar-track, .ChatListGroup-SectionContent::-webkit-scrollbar-track, html[data-theme=dark] .ChatSideBar-Search-ResultListWrap::-webkit-scrollbar-track, html[data-theme=dark] .ChatBox textarea.Input::-webkit-scrollbar-track {background: #2d333b !important;} +/* 滚动条 - 回答目录 */ +html[data-theme=dark] .AnswerItem .RichContent-hasCatalog .RichContent-inner .Catalog.isCatalogV2::-webkit-scrollbar {width: 0 !important;} +html[data-theme=dark] .AnswerItem .RichContent-hasCatalog .RichContent-inner .Catalog.isCatalogV2 > :first-child {background: #2D333B !important;} + html {scrollbar-width: thin; scrollbar-color: #3f4752 #22272e;} .MessagesBox, .Messages-list, .PushNotifications-list, .CommentListV2, .ChatListGroup-SectionContent, .ChatSideBar-Search-ResultListWrap {scrollbar-width: thin; scrollbar-color: #3f4752 #2D333B;} @@ -308,21 +300,24 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();} ` let style_Add = document.createElement('style'); - // 暗黑模式 + // 如果开启了暗黑模式 if (menu_value('menu_darkMode')) { + // 如果暗黑模式为 1 if (menu_value('menu_darkModeType') === 1) { + // 如果当前知乎主题为白天模式,那就是改为暗黑模式 if (getTheme() === 'light') { - document.cookie="theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/"; + document.cookie='theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/'; document.lastChild.setAttribute('data-theme', 'dark'); location.reload(); // 刷新网页 } + // 如果是问题日志页,则改为暗黑模式 if (location.pathname.indexOf('/log') > -1) { document.documentElement.setAttribute('data-theme', 'dark'); style_darkMode_1 += style_darkMode_1_x; } - } else { + } else { // 如果是其他暗黑模式,则需要确保为白天模式 if (getTheme() === 'dark') { - document.cookie="theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; + document.cookie='theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; document.lastChild.setAttribute('data-theme', 'light'); location.reload(); // 刷新网页 } @@ -348,67 +343,42 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();} } } else { if (getTheme() === 'dark'){ - document.cookie="theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; + document.cookie='theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; document.lastChild.setAttribute('data-theme', 'light'); location.reload(); // 刷新网页 } } // 宽屏显示 - if (menu_value('menu_widescreenDisplay')) { - style += style_1; - } - + if (menu_value('menu_widescreenDisplay')) style += style_1; // 调整图片最大高度 - if (menu_value('menu_picHeight')) { - style += style_5; - } - + if (menu_value('menu_picHeight')) style += style_5; // 隐藏文章开头大图 - if (menu_value('menu_postimg')) { - style += style_2; - } - + if (menu_value('menu_postimg')) style += style_2; // 向下翻时自动隐藏顶栏 - if (menu_value('menu_hideTitle')) { - style += style_4; - } + if (menu_value('menu_hideTitle')) style += style_4; // 文章编辑页面与实际文章宽度一致 - if(window.location.href.indexOf("zhuanlan") > -1){ - if(window.location.href.indexOf("/edit") > -1){ - style += style_3; - } - } - - /*style_Add.innerHTML = style; - if (document.head) { - document.head.appendChild(style_Add); - } else { - let timer = setInterval(function(){ - if (document.head) { - document.head.appendChild(style_Add); - clearInterval(timer); - } - }, 1); - }*/ + if (window.location.href.indexOf('zhuanlan') > -1 && window.location.href.indexOf('/edit') > -1) style += style_3; if (document.lastChild) { document.lastChild.appendChild(style_Add).textContent = style; } else { // 避免网站加载速度太慢的备用措施 - let timer1 = setInterval(function(){ // 每 5 毫秒检查一下 html 是否已存在 + let timer1 = setInterval(function(){ // 每 10 毫秒检查一下 html 是否已存在 if (document.lastChild) { clearInterval(timer1); // 取消定时器 document.lastChild.appendChild(style_Add).textContent = style; } - }, 5); + }, 10); } } + + + // 获取知乎 Cookie 中的主题类型 function getTheme() { - let name = "theme="; - let ca = document.cookie.split(';'); - for(let i=0; i Date: Fri, 30 Jul 2021 07:25:41 +0800 Subject: [PATCH 0004/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E5=85=B3=E9=94=AE=E8=AF=8D]=20=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AF=B9=E8=AF=84=E8=AE=BA=E7=9A=84=E6=94=AF=E6=8C=81=20(#59)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加屏蔽评论功能 * 支持通知等其他地方的评论屏蔽 --- Zhihu-Enhanced.user.js | 51 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js index 28d0a1f78..c3e1e6cff 100644 --- a/Zhihu-Enhanced.user.js +++ b/Zhihu-Enhanced.user.js @@ -483,6 +483,9 @@ function blockKeywords(type) { case 'search': blockKeywords_search(); break; + case 'comment': + blockKeywords_comment(); + break; } function blockKeywords_index_() { @@ -630,6 +633,52 @@ function blockKeywords(type) { } document.addEventListener('DOMNodeInserted', blockKeywords); // 监听插入事件 } + + + function blockKeywords_comment() { + function filterComment(comment) { + let content = comment.querySelector('.RichText'); + let texts = [content.textContent.toLowerCase()]; + for (let i = 0; i < content.children.length; i++) { + let emoticonValue = content.children[i].getAttribute('data-zhihu-emoticon'); + if (emoticonValue) { + texts.push(emoticonValue) + } + } + + let keywords = menu_value('menu_customBlockKeywords'); + for (const text of texts) { + for (const keyword of keywords) { // 遍历关键词黑名单 + if (text.indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该信息流 + console.log(text); + content.textContent = '[已屏蔽]'; + break; + } + } + } + } + function blockKeywords(node) { + switch (node.className) { + case 'NestComment--rootComment': + case 'NestComment--child': + case 'CommentItemV2': + filterComment(node); + break; + } + } + + const callback = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + for (const node of target.querySelectorAll('*')) { + blockKeywords(node); + } + } + } + }; + const observer = new MutationObserver(callback); + observer.observe(document, { childList: true, subtree: true }); + } } @@ -992,12 +1041,12 @@ function questionInvitation(){ }); } - (function() { addEventListener_DOMNodeInserted(); // 监听 网页插入元素 事件 questionInvitation(); // 默认折叠邀请 setInterval(originalPic,100); // 默认高清原图 if (menu_value('menu_directLink')) setInterval(directLink, 100); // 默认站外直链 + blockKeywords('comment'); // 评论屏蔽指定关键词 if (window.location.href.indexOf("question") > -1) { // 回答页 // if (window.location.href.indexOf("waiting") == -1) { From 54722b3dd79047b9dcca1c2c5fc39dfdacf2cf63 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 30 Jul 2021 15:23:31 +0800 Subject: [PATCH 0005/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81(DOMNodeInserted=20=E6=94=B9=E4=B8=BA=20MutationObserv?= =?UTF-8?q?er)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zhihu-Enhanced.user.js | 633 ++++++++++++++++++++++++----------------- 1 file changed, 374 insertions(+), 259 deletions(-) diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js index 28d0a1f78..ea6e03a6a 100644 --- a/Zhihu-Enhanced.user.js +++ b/Zhihu-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 知乎增强 -// @version 1.5.0 +// @version 1.5.1 // @author X.I.U // @description 移除登录弹窗、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题)、屏蔽盐选内容、展开问题描述、置顶显示时间、显示问题时间、区分问题文章、默认高清原图、默认站外直链 // @match *://www.zhihu.com/* @@ -238,7 +238,7 @@ function blockUsers(type) { if (!menu_value('menu_customBlockUsers') || menu_value('menu_customBlockUsers').length < 1) return switch(type) { case 'index': - blockUsers_index(); + blockUsers_('.Card.TopstoryItem.TopstoryItem--old.TopstoryItem-isRecommend', 'Card TopstoryItem TopstoryItem--old TopstoryItem-isRecommend'); break; case 'question': blockUsers_question(); @@ -246,6 +246,9 @@ function blockUsers(type) { case 'search': blockUsers_search(); break; + case 'topic': + blockUsers_('.List-item.TopicFeedItem', 'List-item TopicFeedItem'); + break; case 'people': blockUsers_button_people(); // 添加屏蔽用户按钮(用户主页) break; @@ -253,59 +256,109 @@ function blockUsers(type) { blockUsers_comment(); // 评论区 blockUsers_button(); // 加入黑名单按钮 - function blockUsers_index() { - let blockUsers = e => { - if (e.target.innerHTML && e.target.getElementsByClassName('Feed').length > 0) { - let item = e.target.getElementsByClassName('Feed')[0].getElementsByClassName('ContentItem AnswerItem')[0]; // 用户名所在元素 + function blockUsers_(className1, className2) { + // 前几条因为是直接加载的,而不是动态插入网页的,所以需要单独判断 + function blockKeywords_now() { + document.querySelectorAll(className1).forEach(function(item1){ + let item = item1.querySelector('.ContentItem.AnswerItem, .ContentItem.ArticleItem'); // 用户名所在元素 if (item) { - menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单 - if (item.dataset.zop.indexOf('authorName":"' + item1 + '",') > -1) { // 找到就删除该信息流 + for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历用户名黑名单 + if (item.dataset.zop.indexOf('authorName":"' + keyword + '",') > -1) { // 找到就删除该信息流 console.log(item.dataset.zop); - item.parentNode.parentNode.remove(); + item1.remove(); + break; } - }) + } } - } + }) } - document.addEventListener('DOMNodeInserted', blockUsers); // 监听插入事件 - - let listItem = document.getElementsByClassName('Card TopstoryItem TopstoryItem--old TopstoryItem-isRecommend'); - Array.from(listItem).forEach(function(item){ // 遍历所有回答 - let listName = item.querySelector('.ContentItem.AnswerItem') // 用户名所在元素 - if (listName) { - menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单 - if (listName.dataset.zop.indexOf('authorName":"' + item1 + '",') > -1) { // 找到就删除该信息流 - console.log(listName.dataset.zop); - item.remove(); + + blockKeywords_now(); + addLocationchange(); + window.addEventListener('locationchange', function(){ + setTimeout(blockKeywords_now, 500); // 网页 URL 变化后再次执行 + }) + + // 这个是监听网页插入事件,用来判断后续网页动态插入的元素 + const callback = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.className === className2) { + let item = target.querySelector('.ContentItem.AnswerItem, .ContentItem.ArticleItem'); // 用户名所在元素 + if (item) { + for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历用户名黑名单 + if (item.dataset.zop.indexOf('authorName":"' + keyword + '",') > -1) { // 找到就删除该信息流 + console.log(item.dataset.zop); + target.remove(); + break; + } + } + } } - }) + } } - }) + }; + const observer = new MutationObserver(callback); + observer.observe(document, { childList: true, subtree: true }); } + function blockUsers_question() { - let blockUsers = e => { - if (e.target.innerHTML && e.target.getElementsByClassName('ContentItem AnswerItem').length > 0) { - let item = e.target.getElementsByClassName('ContentItem AnswerItem')[0]; // 用户名所在元素 - if (item) { - menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单 - if (item.dataset.zop.indexOf('authorName":"' + item1 + '",') > -1) { // 找到就删除该回答 - console.log(item.dataset.zop) - item.parentNode.remove(); + const blockUsers_question_ = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.className === 'List-item' || target.className === 'Card AnswerCard') { + let item1 = target.querySelector('.ContentItem.AnswerItem'); + if (item1) { + menu_value('menu_customBlockUsers').forEach(function(item2){ // 遍历用户黑名单 + if (item1.dataset.zop.indexOf('authorName":"' + item2 + '",') > -1) { // 找到就删除该回答 + console.log(item1.dataset.zop) + target.remove(); + } + }) + } + } + } + } + }; + + const blockUsers_question_answer_ = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + target.querySelectorAll('.List-item, .Card.AnswerCard').forEach(function(item){ + let item1 = item.querySelector('.ContentItem.AnswerItem'); + if (item1) { + menu_value('menu_customBlockUsers').forEach(function(item2){ // 遍历用户黑名单 + if (item1.dataset.zop.indexOf('authorName":"' + item2 + '",') > -1) { // 找到就删除该回答 + console.log(item1.dataset.zop) + item.remove(); + } + }) } }) } } + }; + + if (location.pathname.indexOf('/answer/') > -1) { // 回答页(就是只有三个回答的页面) + const observer = new MutationObserver(blockUsers_question_answer_); + observer.observe(document, { childList: true, subtree: true }); + } else { // 问题页(可以显示所有回答的页面) + const observer = new MutationObserver(blockUsers_question_); + observer.observe(document, { childList: true, subtree: true }); } - document.addEventListener('DOMNodeInserted', blockUsers); // 监听插入事件 - - let listItem = document.getElementsByClassName('ContentItem AnswerItem'); - Array.from(listItem).forEach(function(item){ // 遍历所有回答 // 用户名所在元素 - if (item) { - menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单 - if (item.dataset.zop.indexOf('authorName":"' + item1 + '",') > -1) { // 找到就删除该回答 - console.log(item.dataset.zop) - item.parentNode.remove(); + + // 针对的是打开网页后直接加载的前面几个回答(上面哪些是针对动态加载的回答) + document.querySelectorAll('.List-item, .Card.AnswerCard').forEach(function(item){ + let item1 = item.querySelector('.ContentItem.AnswerItem'); + if (item1) { + menu_value('menu_customBlockUsers').forEach(function(item2){ // 遍历用户黑名单 + if (item1.dataset.zop.indexOf('authorName":"' + item2 + '",') > -1) { // 找到就删除该回答 + console.log(item1.dataset.zop) + item.remove(); } }) } @@ -313,75 +366,115 @@ function blockUsers(type) { } function blockUsers_search() { - let blockUsers = e => { - if (e.target.innerHTML && e.target.getElementsByClassName('List-item').length > 0) { - let item = e.target.getElementsByClassName('List-item')[0]; - let listName = item.querySelector('.RichText.ztext.CopyrightRichText-richText b') // 用户名所在元素 - if (listName) { - menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单 - if (item1 === listName.innerText) { // 找到就删除该搜索结果 - console.log(listName.innerText); - item.parentNode.remove(); + function blockUsers_now() { + if (location.search.indexOf('type=content') === -1) return // 目前只支持搜索页的 [综合] + document.querySelectorAll('.Card.SearchResult-Card[data-za-detail-view-path-module="AnswerItem"], .Card.SearchResult-Card[data-za-detail-view-path-module="PostItem"]').forEach(function(item1){ + let item = item1.querySelector('.RichText.ztext.CopyrightRichText-richText b'); // 标题所在元素 + if (item) { + for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历关键词黑名单 + if (item.textContent === keyword) { // 找到就删除该信息流 + console.log(item.textContent); + item1.remove(); + break; } - }) + } } - } + }) } - document.addEventListener('DOMNodeInserted', blockUsers); // 监听插入事件 + + setTimeout(blockUsers_now, 500); + addLocationchange(); + window.addEventListener('locationchange', function(){ + setTimeout(blockUsers_now, 500); // 网页 URL 变化后再次执行 + }) + + const callback = (mutationsList, observer) => { + if (location.search.indexOf('type=content') === -1) return // 目前只支持搜索页的 [综合] + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.className === 'Card SearchResult-Card' && (target.dataset.zaDetailViewPathModule === 'AnswerItem' || target.dataset.zaDetailViewPathModule === 'PostItem')) { + let item = target.querySelector('.RichText.ztext.CopyrightRichText-richText b'); // 用户名所在元素 + if (item) { + for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历用户名黑名单 + if (item.textContent === keyword) { // 找到就删除该信息流 + console.log(item.textContent); + target.remove(); + break; + } + } + } + } + } + } + }; + const observer = new MutationObserver(callback); + observer.observe(document, { childList: true, subtree: true }); } function blockUsers_comment() { - let blockUsers = e => { - if (e.target.innerHTML && e.target.querySelector('img.Avatar.UserLink-avatar[width="24"]')) { - let item = e.target.querySelectorAll('img.Avatar.UserLink-avatar[width="24"]') - item.forEach(function(item1){ // 遍历用户名 - menu_value('menu_customBlockUsers').forEach(function(item2){ // 遍历用户黑名单 - if (item1.alt === item2) { // 找到就删除该搜索结果 - if (item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--rootCommentNoChild' || item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--rootComment') { - item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); - } else if (item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--rootCommentNoChild' || item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--rootComment') { - item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); - } else if (item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--child') { - item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); - } else if (item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--child') { - item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); - } else if (item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment') { - item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); - } else if (item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'CommentItemV2') { - item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + const callback = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + let item = target.querySelector('img.Avatar.UserLink-avatar') + if (item) { + menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单 + if (item.alt === item1) { // 找到就删除该搜索结果 + // 试了多种方案,感觉还是这个简单粗暴,缺点就是一旦知乎框架改了就失效了,但好在知乎也不会天天改~ + if (item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--rootCommentNoChild' || item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--rootComment') { + item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + } else if (item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--rootCommentNoChild' || item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--rootComment') { + item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + } else if (item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--child') { + item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + } else if (item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment--child') { + item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + } else if (item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'NestComment') { + item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + } else if (item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'CommentItemV2') { + item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + } } - } - }) + }) - // 添加屏蔽用户按钮(点赞、回复等按钮后面) - if (item1) { - let footer = item1.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('.CommentItemV2-metaSibling > .CommentItemV2-footer'), - userid = item1.parentNode; - if (userid && footer && !footer.lastElementChild.dataset.name) { - userid = userid.href.split('/')[4]; - footer.insertAdjacentHTML('beforeend',``); - footer.lastElementChild.onclick = function(){blockUsers_button_add(this.dataset.name, this.dataset.userid, false)} + // 添加屏蔽用户按钮(点赞、回复等按钮后面) + if (item) { + let footer = item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('.CommentItemV2-metaSibling > .CommentItemV2-footer'), + userid = item.parentNode; + if (userid && footer && !footer.lastElementChild.dataset.name) { + userid = userid.href.split('/')[4]; + footer.insertAdjacentHTML('beforeend',``); + footer.lastElementChild.onclick = function(){blockUsers_button_add(this.dataset.name, this.dataset.userid, false)} + } } } - }) + } } - } - document.addEventListener('DOMNodeInserted', blockUsers); // 监听插入事件 + }; + const observer = new MutationObserver(callback); + observer.observe(document, { childList: true, subtree: true }); } // 添加屏蔽用户按钮(用户信息悬浮框中) function blockUsers_button() { - let blockUsers = e => { - if (e.target.innerHTML && e.target.querySelector('.MemberButtonGroup.ProfileButtonGroup.HoverCard-buttons')) { - let item = e.target.querySelector('.MemberButtonGroup.ProfileButtonGroup.HoverCard-buttons'), - item1 = item.parentNode.parentNode.querySelector('a.UserLink-link'), - name = item1.innerText, - userid = item1.href.split('/')[4]; - item.insertAdjacentHTML('beforeend', ``); - item.lastElementChild.onclick = function(){blockUsers_button_add(this.dataset.name, this.dataset.userid, false)} + const callback = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.className.indexOf('Popover-content Popover-content--top HoverCard-popoverTarget') > -1 || target.className.indexOf('Popover-content Popover-content--bottom HoverCard-popoverTarget') > -1 || target.querySelector('.Popover-content.Popover-content--top.HoverCard-popoverTarget') || target.querySelector('.Popover-content.Popover-content--bottom.HoverCard-popoverTarget')) { + let item = target.querySelector('.MemberButtonGroup.ProfileButtonGroup.HoverCard-buttons'), + item1 = target.querySelector('a.UserLink-link'), + name = item1.textContent, + userid = item1.href.split('/')[4]; + item.insertAdjacentHTML('beforeend', ``); + item.lastElementChild.onclick = function(){blockUsers_button_add(this.dataset.name, this.dataset.userid, false)} + } + } } - } - document.addEventListener('DOMNodeInserted', blockUsers); // 监听插入事件 + }; + const observer = new MutationObserver(callback); + observer.observe(document, { childList: true, subtree: true }); } // 添加屏蔽用户按钮(用户主页) @@ -453,7 +546,7 @@ function blockUsers(type) { function customBlockKeywords() { let nowBlockKeywords = ''; menu_value('menu_customBlockKeywords').forEach(function(item){nowBlockKeywords += '|' + item}) - let newBlockKeywords = prompt('编辑 [自定义屏蔽关键词]\n(不同关键词之间使用 "|" 分隔,例如:关键词A|关键词B|关键词C \n(关键词不区分大小写', nowBlockKeywords.replace('|','')); + let newBlockKeywords = prompt('编辑 [自定义屏蔽关键词]\n(不同关键词之间使用 "|" 分隔,例如:关键词A|关键词B|关键词C \n(关键词不区分大小写,支持表情如:[捂脸]|[飙泪笑]', nowBlockKeywords.replace('|','')); if (newBlockKeywords === '') { GM_setValue('menu_customBlockKeywords', []); registerMenuCommand(); // 重新注册脚本菜单 @@ -464,171 +557,160 @@ function customBlockKeywords() { }; -// 屏蔽指定关键词(标题) +// 屏蔽指定关键词 function blockKeywords(type) { if (!menu_value('menu_blockKeywords')) return if (!menu_value('menu_customBlockKeywords') || menu_value('menu_customBlockKeywords').length < 1) return switch(type) { case 'index': - blockKeywords_index_(); - blockKeywords_index(); + blockKeywords_('.Card.TopstoryItem.TopstoryItem--old.TopstoryItem-isRecommend', 'Card TopstoryItem TopstoryItem--old TopstoryItem-isRecommend'); break; case 'topic': - blockKeywords_topic(); - blockKeywords_people(); + blockKeywords_('.List-item.TopicFeedItem', 'List-item TopicFeedItem'); break; case 'people': - blockKeywords_people(); + blockKeywords_('.List-item', 'List-item'); break; case 'search': blockKeywords_search(); break; + case 'comment': + blockKeywords_comment(); + break; } - function blockKeywords_index_() { - let item = document.querySelectorAll('h2.ContentItem-title meta[itemprop="name"]'); // 标题所在元素 - if (item.length > 0) { - item.forEach(function(item2){ - //console.log(item2) - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item2.content.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log(item2.content); - if (item2.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'Feed') { - item2.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); - } else { - item2.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + + function blockKeywords_(className1, className2) { + // 前几条因为是直接加载的,而不是动态插入网页的,所以需要单独判断 + function blockKeywords_now() { + document.querySelectorAll(className1).forEach(function(item1){ + let item = item1.querySelector('h2.ContentItem-title meta[itemprop="name"], meta[itemprop="headline"]'); // 标题所在元素 + if (item) { + for (const keyword of menu_value('menu_customBlockKeywords')) { // 遍历关键词黑名单 + if (item.content.toLowerCase().indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该信息流 + console.log(item.content); + item1.hidden = true; + break; } } - }) - }) - } - // 如果是文章标题 - item = document.querySelectorAll('.ContentItem.ArticleItem meta[itemprop="headline"]'); // 标题所在元素 - if (item.length > 0) { - item.forEach(function(item2){ - //console.log(item2) - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item2.content.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log('文章',item2.content); - item2.parentNode.parentNode.parentNode.remove(); - } - }) + } }) } - } - function blockKeywords_index() { - let blockKeywords = e => { - if (e.target.innerHTML && e.target.getElementsByClassName('ContentItem-title').length > 0) { - let item = e.target.querySelector('h2.ContentItem-title meta[itemprop="name"]'); // 标题所在元素 - if (item) { - //console.log(item) - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item.content.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log(item.content); - if (item.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'Feed') { - item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); - } else { - item.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + blockKeywords_now(); + addLocationchange(); + window.addEventListener('locationchange', function(){ + setTimeout(blockKeywords_now, 500); // 网页 URL 变化后再次执行 + }) + + // 这个是监听网页插入事件,用来判断后续网页动态插入的元素 + const callback = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.className === className2) { + let item = target.querySelector('h2.ContentItem-title meta[itemprop="name"], meta[itemprop="headline"]'); // 标题所在元素 + if (item) { + for (const keyword of menu_value('menu_customBlockKeywords')) { // 遍历关键词黑名单 + if (item.content.toLowerCase().indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该信息流 + console.log(item.content); + target.hidden = true; + break; + } } } - }) - } else { // 如果是文章标题 - item = e.target.querySelector('.ContentItem.ArticleItem meta[itemprop="headline"]'); // 标题所在元素 - if (item) { - //console.log(item) - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item.content.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log('文章',item.content); - item.parentNode.parentNode.parentNode.remove(); - } - }) } } } - } - document.addEventListener('DOMNodeInserted', blockKeywords); // 监听插入事件 + }; + const observer = new MutationObserver(callback); + observer.observe(document, { childList: true, subtree: true }); } - function blockKeywords_topic() { - let item = document.querySelectorAll('h2.ContentItem-title meta[itemprop="name"]'); // 标题所在元素 - if (item.length > 0) { - //console.log(item) - item.forEach(function(item2){ - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item2.content.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log(item2.content); - item2.parentNode.parentNode.parentNode.parentNode.remove(); - } - }) - }) - } - // 如果是文章标题 - item = document.querySelectorAll('.ContentItem.ArticleItem meta[itemprop="headline"]'); // 标题所在元素 - if (item.length > 0) { - //console.log(item) - item.forEach(function(item2){ - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item2.content.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log('文章',item2.content); - item2.parentNode.parentNode.remove(); + function blockKeywords_search() { + function blockKeywords_now() { + if (location.search.indexOf('type=content') === -1) return // 目前只支持搜索页的 [综合] + document.querySelectorAll('.Card.SearchResult-Card[data-za-detail-view-path-module="AnswerItem"], .Card.SearchResult-Card[data-za-detail-view-path-module="PostItem"]').forEach(function(item1){ + let item = item1.querySelector('a[data-za-detail-view-id]'); // 标题所在元素 + if (item) { + for (const keyword of menu_value('menu_customBlockKeywords')) { // 遍历关键词黑名单 + if (item.textContent.toLowerCase().indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该信息流 + console.log(item.textContent); + item1.hidden = true; + break; + } } - }) + } }) } - } + setTimeout(blockKeywords_now, 500); + addLocationchange(); + window.addEventListener('locationchange', function(){ + setTimeout(blockKeywords_now, 500); // 网页 URL 变化后再次执行 + }) - function blockKeywords_people() { - let blockKeywords = e => { - if (e.target.innerHTML && e.target.getElementsByClassName('ContentItem-title').length > 0) { - let item = e.target.querySelector('h2.ContentItem-title meta[itemprop="name"]'); // 标题所在元素 - if (item) { - console.log(item) - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item.content.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log(item.content); - item.parentNode.parentNode.parentNode.parentNode.remove(); - } - }) - } else { // 如果是文章标题 - item = e.target.querySelector('.ContentItem.ArticleItem meta[itemprop="headline"]'); // 标题所在元素 - if (item) { - console.log(item) - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item.content.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log('文章',item.content); - item.parentNode.parentNode.remove(); + const callback = (mutationsList, observer) => { + if (location.search.indexOf('type=content') === -1) return // 目前只支持搜索页的 [综合] + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.className === 'Card SearchResult-Card' && (target.dataset.zaDetailViewPathModule === 'AnswerItem' || target.dataset.zaDetailViewPathModule === 'PostItem')) { + let item = target.querySelector('a[data-za-detail-view-id]'); // 标题所在元素 + if (item) { + for (const keyword of menu_value('menu_customBlockKeywords')) { // 遍历关键词黑名单 + if (item.textContent.toLowerCase().indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该信息流 + console.log(item.textContent); + target.remove(); + break; + } } - }) + } } } } - } - document.addEventListener('DOMNodeInserted', blockKeywords); // 监听插入事件 + }; + const observer = new MutationObserver(callback); + observer.observe(document, { childList: true, subtree: true }); } - function blockKeywords_search() { - let blockKeywords = e => { - if (location.search.indexOf('&type=content') === -1) return - //if (e.target.innerHTML) console.log(e.target.innerHTML) - if (e.target.innerHTML && e.target.getElementsByClassName('ContentItem-title').length > 0) { - //console.log(e.target.innerHTML) - let item = e.target.querySelector('h2.ContentItem-title a[data-za-detail-view-id]'); // 标题所在元素 - if (item) { - //console.log(item) - menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词黑名单 - if (item.innerText.toLowerCase().indexOf(item1.toLowerCase()) > -1) { // 找到就删除该信息流 - console.log(item.innerText); - item.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); - } - }) + function blockKeywords_comment() { + function filterComment(comment) { + let content = comment.querySelector('.RichText'); // 寻找评论文字所在元素 + let texts = [content.textContent.toLowerCase()]; // 因为要针对评论中的表情,所以需要整个数组并全部转为小写(用来不区分大小写) + for (let i = 0; i < content.children.length; i++) { // 该条针对的是评论中的表情 + let emoticonValue = content.children[i].getAttribute('data-zhihu-emoticon'); // 确定是表情就将其添加到稍后遍历的数组中 + if (emoticonValue) { + texts.push(emoticonValue) + } + } + + let keywords = menu_value('menu_customBlockKeywords'); + for (const text of texts) { + for (const keyword of keywords) { // 遍历关键词黑名单 + if (text.indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该评论 + console.log(text); + content.textContent = '[该评论已屏蔽]'; + break; + } } } } - document.addEventListener('DOMNodeInserted', blockKeywords); // 监听插入事件 + + const callback = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + for (const node of target.querySelectorAll('*')) { + if (node.className === 'CommentItemV2-metaSibling') filterComment(node); + } + } + } + }; + const observer = new MutationObserver(callback); + observer.observe(document, { childList: true, subtree: true }); } } @@ -636,17 +718,43 @@ function blockKeywords(type) { // 屏蔽盐选内容 function blockYanXuan() { if (!menu_value('menu_blockYanXuan')) return - let blockYanXuan = e => { - if (e.target.innerHTML && e.target.getElementsByClassName('KfeCollection-PurchaseBtn-mask').length > 0) { - let item = e.target.getElementsByClassName('KfeCollection-PurchaseBtn-mask')[0]; - item.parentNode.parentNode.parentNode.parentNode.parentNode.remove(); + const blockYanXuan_question = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.className === 'List-item' || target.className === 'Card AnswerCard') { + if (target.querySelector('.KfeCollection-AnswerTopCard-Container, .KfeCollection-PurchaseBtn')) { + target.remove(); + } + } + } + } + }; + + const blockYanXuan_question_answer = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + target.querySelectorAll('.List-item, .Card.AnswerCard').forEach(function(item){ + if (item.querySelector('.KfeCollection-AnswerTopCard-Container, .KfeCollection-PurchaseBtn')) { + item.remove(); + } + }) + } } + }; + + if (location.pathname.indexOf('/answer/') > -1) { // 回答页(就是只有三个回答的页面) + const observer = new MutationObserver(blockYanXuan_question_answer); + observer.observe(document, { childList: true, subtree: true }); + } else { // 问题页(可以显示所有回答的页面) + const observer = new MutationObserver(blockYanXuan_question); + observer.observe(document, { childList: true, subtree: true }); } - document.addEventListener('DOMNodeInserted', blockYanXuan); // 监听插入事件 - let listItem = document.getElementsByClassName('List-item'); - Array.from(listItem).forEach(function(item){ - if (item.getElementsByClassName('KfeCollection-PurchaseBtn-mask').length > 0) { + // 针对的是打开网页后直接加载的前面几个回答(上面哪些是针对动态加载的回答) + document.querySelectorAll('.List-item, .Card.AnswerCard').forEach(function(item){ + if (item.querySelector('.KfeCollection-AnswerTopCard-Container, .KfeCollection-PurchaseBtn')) { item.remove(); } }) @@ -693,52 +801,38 @@ function addTypeTips() { function questionRichTextMore() { if (!menu_value('menu_questionRichTextMore')) return let button = document.querySelector('button.QuestionRichText-more'); - if (button) { - button.click() - } + if (button) button.click() } -// 监听 网页插入元素 事件 -function addEventListener_DOMNodeInserted() { - // 知乎免登录,修改自:https://greasyfork.org/zh-CN/scripts/417126 - let removeLoginModal = e => { - if (e.target.innerHTML && e.target.getElementsByClassName('Modal-wrapper').length > 0) { - if (e.target.getElementsByClassName('Modal-wrapper')[0].querySelector('.signFlowModal')){ - let button = e.target.getElementsByClassName('Button Modal-closeButton Button--plain')[0]; - if (button)button.click(); - } - } - } - - // 收起当前评论(监听点击事件,点击网页两侧空白处) - let collapseNowComment = e => { - if (e.target.innerHTML && e.target.getElementsByClassName('Modal-wrapper Modal-enter').length > 0) { - document.getElementsByClassName('Modal-backdrop')[0].onclick = function(event){ - if (event.target==this) { - let closeButton = document.getElementsByClassName('Modal-closeButton')[0] - if(closeButton) { - closeButton.click(); - } +// 知乎免登录 +function removeLogin() { + const removeLoginModal = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.querySelector('.signFlowModal')) { + let button = target.getElementsByClassName('Button Modal-closeButton Button--plain')[0]; + if (button) button.click(); } } } - } + }; // 未登录时才会监听并移除登录弹窗 - if(window.location.href.indexOf("zhuanlan") > -1) { // 如果是文章页 - if (!document.querySelector('button.ColumnPageHeader-MenuToggler')) { // 判断不存在,则已登录 - document.addEventListener('DOMNodeInserted', removeLoginModal); + if(window.location.href.indexOf('zhuanlan') > -1) { // 如果是文章页 + if (!document.querySelector('button.ColumnPageHeader-MenuToggler')) { // 如果不存在,则代表已登录 + const observer = new MutationObserver(removeLoginModal); + observer.observe(document, { childList: true, subtree: true }); } } else { // 不是文章页 - if (document.querySelector('button.AppHeader-login')) { // 如果存在,则未登录 - document.addEventListener('DOMNodeInserted', removeLoginModal); + if (document.querySelector('button.AppHeader-login')) { // 如果存在,则代表未登录 + const observer = new MutationObserver(removeLoginModal); + observer.observe(document, { childList: true, subtree: true }); document.querySelector('button.AppHeader-login').onclick=function(){location.href='https://www.zhihu.com/signin';} // [登录] 按钮跳转至登录页面 document.querySelector('.AppHeader-profile button.Button--primary').onclick=function(){location.href='https://www.zhihu.com/signin';} // [加入知乎] 按钮跳转至注册页面(实际上是同一个页面) } } - - document.addEventListener('DOMNodeInserted', collapseNowComment); // 收起当前评论(监听点击事件,点击网页两侧空白处) } @@ -992,12 +1086,33 @@ function questionInvitation(){ }); } +// 自定义 locationchange 事件(用来监听 URL 变化) +function addLocationchange() { + history.pushState = ( f => function pushState(){ + var ret = f.apply(this, arguments); + window.dispatchEvent(new Event('pushstate')); + window.dispatchEvent(new Event('locationchange')); + return ret; + })(history.pushState); + + history.replaceState = ( f => function replaceState(){ + var ret = f.apply(this, arguments); + window.dispatchEvent(new Event('replacestate')); + window.dispatchEvent(new Event('locationchange')); + return ret; + })(history.replaceState); + + window.addEventListener('popstate',()=>{ + window.dispatchEvent(new Event('locationchange')) + }); +} (function() { - addEventListener_DOMNodeInserted(); // 监听 网页插入元素 事件 + removeLogin(); // 移除登录弹窗 questionInvitation(); // 默认折叠邀请 setInterval(originalPic,100); // 默认高清原图 if (menu_value('menu_directLink')) setInterval(directLink, 100); // 默认站外直链 + blockKeywords('comment'); // 屏蔽指定关键词(评论) if (window.location.href.indexOf("question") > -1) { // 回答页 // if (window.location.href.indexOf("waiting") == -1) { @@ -1024,7 +1139,7 @@ function questionInvitation(){ collapsedNowAnswer(".ContentLayout"); // 收起当前回答 + 快捷返回顶部 setInterval(topTime_people, 300); // 置顶显示时间 EventXMLHttpRequest(); // 区分问题文章 - blockUsers(); // 屏蔽指定用户 + blockUsers('topic'); // 屏蔽指定用户 blockKeywords('topic'); // 屏蔽指定关键词 } } else if (window.location.href.indexOf("zhuanlan") > -1){ // 文章 // @@ -1042,7 +1157,7 @@ function questionInvitation(){ collapsedNowAnswer("main div"); // 收起当前回答 + 快捷返回顶部 collapsedNowAnswer(".Profile-main"); // 收起当前回答 + 快捷返回顶部 setInterval(topTime_people, 300); // 置顶显示时间 - blockUsers('people'); // 屏蔽指定用户 + blockUsers('people'); // 屏蔽指定用户 blockKeywords('people'); // 屏蔽指定关键词 } else { // 首页 // collapsedAnswer(); // 一键收起回答 From 4dbc7793b3ce7edbf9f011d0bac7af93541460fb Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 30 Jul 2021 15:50:18 +0800 Subject: [PATCH 0006/2043] README.md --- README.md | 2 +- Zhihu-Enhanced.user.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7521ae615..9f5a93892 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ | :----: | :---- | :---- | :----: | | [](https://github.com/XIU2) | **护眼模式** | 简单有效的全网通用护眼模式、夜间模式、暗黑模式~ | **[安装](https://greasyfork.org/zh-CN/scripts/426377)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/DarkMode.user.js)** | | [](https://www.zhihu.com/people/xiu2) | **知乎 美化** | 宽屏显示、**暗黑模式**、隐藏文章开头大图、调整图片最大高... | **[安装](https://greasyfork.org/zh-CN/scripts/412212)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhihu-Beautification.user.js)** | -| [](https://www.zhihu.com/people/xiu2) | **知乎 增强** | **移除登录弹窗**、一键收起回答、屏蔽用户、屏蔽关键词(标题)... | **[安装](https://greasyfork.org/zh-CN/scripts/419081)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhihu-Enhanced.user.js)** | +| [](https://www.zhihu.com/people/xiu2) | **知乎 增强** | **移除登录弹窗**、一键收起回答、屏蔽用户、屏蔽关键词、快... | **[安装](https://greasyfork.org/zh-CN/scripts/419081)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhihu-Enhanced.user.js)** | | [](https://www.v2ex.com/) | **V2ex 增强** | **自动签到**、链接转图片、自动无缝翻页、新标签页打开链接... | **[安装](https://greasyfork.org/zh-CN/scripts/424246)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/V2ex-Enhanced.user.js)** | | [](https://github.com/XIU2) | **Github 增强** | **高速下载** Git Clone/SSH、Release、Raw、Code(ZIP) 文件... | **[安装](https://greasyfork.org/zh-CN/scripts/412245)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/GithubEnhanced-High-Speed-Download.user.js)** | | [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz!论坛**、423Down、不死鸟、小众软件、异次... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js index ea6e03a6a..4c527aea7 100644 --- a/Zhihu-Enhanced.user.js +++ b/Zhihu-Enhanced.user.js @@ -2,7 +2,7 @@ // @name 知乎增强 // @version 1.5.1 // @author X.I.U -// @description 移除登录弹窗、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题)、屏蔽盐选内容、展开问题描述、置顶显示时间、显示问题时间、区分问题文章、默认高清原图、默认站外直链 +// @description 移除登录弹窗、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题/评论)、屏蔽盐选内容、展开问题描述、置顶显示时间、显示问题时间、区分问题文章、默认高清原图、默认站外直链 // @match *://www.zhihu.com/* // @match *://zhuanlan.zhihu.com/* // @icon https://static.zhihu.com/heifetz/favicon.ico From 2a0516f352502322e87a870f6db75f01d0b766c4 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 30 Jul 2021 20:11:13 +0800 Subject: [PATCH 0007/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81(=E6=97=B6=E9=97=B4=E9=97=B4=E9=9A=94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DarkMode.user.js | 10 +++++----- Zhihu-Beautification.user.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DarkMode.user.js b/DarkMode.user.js index c5d240ff1..4506049cd 100644 --- a/DarkMode.user.js +++ b/DarkMode.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 护眼模式 -// @version 1.2.2 +// @version 1.2.3 // @author X.I.U // @description 简单有效的全网通用护眼模式、夜间模式、暗黑模式 // @match *://*/* @@ -316,7 +316,7 @@ clearInterval(timer1); // 取消定时器 document.lastChild.appendChild(style_Add).textContent = style; } - }, 5); + }); } let websiteList = []; @@ -325,7 +325,7 @@ } // 为了避免 body 还没加载导致无法检查是否设置背景颜色 - let timer = setInterval(function(){ // 每 10 毫秒检查一下 body 是否已存在 + let timer = setInterval(function(){ // 每 5 毫秒检查一下 body 是否已存在 if (document.body) { clearInterval(timer); // 取消定时器(每 10 毫秒一次的) setTimeout(function(){ // 为了避免太快 body 的 CSS 还没加载上,先延迟 150 毫秒(缺点就是可能会出现短暂一闪而过的暗黑滤镜) @@ -365,7 +365,7 @@ } }, 1500); } - }, 10); + }); // 用来解决一些 CSS 加载缓慢的网站,可能会出现没有正确排除的问题,在没有找到更好的办法之前,先这样凑活着用 /*setTimeout(function(){ @@ -391,7 +391,7 @@ document.lastChild.appendChild(style_Add).textContent = style; clearInterval(timer1); } - }, 10); + }); } } diff --git a/Zhihu-Beautification.user.js b/Zhihu-Beautification.user.js index 0a16498db..5c75b5dd6 100644 --- a/Zhihu-Beautification.user.js +++ b/Zhihu-Beautification.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 知乎美化 -// @version 1.2.6 +// @version 1.2.7 // @author X.I.U // @description 宽屏显示、暗黑模式(4种)、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、文章编辑页面与实际文章宽度一致、屏蔽登录提示 // @match *://www.zhihu.com/* @@ -369,7 +369,7 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();} clearInterval(timer1); // 取消定时器 document.lastChild.appendChild(style_Add).textContent = style; } - }, 10); + }); } } From 7d7afafc9b771f9c392974490e926e97999f6dbe Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 30 Jul 2021 20:45:55 +0800 Subject: [PATCH 0008/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GithubEnhanced-High-Speed-Download.user.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/GithubEnhanced-High-Speed-Download.user.js b/GithubEnhanced-High-Speed-Download.user.js index e98e8dd99..77e807e7c 100644 --- a/GithubEnhanced-High-Speed-Download.user.js +++ b/GithubEnhanced-High-Speed-Download.user.js @@ -44,7 +44,7 @@ //['https://gh.66ccff.work', '美国'], //['https://github.91chifun.workers.dev', '美国'], //['https://github.rc1844.workers.dev', '美国'], - var download_url = [ + const download_url = [ ['https://gh.api.99988866.xyz', '美国'], ['https://gh.msx.workers.dev', '美国'], ['https://gh.xiu2.xyz', '美国'], @@ -75,9 +75,8 @@ '', '' ], - style = ['padding:0 6px;margin-right: -1px;border-radius: 2px;background-color: '+backColor+';border-color: rgba(27, 31, 35, 0.1);font-size: 11px;color: '+fontColor+';'], - menu_raw_fast = GM_getValue('xiu2_menu_raw_fast'), - menu_menu_raw_fast_ID, menu_feedBack_ID; + style = ['padding:0 6px;margin-right: -1px;border-radius: 2px;background-color: '+backColor+';border-color: rgba(27, 31, 35, 0.1);font-size: 11px;color: '+fontColor+';']; + var menu_raw_fast = GM_getValue('xiu2_menu_raw_fast'), menu_menu_raw_fast_ID, menu_feedBack_ID; if (menu_raw_fast == null){menu_raw_fast = 1; GM_setValue('xiu2_menu_raw_fast', 1)}; registerMenuCommand(); @@ -403,7 +402,7 @@ } - // 自定义 locationchange 事件(用来监听 URL 变化,针对的是 Github 这种因为使用 pjax 而无法依靠 hashchange 监听的网页) + // 自定义 locationchange 事件(用来监听 URL 变化) function addLocationchange() { history.pushState = ( f => function pushState(){ var ret = f.apply(this, arguments); From a8fd47f38d56db9ec85bc290c1d4e11772399116 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sat, 31 Jul 2021 11:07:35 +0800 Subject: [PATCH 0009/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=98=AF=E5=90=A6=E7=99=BB=E5=BD=95=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=88=E7=94=A8=E6=9D=A5=E7=A1=AE=E5=AE=9A=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E7=AD=BE=E5=88=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hostloc-Enhanced.user.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Hostloc-Enhanced.user.js b/Hostloc-Enhanced.user.js index 884f077d7..c0b72ad42 100644 --- a/Hostloc-Enhanced.user.js +++ b/Hostloc-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 全球主机交流论坛增强 -// @version 1.3.0 +// @version 1.3.1 // @author X.I.U // @description 自动签到(访问空间)、屏蔽用户(黑名单)、屏蔽关键词(帖子标题)、回帖小尾巴、自动无缝翻页、快捷回到顶部(右键点击两侧空白处)、收起预览帖子(左键点击两侧空白处)、预览帖子快速回复带签名、显示是否在线、显示帖子内隐藏回复、屏蔽阅读权限 255 帖子 // @match *://hostloc.com/* @@ -92,6 +92,8 @@ var loginStatus = false; if (document.getElementById('um')){ loginStatus = true; + } else { + loginStatus = getLoginStatus(); } // 默认 ID 为 0 @@ -252,7 +254,7 @@ // 自定义屏蔽用户 function customBlockUsers() { let nowBlockUsers = ''; - GM_getValue('menu_customBlockUsers').forEach(function(item){nowBlockUsers = nowBlockUsers + '|' + item}) + GM_getValue('menu_customBlockUsers').forEach(function(item){nowBlockUsers += '|' + item}) let newBlockUsers = prompt('编辑 [自定义屏蔽用户],刷新网页后生效\n(不同用户名之间使用 "|" 分隔,\n(例如:用户A|用户B|用户C,如果只有一个就不需要 "|" 了。', nowBlockUsers.replace('|','')); if (newBlockUsers === '') { GM_setValue('menu_customBlockUsers', []); @@ -305,7 +307,7 @@ function blockUsers_vfastpost() { let vfastpost = e => { if (e.target.innerHTML && e.target.innerHTML.indexOf('id="vfastpost"') > -1) { - let listItem = e.target.querySelectorAll('[id^="post_"]'); + let listItem = e.target.querySelectorAll('.bm_c > [id^="post_"]'); if (listItem.length < 1) return listItem.forEach(function(item){ // 遍历所有回复 menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单 @@ -326,7 +328,7 @@ // 自定义屏蔽关键词(帖子标题) function customBlockKeywords() { let nowBlockKeywords = ''; - GM_getValue('menu_customBlockKeywords').forEach(function(item){nowBlockKeywords = nowBlockKeywords + '|' + item}) + GM_getValue('menu_customBlockKeywords').forEach(function(item){nowBlockKeywords += '|' + item}) let newBlockKeywords = prompt('编辑 [自定义屏蔽关键词],刷新网页后生效\n(不同关键词之间使用 "|" 分隔,\n(例如:助力|互助|互点,如果只有一个就不需要 "|" 了。', nowBlockKeywords.replace('|','')); if (newBlockKeywords === '') { GM_setValue('menu_customBlockKeywords', []); @@ -707,4 +709,12 @@ } }(i); } + + + // 通过 Cookie 来判断是否登录 + function getLoginStatus() { + let cookie = document.cookie.split(';'); + for (let i=0; i -1) { diff --git a/Zhihu-Beautification.user.js b/Zhihu-Beautification.user.js index 5c75b5dd6..93cc26bbb 100644 --- a/Zhihu-Beautification.user.js +++ b/Zhihu-Beautification.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 知乎美化 -// @version 1.2.7 +// @version 1.2.8 // @author X.I.U // @description 宽屏显示、暗黑模式(4种)、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、文章编辑页面与实际文章宽度一致、屏蔽登录提示 // @match *://www.zhihu.com/* @@ -19,8 +19,8 @@ // @homepageURL https://github.com/XIU2/UserScript // ==/UserScript== -'use strict'; (function() { + 'use strict'; var menu_ALL = [ ['menu_widescreenDisplay', '宽屏显示', '宽屏显示', true], ['menu_darkMode', '暗黑模式', '暗黑模式', true], @@ -278,7 +278,7 @@ html[data-theme=dark] div#zh-hovercard a {color: #353535 !important;} html {filter: invert(80%) !important;} img, .ZVideoItem-video, .ZVideo-video {filter: invert(1) !important;} .GifPlayer img, .GifPlayer.isPlaying video {filter: invert(1) !important;} -.GifPlayer.isPlaying img.ztext-gif.GifPlayer-gif2mp4Image {filter: none !important;} +.GifPlayer.isPlaying img.ztext-gif.GifPlayer-gif2mp4Image, img[alt="[公式]"] {filter: none !important;} `, style_darkMode_2_firefox = `/* 暗黑模式(方案 2) */ html {filter: invert(80%) !important; background-image: url();} From c99520b9d4b249d6dcdb0dac710bbba136bc0ba9 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sat, 31 Jul 2021 21:42:30 +0800 Subject: [PATCH 0013/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hostloc-Enhanced.user.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Hostloc-Enhanced.user.js b/Hostloc-Enhanced.user.js index c0b72ad42..bed296967 100644 --- a/Hostloc-Enhanced.user.js +++ b/Hostloc-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 全球主机交流论坛增强 -// @version 1.3.1 +// @version 1.3.2 // @author X.I.U // @description 自动签到(访问空间)、屏蔽用户(黑名单)、屏蔽关键词(帖子标题)、回帖小尾巴、自动无缝翻页、快捷回到顶部(右键点击两侧空白处)、收起预览帖子(左键点击两侧空白处)、预览帖子快速回复带签名、显示是否在线、显示帖子内隐藏回复、屏蔽阅读权限 255 帖子 // @match *://hostloc.com/* @@ -20,8 +20,8 @@ // @homepageURL https://github.com/XIU2/UserScript // ==/UserScript== -'use strict'; (function() { + 'use strict'; var menu_ALL = [ ['menu_autoSignIn', '自动签到', '自动签到', true], ['menu_reAutoSignIn', '重新签到', '重新签到', ''], @@ -418,7 +418,9 @@ if (e.target.innerHTML && e.target.innerHTML.indexOf('id="vfastpost"') > -1) { let message = e.target.querySelector('input[name="message"]'), id = message.id.match(/\d+/g)[0]; message.parentNode.innerHTML = `` - document.getElementById(`vreplysubmit_${id}`).onclick = function(){document.getElementById(`vmessage_${id}`).value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');} + document.getElementById(`vreplysubmit_${id}`).onclick = function(){ + if (GM_getValue('menu_customLittleTail')) document.getElementById(`vmessage_${id}`).value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n'); + } } } document.addEventListener('DOMNodeInserted', vfastpost); // 监听插入事件 @@ -427,20 +429,26 @@ function littleTail_1() { let floatlayout_reply = e => { if (e.target.innerHTML && e.target.innerHTML.indexOf('id="floatlayout_reply"') > -1) { - document.getElementById('postsubmit').onclick = function(){document.getElementById('postmessage').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');} + document.getElementById('postsubmit').onclick = function(){ + if (GM_getValue('menu_customLittleTail')) document.getElementById('postmessage').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n'); + } } } document.addEventListener('DOMNodeInserted', floatlayout_reply); // 监听插入事件 } function littleTail_2() { // 帖子底部的回复框 - document.getElementById('fastpostsubmit').onclick = function(){document.getElementById('fastpostmessage').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');} + document.getElementById('fastpostsubmit').onclick = function(){ + if (GM_getValue('menu_customLittleTail')) document.getElementById('fastpostmessage').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n'); + } } function littleTail_3() { let postsubmit = document.getElementById('postsubmit'); if (postsubmit && postsubmit.innerText === '\n参与/回复主题\n' || postsubmit && postsubmit.innerText === '\n发表帖子\n') { - postsubmit.onclick = function(){document.getElementById('e_textarea').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');} + postsubmit.onclick = function(){ + if (GM_getValue('menu_customLittleTail')) document.getElementById('e_textarea').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n'); + } } } } From 509fa6ca31ed167242505b19865c52434aa1bd74 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Mon, 2 Aug 2021 13:08:45 +0800 Subject: [PATCH 0014/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=AF=B9=20Disc?= =?UTF-8?q?uz!=20=E8=AE=BA=E5=9D=9B=E7=9A=84=20[=E5=AF=BC=E8=AF=BB?= =?UTF-8?q?=E3=80=81=E6=B7=98=E5=B8=96=E3=80=81=E6=88=91=E7=9A=84=E5=B8=96?= =?UTF-8?q?=E5=AD=90/=E5=9B=9E=E5=A4=8D=E3=80=81=E5=88=AB=E4=BA=BA?= =?UTF-8?q?=E7=9A=84=E5=B8=96=E5=AD=90/=E5=9B=9E=E5=A4=8D]=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81;=20=E4=BC=98=E5=8C=96=20Discuz!=20=E8=AE=BA=E5=9D=9B?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 111 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 35 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 9ba846c67..876dfd6da 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.3.5 +// @version 1.3.6 // @author X.I.U // @description 自动无缝翻页,目前支持:所有 Discuz!论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... // @match *://*/* @@ -43,11 +43,11 @@ GM_registerMenuCommand('❎ 已禁用 (点击对当前网站启用)', function(){menu_disable('del')}); return } else { - if (websiteList.indexOf(location.host) > -1 || document.querySelector('meta[name="author"][content*="Discuz!"]')) { + if (websiteList.indexOf(location.host) > -1 || document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]')) { GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')}); } else { - - GM_registerMenuCommand('❌ 当前网站暂不支持,请点击下方选项申请支持~'); + 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});}); + return } } 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});}); @@ -104,8 +104,41 @@ scrollDelta: 1000 } }, - _423down_postslist: { + discuz_guide: { SiteTypeID: 4, + pager: { + type: 1, + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;div#threadlist div.bm_c table > tbody', + HT_insert: ['css;div#threadlist div.bm_c table', 3], + replaceE: 'css;div.pg', + scrollDelta: 1000 + } + }, + discuz_youspace: { + SiteTypeID: 5, + pager: { + type: 1, + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;tbody > tr:not(.th)', + HT_insert: ['css;tbody', 3], + replaceE: 'css;div.pg', + scrollDelta: 1000 + } + }, + discuz_collection: { + SiteTypeID: 6, + pager: { + type: 1, + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;div#ct div.bm_c table > tbody', + HT_insert: ['css;div#ct div.bm_c table', 3], + replaceE: 'css;div.pg', + scrollDelta: 1000 + } + }, + _423down_postslist: { + SiteTypeID: 7, pager: { type: 1, nextLink: '//div[@class="paging"]//a[contains(text(),"下一页")][@href]', @@ -116,7 +149,7 @@ } }, apphot_postslist: { - SiteTypeID: 5, + SiteTypeID: 8, pager: { type: 1, nextLink: '//div[@class="pagination"]//a[contains(text(),"下一页")][@href]', @@ -127,7 +160,7 @@ } }, iao_su_postslist: { - SiteTypeID: 6, + SiteTypeID: 9, pager: { type: 1, nextLink: '//li[@class="btn btn-primary next"]//a[@href]', @@ -141,7 +174,7 @@ } }, appinn_postslist: { - SiteTypeID: 7, + SiteTypeID: 10, pager: { type: 1, nextLink: '//a[@class="next page-numbers"][@href]', @@ -152,7 +185,7 @@ } }, iplaysoft_postslist: { - SiteTypeID: 8, + SiteTypeID: 11, pager: { type: 1, nextLink: '//div[@class="pagenavi"]//a[@title="下一页"][@href]', @@ -166,7 +199,7 @@ } }, iplaysoft_postcomments: { - SiteTypeID: 9, + SiteTypeID: 12, pager: { type: 2, nextLink: '#loadHistoryComments', @@ -175,7 +208,7 @@ } }, pubmed_postslist: { - SiteTypeID: 10, + SiteTypeID: 13, pager: { type: 2, nextLink: 'button.load-button.next-page', @@ -184,7 +217,7 @@ } }, wall_alphacoders: { - SiteTypeID: 11, + SiteTypeID: 14, pager: { type: 1, nextLink: '//a[@id="next_page"][@href]', @@ -195,7 +228,7 @@ } }, art_alphacoders: { - SiteTypeID: 12, + SiteTypeID: 15, pager: { type: 1, nextLink: '//a[@id="next_page"][@href]', @@ -209,7 +242,7 @@ } }, fitgirl: { - SiteTypeID: 13, + SiteTypeID: 16, pager: { type: 1, nextLink: '//a[@class="next page-numbers"][@href]', @@ -220,7 +253,7 @@ } }, weidown: { - SiteTypeID: 14, + SiteTypeID: 17, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -231,7 +264,7 @@ } }, weidown_search: { - SiteTypeID: 14, + SiteTypeID: 18, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -242,7 +275,7 @@ } }, weidown_special: { - SiteTypeID: 14, + SiteTypeID: 19, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -253,7 +286,7 @@ } }, douban_subject_comments: { - SiteTypeID: 15, + SiteTypeID: 20, pager: { type: 1, nextLink: '//a[@class="next"][@href]', @@ -264,7 +297,7 @@ } }, douban_subject_reviews: { - SiteTypeID: 16, + SiteTypeID: 21, pager: { type: 1, nextLink: '//link[@rel="next"][@href]', @@ -275,7 +308,7 @@ } }, douban_subject_episode: { - SiteTypeID: 17, + SiteTypeID: 22, pager: { type: 1, nextLink: '//link[@rel="next"][@href]', @@ -286,7 +319,7 @@ } }, douban_search: { - SiteTypeID: 18, + SiteTypeID: 23, pager: { type: 1, nextLink: '//a[@class="next"][@href]', @@ -297,7 +330,7 @@ } }, _3dmgame: { - SiteTypeID: 19, + SiteTypeID: 24, pager: { type: 3, nextLink: '//li[@class="next"]/a[@href]', @@ -309,7 +342,7 @@ } }, gamersky_ent: { - SiteTypeID: 20, + SiteTypeID: 25, pager: { type: 3, nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]', @@ -321,7 +354,7 @@ } }, gamersky_gl: { - SiteTypeID: 21, + SiteTypeID: 26, pager: { type: 3, nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]', @@ -333,7 +366,7 @@ } }, ali213_www: { - SiteTypeID: 22, + SiteTypeID: 27, pager: { type: 3, nextLink: '//a[@id="after_this_page"][@href]', @@ -345,7 +378,7 @@ } }, ali213_gl: { - SiteTypeID: 23, + SiteTypeID: 28, pager: { type: 3, nextLink: '//a[@class="next n"][@href]', @@ -357,7 +390,7 @@ } }, _58pic: { - SiteTypeID: 24, + SiteTypeID: 29, pager: { type: 1, nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]', @@ -371,7 +404,7 @@ } }, _58pic_c: { - SiteTypeID: 25, + SiteTypeID: 30, pager: { type: 1, nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]', @@ -385,7 +418,7 @@ } }, rarbgprx: { - SiteTypeID: 26, + SiteTypeID: 31, pager: { type: 1, nextLink: '(//a[@title="next page"])[1][@href]', @@ -396,7 +429,7 @@ } }, yxssp: { - SiteTypeID: 27, + SiteTypeID: 32, pager: { type: 1, nextLink: '//div[@class="page-nav td-pb-padding-side"]/a[last()][@href]', @@ -407,7 +440,7 @@ } }, yuankongjian: { - SiteTypeID: 28, + SiteTypeID: 33, pager: { type: 2, nextLink: 'button[title="加载更多"]', @@ -416,7 +449,7 @@ } }, weibo_comment: { - SiteTypeID: 29, + SiteTypeID: 34, pager: { type: 2, nextLink: 'a[action-type="click_more_comment"]', @@ -425,7 +458,7 @@ } }, afreecatv: { - SiteTypeID: 30, + SiteTypeID: 35, pager: { type: 2, nextLink: '.btn-more > button', @@ -534,7 +567,7 @@ case "www.afreecatv.com": curSite = DBSite.afreecatv; break; - default: // < Discuz! 论坛专用 > + default: // < Discuz! 论坛专用 > if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表 curSite = DBSite.discuz_forum; @@ -550,8 +583,16 @@ } else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内 curSite = DBSite.discuz_thread; hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + } else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表 + curSite = DBSite.discuz_guide; + } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复 + curSite = DBSite.discuz_youspace; + } else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表 + curSite = DBSite.discuz_collection; } else if (location.pathname.indexOf('search') > -1) { // 搜索结果 curSite = DBSite.discuz_search; + } else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的 + curSite = DBSite.discuz_forum; } } } @@ -571,7 +612,7 @@ let scrollElement = document.querySelector(curSite.pager.scrollElement); //console.log(scrollElement.offsetTop - (scrollTop + scrollHeight), scrollDelta, curSite.SiteTypeID) if (scrollElement.offsetTop - (scrollTop + scrollHeight) <= scrollDelta) { - if (curSite.SiteTypeID === 21) curSite.pager.scrollDelta -= 800 // 游民星空的比较奇葩,需要特殊处理下 + if (curSite.SiteTypeID === 25) curSite.pager.scrollDelta -= 800 // 游民星空的比较奇葩,需要特殊处理下 ShowPager.loadMorePage(); } } else { From b21094221cf39bffeeba3b275ff213d35cff4f49 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Mon, 2 Aug 2021 13:09:45 +0800 Subject: [PATCH 0015/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=97=A0=E7=BC=9D=E7=BF=BB=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3dm-Enhanced.user.js | 56 ++++++++++++++++++++++++++++++++-------- 52pojie-Enhanced.user.js | 56 ++++++++++++++++++++++++---------------- Hostloc-Enhanced.user.js | 28 ++++++-------------- 3 files changed, 87 insertions(+), 53 deletions(-) diff --git a/3dm-Enhanced.user.js b/3dm-Enhanced.user.js index 740199387..da01b7253 100644 --- a/3dm-Enhanced.user.js +++ b/3dm-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 3DM论坛增强 -// @version 1.0.9 +// @version 1.1.0 // @author X.I.U // @description 自动回复、自动无缝翻页、清理置顶帖子、自动滚动至隐藏内容 // @match *://bbs.3dmgame.com/* @@ -105,19 +105,37 @@ thread: { SiteTypeID: 2, pager: { - nextLink: '//div[@id="pgt"]//a[contains(text(),"下一页")][@href]', + nextLink: '//a[@class="nxt"][@href]', pageElement: 'css;div#postlist > div[id^="post_"]', HT_insert: ['css;div#postlist', 2], - replaceE: '//div[@class="pg"] | //div[@class="pgbtn"]', + replaceE: 'css;div.pg' } }, - guide: { + search: { SiteTypeID: 3, pager: { - nextLink: '//div[@id="pgt"]//a[contains(text(),"下一页")][@href]', - pageElement: 'css;div#threadlist div.bm_c table > tbody[id^="normalthread_"]', + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;div#threadlist > ul', + HT_insert: ['css;div#threadlist', 2], + replaceE: 'css;div.pg' + } + }, + guide: { + SiteTypeID: 4, + pager: { + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;div#threadlist div.bm_c table > tbody', HT_insert: ['css;div#threadlist div.bm_c table', 2], - replaceE: 'css;div.pg', + replaceE: 'css;div.pg' + } + }, + youspace: { + SiteTypeID: 5, + pager: { + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;tbody > tr:not(.th)', + HT_insert: ['css;tbody', 2], + replaceE: 'css;div.pg' } } }; @@ -134,22 +152,30 @@ // URL 匹配正则表达式 let patt_thread = /\/thread-\d+-\d+\-\d+.html/, - patt_forum = /\/forum-\d+-\d+\.html/, - patt_guide = /mod\=guide\&view\=(hot|digest)/ + patt_forum = /\/forum-\d+-\d+\.html/ // URL 判断 if (patt_thread.test(location.pathname) || location.search.indexOf('mod=viewthread') > -1){ // 帖子内 + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 if(menu_value('menu_thread_pageLoading'))curSite = DBSite.thread; if(menu_value('menu_autoReply'))autoReply(); // 如果有隐藏内容,则自动回复 if(menu_value('menu_scrollToShowhide'))setTimeout(function(){window.scrollTo(0,document.querySelector('.showhide').offsetTop)}, 500); // 滚动至隐藏内容 - }else if (patt_forum.test(location.pathname) || location.search.indexOf('mod=forumdisplay') > -1){ + } else if (patt_forum.test(location.pathname) || location.search.indexOf('mod=forumdisplay') > -1){ // 各板块帖子列表 curSite = DBSite.forum; if(menu_value('menu_cleanTopPost'))cleanTopPost(); // 清理置顶帖子 - }else if (patt_guide.test(location.search)){ + } else if (location.search.indexOf('mod=guide') > -1){ // 导读帖子列表 curSite = DBSite.guide; + } else if (location.pathname === '/search.php') { + // 搜索结果列表 + curSite = DBSite.search; + } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { + // 别人的主题/回复 + curSite = DBSite.youspace; + } else { + curSite = DBSite.forum; } pageLoading(); // 自动翻页 @@ -237,6 +263,14 @@ } + // 隐藏帖子内的 [下一页] 按钮 + function hidePgbtn() { + let style_hidePgbtn = document.createElement('style'); + style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`; + document.head.appendChild(style_hidePgbtn); + } + + // 滚动条事件 function windowScroll(fn1) { var beforeScrollTop = document.documentElement.scrollTop, diff --git a/52pojie-Enhanced.user.js b/52pojie-Enhanced.user.js index 59336a6f4..e4d7c4195 100644 --- a/52pojie-Enhanced.user.js +++ b/52pojie-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 吾爱破解论坛增强 - 自动签到、翻页 -// @version 1.3.0 +// @version 1.3.1 // @author X.I.U // @description 自动签到、自动无缝翻页、屏蔽导读悬赏贴(最新发表页) // @match *://www.52pojie.cn/* @@ -90,63 +90,73 @@ SiteTypeID: 2, pager: { type: 1, - nextLink: '//div[@id="pgt"]//a[contains(text(),"下一页")][@href]', + nextLink: '//a[@class="nxt"][@href]', pageElement: 'css;div#postlist > div[id^="post_"]', HT_insert: ['css;div#postlist', 2], replaceE: 'css;div.pg', scrollDelta: 766 } }, - guide: { + search: { SiteTypeID: 3, pager: { type: 1, - nextLink: '//div[@id="pgt"]//a[contains(text(),"下一页")][@href]', - pageElement: 'css;div#threadlist div.bm_c table > tbody[id^="normalthread_"]', - HT_insert: ['css;div#threadlist div.bm_c table', 2], + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;div#threadlist > ul', + HT_insert: ['css;div#threadlist', 2], replaceE: 'css;div.pg', scrollDelta: 766 } }, - collection: { + guide: { SiteTypeID: 4, pager: { type: 1, - nextLink: '//div[@class="pg"]//a[contains(text(),"下一页")][@href]', - pageElement: 'css;div#ct div.bm_c table > tbody', - HT_insert: ['css;div#ct div.bm_c table', 2], + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;div#threadlist div.bm_c table > tbody', + HT_insert: ['css;div#threadlist div.bm_c table', 2], replaceE: 'css;div.pg', - scrollDelta: 899 + scrollDelta: 766 } }, - favorite: { + youspace: { SiteTypeID: 5, pager: { type: 1, nextLink: '//a[@class="nxt"][@href]', - pageElement: 'css;ul#favorite_ul > li', - HT_insert: ['css;ul#favorite_ul', 2], + pageElement: 'css;tbody > tr:not(.th)', + HT_insert: ['css;tbody', 2], replaceE: 'css;div.pg', - scrollDelta: 899 + scrollDelta: 1000 } }, - search: { + collection: { SiteTypeID: 6, pager: { type: 1, nextLink: '//a[@class="nxt"][@href]', - pageElement: 'css;div#threadlist > ul', - HT_insert: ['css;div#threadlist', 2], + pageElement: 'css;div#ct div.bm_c table > tbody', + HT_insert: ['css;div#ct div.bm_c table', 2], replaceE: 'css;div.pg', - scrollDelta: 766 + scrollDelta: 899 + } + }, + favorite: { + SiteTypeID: 7, + pager: { + type: 1, + nextLink: '//a[@class="nxt"][@href]', + pageElement: 'css;ul#favorite_ul > li', + HT_insert: ['css;ul#favorite_ul', 2], + replaceE: 'css;div.pg', + scrollDelta: 899 } } }; // URL 匹配正则表达式 let patt_thread = /\/thread-\d+-\d+\-\d+.html/, - patt_forum = /\/forum-\d+-\d+\.html/, - patt_guide = /mod\=guide\&view\=(hot|digest|new|newthread|my|tech|help)/ + patt_forum = /\/forum-\d+-\d+\.html/ // URL 判断 if (patt_thread.test(location.pathname) || location.search.indexOf('mod=viewthread') > -1) { @@ -156,7 +166,7 @@ } } else if (patt_forum.test(location.pathname) || location.search.indexOf('mod=forumdisplay') > -1) { curSite = DBSite.forum; // 各板块帖子列表 - } else if (patt_guide.test(location.search)) { + } else if (location.search.indexOf('mod=guide') > -1) { curSite = DBSite.guide; // 导读帖子列表 delateReward(); // 屏蔽导读悬赏贴(最新发表) } else if (location.search.indexOf('mod=collection') > -1) { @@ -165,6 +175,8 @@ curSite = DBSite.favorite; // 收藏列表 } else if (location.pathname === '/search.php') { curSite = DBSite.search; // 搜索结果列表 + } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复 + curSite = DBSite.youspace; } curSite.pageUrl = ""; // 下一页URL diff --git a/Hostloc-Enhanced.user.js b/Hostloc-Enhanced.user.js index bed296967..9142e75a0 100644 --- a/Hostloc-Enhanced.user.js +++ b/Hostloc-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 全球主机交流论坛增强 -// @version 1.3.2 +// @version 1.3.3 // @author X.I.U // @description 自动签到(访问空间)、屏蔽用户(黑名单)、屏蔽关键词(帖子标题)、回帖小尾巴、自动无缝翻页、快捷回到顶部(右键点击两侧空白处)、收起预览帖子(左键点击两侧空白处)、预览帖子快速回复带签名、显示是否在线、显示帖子内隐藏回复、屏蔽阅读权限 255 帖子 // @match *://hostloc.com/* @@ -113,17 +113,8 @@ replaceE: 'css;div.pg', } }, - guide: { - SiteTypeID: 3, - pager: { - nextLink: '//a[@class="nxt"][@href]', - pageElement: 'css;div#threadlist div.bm_c table > tbody[id^="normalthread_"]', - HT_insert: ['css;div#threadlist div.bm_c table', 2], - replaceE: 'css;div.pg', - } - }, search: { - SiteTypeID: 4, + SiteTypeID: 3, pager: { nextLink: '//a[@class="nxt"][@href]', pageElement: 'css;div#threadlist > ul', @@ -131,10 +122,10 @@ replaceE: 'css;div.pg' } }, - myreply: { + guide: { SiteTypeID: 4, pager: { - nextLink: '(//a[@class="nxt"])[1][@href]', + nextLink: '//a[@class="nxt"][@href]', pageElement: 'css;div#threadlist div.bm_c table > tbody', HT_insert: ['css;div#threadlist div.bm_c table', 2], replaceE: 'css;div.pg', @@ -144,7 +135,7 @@ SiteTypeID: 5, pager: { nextLink: '//a[@class="nxt"][@href]', - pageElement: 'css;tbody > tr', + pageElement: 'css;tbody > tr:not(.th)', HT_insert: ['css;tbody', 2], replaceE: 'css;div.pg', } @@ -161,8 +152,7 @@ // URL 匹配正则表达式 let patt_thread = /\/thread-\d+-\d+\-\d+.html/, - patt_forum = /\/forum-\d+-\d+\.html/, - patt_guide = /mod\=guide\&view\=(hot|digest)/ + patt_forum = /\/forum-\d+-\d+\.html/ // URL 判断 if (patt_thread.test(location.pathname) || location.search.indexOf('mod=viewthread') > -1) { // 帖子内 @@ -183,7 +173,7 @@ vfastpostDOMNodeInserted(); // 监听插入事件(预览快速回复带签名) littleTail('forum'); // 小尾巴 if (patt_forum.test(location.pathname)) blockDOMNodeInserted(); //监听插入事件(有新的回复主题,点击查看) - }else if (patt_guide.test(location.search)) { // 导读帖子列表 + }else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表 curSite = DBSite.guide; } else if(location.pathname === '/search.php') { // 搜索结果列表 curSite = DBSite.search; @@ -192,9 +182,7 @@ blockUsers('notice'); // 屏蔽用户(黑名单) } else if(location.pathname === '/home.php' && location.search.indexOf('mod=space&do=pm') > -1) { // 消息(私人聊天) blockUsers('pm'); // 屏蔽用户(黑名单) - } else if(location.pathname === '/forum.php' && location.search.indexOf('mod=guide&view=my&type=reply') > -1) { // 我的帖子:回复 - curSite = DBSite.myreply; - } else if(location.pathname === '/home.php' && location.search.indexOf('&do=thread&view=me') > -1) { // 别人的帖子:回复 + } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复 curSite = DBSite.youreply; } else if(location.pathname === '/forum.php' && location.search.indexOf('mod=post&action=reply') > -1 || location.pathname === '/forum.php' && location.search.indexOf('mod=post&action=newthread') > -1) { // 回复:高级回复 littleTail('reply'); // 小尾巴 From 5f0e59d7c432221246f5baf9e2f987417817d381 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Mon, 2 Aug 2021 15:18:49 +0800 Subject: [PATCH 0016/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=A3=80=E6=9F=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hostloc-Enhanced.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Hostloc-Enhanced.user.js b/Hostloc-Enhanced.user.js index 9142e75a0..12fa36a3d 100644 --- a/Hostloc-Enhanced.user.js +++ b/Hostloc-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 全球主机交流论坛增强 -// @version 1.3.3 +// @version 1.3.4 // @author X.I.U // @description 自动签到(访问空间)、屏蔽用户(黑名单)、屏蔽关键词(帖子标题)、回帖小尾巴、自动无缝翻页、快捷回到顶部(右键点击两侧空白处)、收起预览帖子(左键点击两侧空白处)、预览帖子快速回复带签名、显示是否在线、显示帖子内隐藏回复、屏蔽阅读权限 255 帖子 // @match *://hostloc.com/* @@ -710,7 +710,7 @@ // 通过 Cookie 来判断是否登录 function getLoginStatus() { let cookie = document.cookie.split(';'); - for (let i=0; i div") - document.querySelector(".container-masonry").style.height = "auto" + let pageElems1 = document.querySelectorAll('.container-masonry > div') + document.querySelector('.container-masonry').style.height = 'auto' pageElems1.forEach(function (one) { - one.setAttribute("style","float: left"); + one.setAttribute('style','float: left'); }); } @@ -692,23 +692,23 @@ // art_alphacoders 的插入前函数 function art_alphacoders_beforeFunction(pageElems) { pageElems.forEach(function (one) { - one.setAttribute("style","float: left"); + one.setAttribute('style','float: left'); }); return pageElems } - // iplaysoft 的插入前函数 + // 58pic 的插入前函数 function _58pic_beforeFunction(pageElems) { - let is_one = document.querySelector(".qtw-card.place-box.is-one"); - if (is_one && is_one.style.display != "none") { - is_one.setAttribute("style", "display: none;") + let is_one = document.querySelector('.qtw-card.place-box.is-one'); + if (is_one && is_one.style.display != 'none') { + is_one.setAttribute('style', 'display: none;') } pageElems.forEach(function (one) { - let now = one.querySelector("img.lazy") - if (now && now.getAttribute('src') === "//icon.qiantucdn.com/static/images/qtw-card/card-place.png") { - now.setAttribute("src", now.dataset.original) - now.setAttribute("style", "display: block;") + let now = one.querySelector('img.lazy') + if (now && now.getAttribute('src') != now.dataset.original) { + now.setAttribute('src', now.dataset.original) + now.setAttribute('style', 'display: block;') } }); return pageElems From aca302fce56e93d6861f3738a55f0b7cbb5cebe9 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Tue, 3 Aug 2021 18:07:42 +0800 Subject: [PATCH 0018/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E6=89=80?= =?UTF-8?q?=E6=9C=89=20Flarum=20=E8=AE=BA=E5=9D=9B]=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 142 ++++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 70 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 7fb8f45ff..2c58c7944 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.3.7 +// @version 1.3.8 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有 Discuz!论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... // @match *://*/* // @exclude *://www.423down.com/*.html // @exclude *://apphot.cc/*.html @@ -33,7 +33,6 @@ 'rarbgprx.org', 'fitgirl-repacks.site', 'www.yxssp.com', - 'pan.yuankongjian.com', 'weibo.com', 'www.afreecatv.com']; @@ -43,7 +42,10 @@ GM_registerMenuCommand('❎ 已禁用 (点击对当前网站启用)', function(){menu_disable('del')}); return } else { - if (websiteList.indexOf(location.host) > -1 || document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]')) { + if (websiteList.indexOf(location.host) > -1 // 其他网站列表 + || document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]') // 所有 Discuz! 论坛 + || document.getElementById('flarum-loading') // 所有 Flarum 论坛 + ) { GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')}); } else { 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});}); @@ -137,8 +139,16 @@ scrollDelta: 1000 } }, - _423down_postslist: { + flarum: { SiteTypeID: 7, + pager: { + type: 2, + nextLink: '.DiscussionList-loadMore > button[title]', + scrollDelta: 1000 + } + }, + _423down_postslist: { + SiteTypeID: 8, pager: { type: 1, nextLink: '//div[@class="paging"]//a[contains(text(),"下一页")][@href]', @@ -149,7 +159,7 @@ } }, apphot_postslist: { - SiteTypeID: 8, + SiteTypeID: 9, pager: { type: 1, nextLink: '//div[@class="pagination"]//a[contains(text(),"下一页")][@href]', @@ -160,7 +170,7 @@ } }, iao_su_postslist: { - SiteTypeID: 9, + SiteTypeID: 10, pager: { type: 1, nextLink: '//li[@class="btn btn-primary next"]//a[@href]', @@ -174,7 +184,7 @@ } }, appinn_postslist: { - SiteTypeID: 10, + SiteTypeID: 11, pager: { type: 1, nextLink: '//a[@class="next page-numbers"][@href]', @@ -185,7 +195,7 @@ } }, iplaysoft_postslist: { - SiteTypeID: 11, + SiteTypeID: 12, pager: { type: 1, nextLink: '//div[@class="pagenavi"]//a[@title="下一页"][@href]', @@ -199,7 +209,7 @@ } }, iplaysoft_postcomments: { - SiteTypeID: 12, + SiteTypeID: 13, pager: { type: 2, nextLink: '#loadHistoryComments', @@ -208,7 +218,7 @@ } }, pubmed_postslist: { - SiteTypeID: 13, + SiteTypeID: 14, pager: { type: 2, nextLink: 'button.load-button.next-page', @@ -217,7 +227,7 @@ } }, wall_alphacoders: { - SiteTypeID: 14, + SiteTypeID: 15, pager: { type: 1, nextLink: '//a[@id="next_page"][@href]', @@ -228,7 +238,7 @@ } }, art_alphacoders: { - SiteTypeID: 15, + SiteTypeID: 16, pager: { type: 1, nextLink: '//a[@id="next_page"][@href]', @@ -242,7 +252,7 @@ } }, fitgirl: { - SiteTypeID: 16, + SiteTypeID: 17, pager: { type: 1, nextLink: '//a[@class="next page-numbers"][@href]', @@ -253,7 +263,7 @@ } }, weidown: { - SiteTypeID: 17, + SiteTypeID: 18, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -264,7 +274,7 @@ } }, weidown_search: { - SiteTypeID: 18, + SiteTypeID: 19, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -275,7 +285,7 @@ } }, weidown_special: { - SiteTypeID: 19, + SiteTypeID: 20, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -286,7 +296,7 @@ } }, douban_subject_comments: { - SiteTypeID: 20, + SiteTypeID: 21, pager: { type: 1, nextLink: '//a[@class="next"][@href]', @@ -297,7 +307,7 @@ } }, douban_subject_reviews: { - SiteTypeID: 21, + SiteTypeID: 22, pager: { type: 1, nextLink: '//link[@rel="next"][@href]', @@ -308,7 +318,7 @@ } }, douban_subject_episode: { - SiteTypeID: 22, + SiteTypeID: 23, pager: { type: 1, nextLink: '//link[@rel="next"][@href]', @@ -319,7 +329,7 @@ } }, douban_search: { - SiteTypeID: 23, + SiteTypeID: 24, pager: { type: 1, nextLink: '//a[@class="next"][@href]', @@ -330,7 +340,7 @@ } }, _3dmgame: { - SiteTypeID: 24, + SiteTypeID: 25, pager: { type: 3, nextLink: '//li[@class="next"]/a[@href]', @@ -342,7 +352,7 @@ } }, gamersky_ent: { - SiteTypeID: 25, + SiteTypeID: 26, pager: { type: 3, nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]', @@ -354,7 +364,7 @@ } }, gamersky_gl: { - SiteTypeID: 26, + SiteTypeID: 27, pager: { type: 3, nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]', @@ -366,7 +376,7 @@ } }, ali213_www: { - SiteTypeID: 27, + SiteTypeID: 28, pager: { type: 3, nextLink: '//a[@id="after_this_page"][@href]', @@ -378,7 +388,7 @@ } }, ali213_gl: { - SiteTypeID: 28, + SiteTypeID: 29, pager: { type: 3, nextLink: '//a[@class="next n"][@href]', @@ -390,7 +400,7 @@ } }, _58pic: { - SiteTypeID: 29, + SiteTypeID: 30, pager: { type: 1, nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]', @@ -404,7 +414,7 @@ } }, _58pic_c: { - SiteTypeID: 30, + SiteTypeID: 31, pager: { type: 1, nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]', @@ -418,7 +428,7 @@ } }, rarbgprx: { - SiteTypeID: 31, + SiteTypeID: 32, pager: { type: 1, nextLink: '(//a[@title="next page"])[1][@href]', @@ -429,7 +439,7 @@ } }, yxssp: { - SiteTypeID: 32, + SiteTypeID: 33, pager: { type: 1, nextLink: '//div[@class="page-nav td-pb-padding-side"]/a[last()][@href]', @@ -439,15 +449,6 @@ scrollDelta: 900 } }, - yuankongjian: { - SiteTypeID: 33, - pager: { - type: 2, - nextLink: 'button[title="加载更多"]', - nextText: '加载更多', - scrollDelta: 500 - } - }, weibo_comment: { SiteTypeID: 34, pager: { @@ -556,44 +557,45 @@ case "rarbgprx.org": curSite = DBSite.rarbgprx; break; - case "pan.yuankongjian.com": - if (location.pathname.indexOf('/d/') === -1) { - curSite = DBSite.yuankongjian; - } - break; case "weibo.com": curSite = DBSite.weibo_comment; break; case "www.afreecatv.com": curSite = DBSite.afreecatv; break; - default: // < Discuz! 论坛专用 > - if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) - if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表 - curSite = DBSite.discuz_forum; - } else if (location.pathname.indexOf('thread') > -1) { // 帖子内 - curSite = DBSite.discuz_thread; - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 - }else if(location.pathname.indexOf('search') > -1) { // 搜索结果 - curSite = DBSite.discuz_search; - } - } else { - if (location.search.indexOf('mod=forumdisplay') > -1) { // 各版块帖子列表 - curSite = DBSite.discuz_forum; - } else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内 - curSite = DBSite.discuz_thread; - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 - } else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表 - curSite = DBSite.discuz_guide; - } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复 - curSite = DBSite.discuz_youspace; - } else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表 - curSite = DBSite.discuz_collection; - } else if (location.pathname.indexOf('search') > -1) { // 搜索结果 - curSite = DBSite.discuz_search; - } else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的 - curSite = DBSite.discuz_forum; + default: + if (document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]')) { + // < 所有 Discuz!论坛 > + if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) + if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表 + curSite = DBSite.discuz_forum; + } else if (location.pathname.indexOf('thread') > -1) { // 帖子内 + curSite = DBSite.discuz_thread; + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + }else if(location.pathname.indexOf('search') > -1) { // 搜索结果 + curSite = DBSite.discuz_search; + } + } else { + if (location.search.indexOf('mod=forumdisplay') > -1) { // 各版块帖子列表 + curSite = DBSite.discuz_forum; + } else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内 + curSite = DBSite.discuz_thread; + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + } else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表 + curSite = DBSite.discuz_guide; + } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复 + curSite = DBSite.discuz_youspace; + } else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表 + curSite = DBSite.discuz_collection; + } else if (location.pathname.indexOf('search') > -1) { // 搜索结果 + curSite = DBSite.discuz_search; + } else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的 + curSite = DBSite.discuz_forum; + } } + } else if (document.getElementById('flarum-loading') && location.pathname.indexOf('/d/') === -1) { + // < 所有 Flarum 论坛 > + curSite = DBSite.flarum; } } curSite.pageUrl = ""; // 下一页URL From 5a23e3b79ea06a8fbc659073a10fc45d0a121c3e Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Tue, 3 Aug 2021 18:14:04 +0800 Subject: [PATCH 0019/2043] README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f5a93892..e36c35d8c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ | [](https://www.zhihu.com/people/xiu2) | **知乎 增强** | **移除登录弹窗**、一键收起回答、屏蔽用户、屏蔽关键词、快... | **[安装](https://greasyfork.org/zh-CN/scripts/419081)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhihu-Enhanced.user.js)** | | [](https://www.v2ex.com/) | **V2ex 增强** | **自动签到**、链接转图片、自动无缝翻页、新标签页打开链接... | **[安装](https://greasyfork.org/zh-CN/scripts/424246)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/V2ex-Enhanced.user.js)** | | [](https://github.com/XIU2) | **Github 增强** | **高速下载** Git Clone/SSH、Release、Raw、Code(ZIP) 文件... | **[安装](https://greasyfork.org/zh-CN/scripts/412245)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/GithubEnhanced-High-Speed-Download.user.js)** | -| [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz!论坛**、423Down、不死鸟、小众软件、异次... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | +| [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz! / Flarum 论坛**、423Down、不死鸟、小众软... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/413593)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Beautification.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 增强** | **自动回复**、自动无缝翻页、清理置顶帖子、自动滚动至隐藏... | **[安装](https://greasyfork.org/zh-CN/scripts/412890)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Enhanced.user.js)** | | [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | **智友邦论坛 美化** | 精简多余内容、样式优化、宽屏显示 | **[安装](https://greasyfork.org/zh-CN/scripts/412361)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)** | From 7855049c57a80ee124a38acee1ebb937d054f5e7 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Tue, 3 Aug 2021 22:55:42 +0800 Subject: [PATCH 0020/2043] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20[=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E5=85=B3=E9=97=AD=E6=82=AC=E6=B5=AE=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=EF=BC=88=E7=82=B9=E5=87=BB=E4=B8=A4=E4=BE=A7=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E5=A4=84=EF=BC=89]=20=E5=8A=9F=E8=83=BD=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zhihu-Enhanced.user.js | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js index 4c527aea7..b4fb219a2 100644 --- a/Zhihu-Enhanced.user.js +++ b/Zhihu-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 知乎增强 -// @version 1.5.1 +// @version 1.5.2 // @author X.I.U // @description 移除登录弹窗、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题/评论)、屏蔽盐选内容、展开问题描述、置顶显示时间、显示问题时间、区分问题文章、默认高清原图、默认站外直链 // @match *://www.zhihu.com/* @@ -109,27 +109,25 @@ function collapsedNowAnswer(selectors) { if (!menu_value('menu_collapsedNowAnswer')) return document.querySelector(selectors).onclick = function(event){ if (event.target==this) { + // 下面这段主要是 [收起回答],顺便 [收起评论](如果展开了的话) let rightButton = document.querySelector('.ContentItem-actions.Sticky.RichContent-actions.is-fixed.is-bottom') - if (rightButton) { // 悬浮的 [收起回答](此时正在浏览回答内容 [头部区域 + 中间区域]) + // 悬浮在底部的 [收起回答](此时正在浏览回答内容 [头部区域 + 中间区域]) + if (rightButton) { // 固定的 [收起评论](先看看是否展开评论) let commentCollapseButton = rightButton.querySelector('button.Button.ContentItem-action.Button--plain.Button--withIcon.Button--withLabel:first-of-type') - if (commentCollapseButton && commentCollapseButton.innerText.indexOf('收起评论') > -1) { - commentCollapseButton.click(); - } + if (commentCollapseButton && commentCollapseButton.textContent.indexOf('收起评论') > -1) commentCollapseButton.click(); // 再去收起回答 rightButton = rightButton.querySelector('.ContentItem-rightButton') - if (rightButton && rightButton.hasAttribute('data-zop-retract-question')) { - rightButton.click(); - } - } else { // 固定的 [收起回答](此时正在浏览回答内容 [尾部区域]) - for (let el of document.querySelectorAll('.ContentItem-rightButton')) { + if (rightButton && rightButton.hasAttribute('data-zop-retract-question')) rightButton.click(); + // 固定在回答底部的 [收起回答](此时正在浏览回答内容 [尾部区域]) + } else { + for (let el of document.querySelectorAll('.ContentItem-rightButton')) { // 遍历所有回答底部的 [收起] 按钮 if (el.hasAttribute('data-zop-retract-question')) { - if (isElementInViewport(el)) { - // 固定的 [收起评论](先看看是否展开评论) + if (isElementInViewport(el)) { // 判断该 [收起] 按钮是否在可视区域内 + // 固定的 [收起评论](先看看是否展开评论,即存在 [收起评论] 按钮) let commentCollapseButton = el.parentNode.querySelector('button.Button.ContentItem-action.Button--plain.Button--withIcon.Button--withLabel:first-of-type') - if (commentCollapseButton && commentCollapseButton.innerText.indexOf('收起评论') > -1) { - commentCollapseButton.click(); // 如果展开了评论,就收起评论 - } + // 如果展开了评论,就收起评论 + if (commentCollapseButton && commentCollapseButton.textContent.indexOf('收起评论') > -1) commentCollapseButton.click(); el.click() // 再去收起回答 break } @@ -137,6 +135,7 @@ function collapsedNowAnswer(selectors) { } } + // 下面这段只针对 [收起评论](如果展开了的话) var commentCollapseButton_ = false, commentCollapseButton__ = false; // 悬浮的 [收起评论](此时正在浏览评论内容 [中间区域]) let commentCollapseButton = document.querySelector('.CommentCollapseButton') @@ -146,7 +145,7 @@ function collapsedNowAnswer(selectors) { let commentCollapseButton_1 = document.querySelectorAll('.ContentItem-actions > button.Button.ContentItem-action.Button--plain.Button--withIcon.Button--withLabel:first-of-type, .ContentItem-action > button.Button.Button--plain.Button--withIcon.Button--withLabel:first-of-type') if (commentCollapseButton_1.length > 0) { for (let el of commentCollapseButton_1) { - if (el.innerText.indexOf('收起评论') > -1) { + if (el.textContent.indexOf('收起评论') > -1) { if (isElementInViewport(el)) { el.click() commentCollapseButton_ = true // 如果找到并点击了,就没必要执行下面的代码了(可视区域中没有 [收起评论] 时) @@ -161,7 +160,7 @@ function collapsedNowAnswer(selectors) { for (let el of commentCollapseButton_1) { if (isElementInViewport(el)) { let commentCollapseButton = el.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('.ContentItem-actions > button.Button.ContentItem-action.Button--plain.Button--withIcon.Button--withLabel:first-of-type') - if (commentCollapseButton.innerText.indexOf('收起评论') > -1) { + if (commentCollapseButton.textContent.indexOf('收起评论') > -1) { commentCollapseButton.click() commentCollapseButton__ = true // 如果找到并点击了,就没必要执行下面的代码了(可视区域中没有 评论元素 时) break @@ -176,7 +175,7 @@ function collapsedNowAnswer(selectors) { if (isElementInViewport(el)) { let commentCollapseButton = el.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('.ContentItem-actions > button.Button.ContentItem-action.Button--plain.Button--withIcon.Button--withLabel:first-of-type') console.log(commentCollapseButton) - if (commentCollapseButton.innerText.indexOf('收起评论') > -1) { + if (commentCollapseButton.textContent.indexOf('收起评论') > -1) { commentCollapseButton.click() break } @@ -836,6 +835,28 @@ function removeLogin() { } +// 快捷关闭悬浮评论(监听点击事件,点击网页两侧空白处) +function closeFloatingComments() { + const closeFloatingCommentsModal = (mutationsList, observer) => { + for (const mutation of mutationsList) { + for (const target of mutation.addedNodes) { + if (target.nodeType != 1) return + if (target.querySelector('.Modal-backdrop')) { + document.querySelector('.Modal-backdrop').onclick = function(event){ + if (event.target == this) { + let button = document.getElementsByClassName('Button Modal-closeButton Button--plain')[0]; + if (button) button.click(); + } + } + } + } + } + }; + const observer = new MutationObserver(closeFloatingCommentsModal); + observer.observe(document, { childList: true, subtree: true }); +} + + // 监听 XMLHttpRequest 事件 function EventXMLHttpRequest() { var _send = window.XMLHttpRequest.prototype.send @@ -847,7 +868,6 @@ function EventXMLHttpRequest() { } - // [完整显示时间 + 置顶显示时间] 功能修改自:https://greasyfork.org/scripts/402808(从 JQuery 改为原生 JavaScript,且优化了代码) // 完整显示时间 + 置顶显示时间 - 首页 function topTime_index() { @@ -1109,6 +1129,7 @@ function addLocationchange() { (function() { removeLogin(); // 移除登录弹窗 + closeFloatingComments(); // 快捷关闭悬浮评论(监听点击事件,点击网页两侧空白处) questionInvitation(); // 默认折叠邀请 setInterval(originalPic,100); // 默认高清原图 if (menu_value('menu_directLink')) setInterval(directLink, 100); // 默认站外直链 From d3ca358cf514e9b1e7291214c71245dcb8b8a739 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Wed, 4 Aug 2021 10:02:57 +0800 Subject: [PATCH 0021/2043] README.md --- Hostloc-Enhanced.user.js | 23 ++++++++--------------- README.md | 2 +- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Hostloc-Enhanced.user.js b/Hostloc-Enhanced.user.js index 12fa36a3d..8718798a0 100644 --- a/Hostloc-Enhanced.user.js +++ b/Hostloc-Enhanced.user.js @@ -2,7 +2,7 @@ // @name 全球主机交流论坛增强 // @version 1.3.4 // @author X.I.U -// @description 自动签到(访问空间)、屏蔽用户(黑名单)、屏蔽关键词(帖子标题)、回帖小尾巴、自动无缝翻页、快捷回到顶部(右键点击两侧空白处)、收起预览帖子(左键点击两侧空白处)、预览帖子快速回复带签名、显示是否在线、显示帖子内隐藏回复、屏蔽阅读权限 255 帖子 +// @description 自动签到(访问空间 +22 积分)、屏蔽用户(黑名单)、屏蔽关键词(帖子标题)、回帖小尾巴、自动无缝翻页、快捷回到顶部(右键点击两侧空白处)、收起预览帖子(左键点击两侧空白处)、预览帖子快速回复带签名、显示是否在线、显示帖子内隐藏回复、屏蔽阅读权限 255 帖子 // @match *://hostloc.com/* // @match *://91ai.net/* // @icon https://www.hostloc.com/favicon.ico @@ -23,7 +23,7 @@ (function() { 'use strict'; var menu_ALL = [ - ['menu_autoSignIn', '自动签到', '自动签到', true], + ['menu_autoSignIn', '自动签到(22 积分)', '自动签到', true], ['menu_reAutoSignIn', '重新签到', '重新签到', ''], ['menu_blockUsers', '屏蔽用户', '屏蔽用户', false], ['menu_customBlockUsers', '自定义屏蔽用户', '自定义屏蔽用户', []], @@ -195,10 +195,9 @@ //replyIntervalDOMNodeInserted(); // 监听插入事件(回帖间隔) - // 自动签到(访问空间 10 次 = 20 积分) + // 自动签到(访问空间 10 次 = 20 积分 + 当天首次访问论坛 2 积分) function autoSignIn() { if (!loginStatus) return - //if (GM_getValue('menu_signingIn')) return let timeNow = new Date().getFullYear() + "/" + (new Date().getMonth() + 1) + "/" + new Date().getDate(), timeOld = GM_getValue('menu_signInTime'); if (!timeOld || timeOld != timeNow) { // 是新的一天 @@ -208,33 +207,27 @@ url = 0; // 随机生成 12 个空间地址(2 个冗余) for(let i = 0;i < 12;i++){url_list[i] = "https://" + location.host + "/space-uid-" + Math.floor(Math.random()*(50000-10000+1)+10000) + ".html";} - // 每 5 秒访问一次(避免触发网站防御机制) - //GM_setValue('menu_signingIn', true); + // 每 5 秒访问一次(避免触发网站防御机制,而且还可以适当浏览论坛) let signIn = setInterval(function(){ GM_xmlhttpRequest({ url: url_list[url++], method: "GET", timeout: 4000 }); - console.log(`[全球主机交流论坛 增强] 金钱 +2 (${url_list[url]})`); + console.log(`[全球主机交流论坛 增强] 积分 +2 (${url_list[url]})`); if (url === 11) { // 次数够了就取消定时循环 clearInterval(signIn); - //GM_setValue('menu_signingIn', false); - //GM_setValue('menu_signInTime', timeNow); // 写入签到时间以供后续比较 console.log('[全球主机交流论坛 增强] 签到完成!'); - GM_notification({text: '签到完成!金钱 +20 ~', timeout: 3500}); + GM_notification({text: '签到完成!积分 +22 ~', timeout: 3500}); } }, 5000); - }/* else { // 新旧签到时间一致 - console.info('[全球主机交流论坛 增强] 已经签过到了。') - }*/ + } } // 重新签到 function reAutoSignIn() { - //GM_setValue('menu_signingIn', false); - GM_setValue('menu_signInTime', '1970/1/1'); + GM_setValue('menu_signInTime', '1970/1/1'); // 设置为比当前日期更早 location.reload(); // 刷新网页 } diff --git a/README.md b/README.md index e36c35d8c..70ab653f7 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ | [](https://github.com/XIU2) | **新标签页打开链接 \*** | 将网页中所有链接改为新标签页打开~ | **[安装](https://greasyfork.org/zh-CN/scripts/429714)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/TargetBlank.user.js)** | | [](https://www.52pojie.cn) | **吾爱破解论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/412681)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/52pojie-Beautification.user.js)** | | [](https://www.52pojie.cn) | **吾爱破解论坛 增强** | **自动签到**、自动无缝翻页、屏蔽导读悬赏贴 (最新发表页)... | **[安装](https://greasyfork.org/zh-CN/scripts/412680)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/52pojie-Enhanced.user.js)** | -| [](https://hostloc.com) | **全球主机交流论坛 增强 \*** | **自动访问空间、屏蔽用户**、屏蔽关键词、自动无缝翻页等... | **[安装](https://greasyfork.org/zh-CN/scripts/414005)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Hostloc-Enhanced.user.js)** | +| [](https://hostloc.com) | **全球主机交流论坛 增强 \*** | **自动访问空间(22积分)、屏蔽用户**、屏蔽关键词、自动无缝翻... | **[安装](https://greasyfork.org/zh-CN/scripts/414005)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Hostloc-Enhanced.user.js)** | | [](https://store.steampowered.com) | **Steam 创意工坊大图 修复** | 修复 Steam 创意工坊预览大图无法显示的问题 | **[安装](https://github.com/XIU2/UserScript/raw/master/SteamWorkshopImageRepair.user.js)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/SteamWorkshopImageRepair.user.js)** | > _脚本名称末尾 **`*`** 代表该脚本为**网友主动提出需求**而写的。如果你也有需求,可以[告诉我](https://github.com/XIU2/UserScript/issues/new/choose)!_ From c03e723e14090eea20a74e17c36af2820eb799d2 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Wed, 4 Aug 2021 16:46:23 +0800 Subject: [PATCH 0022/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Discuz!=20?= =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E6=A3=80=E6=B5=8B=E4=BB=A3=E7=A0=81=EF=BC=88?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E6=B2=A1=E6=9C=89=E9=81=97=E6=BC=8F=E4=BA=86?= =?UTF-8?q?=EF=BC=89;=20=E4=BC=98=E5=8C=96=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 280 ++++++++++++++++++++++++----------------------- 1 file changed, 142 insertions(+), 138 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 2c58c7944..4cb533be6 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,11 +1,9 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.3.8 +// @version 1.3.9 // @author X.I.U // @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... // @match *://*/* -// @exclude *://www.423down.com/*.html -// @exclude *://apphot.cc/*.html // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png // @grant GM_xmlhttpRequest @@ -34,7 +32,7 @@ 'fitgirl-repacks.site', 'www.yxssp.com', 'weibo.com', - 'www.afreecatv.com']; + 'www.afreecatv.com'], webType, curSite = {SiteTypeID: 0}; if (GM_getValue('menu_disable') == null){GM_setValue('menu_disable', [])}; // 注册脚本菜单 @@ -42,21 +40,20 @@ GM_registerMenuCommand('❎ 已禁用 (点击对当前网站启用)', function(){menu_disable('del')}); return } else { - if (websiteList.indexOf(location.host) > -1 // 其他网站列表 - || document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]') // 所有 Discuz! 论坛 - || document.getElementById('flarum-loading') // 所有 Flarum 论坛 - ) { - GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')}); + if (websiteList.indexOf(location.host) > -1) { + webType = 1 // 其他网站 + } else if (document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]') || document.getElementById('ft') && document.getElementById('ft').textContent.indexOf('Discuz!') > -1) { + webType = 2 // 所有 Discuz! 论坛 + } else if (document.getElementById('flarum-loading')) { + webType = 3 // 所有 Flarum 论坛 } else { 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});}); return } + GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')}); } 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});}); - // 默认 ID 为 0 - var curSite = {SiteTypeID: 0}; - /* 自动翻页规则 type: @@ -74,7 +71,7 @@ after = 插入后执行函数; parameter = 参数 */ - let DBSite = { + const DBSite = { discuz_forum: { SiteTypeID: 1, pager: { @@ -470,135 +467,142 @@ }; - switch (location.host) { - case "www.423down.com": - curSite = DBSite._423down_postslist; - break; - case "apphot.cc": - curSite = DBSite.apphot_postslist; - break; - case "iao.su": - curSite = DBSite.iao_su_postslist; - break; - case "www.appinn.com": - curSite = DBSite.appinn_postslist; - break; - case "www.iplaysoft.com": - if (location.pathname.indexOf(".html") > -1 || location.pathname.indexOf("/p/") > -1) { // 文章内 - curSite = DBSite.iplaysoft_postcomments; - } else { // 其他页面 - curSite = DBSite.iplaysoft_postslist; - } - break; - case "www.weidown.com": - if (location.pathname.indexOf("/search/") > -1) { - curSite = DBSite.weidown_search; - } else if (location.pathname.indexOf("/special/") > -1) { - curSite = DBSite.weidown_special; - } else { - curSite = DBSite.weidown; - } - break; - case "www.yxssp.com": - curSite = DBSite.yxssp; - break; - case "fitgirl-repacks.site": - curSite = DBSite.fitgirl; - break; - case "art.alphacoders.com": - curSite = DBSite.art_alphacoders; - setTimeout(art_alphacoders_beforeFunction_0, 1000); - break; - case "wall.alphacoders.com": - case "avatars.alphacoders.com": - case "mobile.alphacoders.com": - curSite = DBSite.wall_alphacoders; - break; - case "pubmed.ncbi.nlm.nih.gov": - curSite = DBSite.pubmed_postslist; - break; - case "movie.douban.com": - if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评 - curSite = DBSite.douban_subject_comments; - } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评 - curSite = DBSite.douban_subject_reviews; - }else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论 - curSite = DBSite.douban_subject_episode; - } - break; - case "search.douban.com": - curSite = DBSite.douban_search; - break; - case "www.3dmgame.com": - curSite = DBSite._3dmgame; - break; - case "www.gamersky.com": - if (location.pathname.indexOf("/ent/") > -1) { - curSite = DBSite.gamersky_ent; - } else { - curSite = DBSite.gamersky_gl; - } - //document.lastElementChild.appendChild(document.createElement('style')).textContent = `.Comment {display: none !important;}` // 隐藏评论区 - break; - case "www.ali213.net": - curSite = DBSite.ali213_www; - break; - case "gl.ali213.net": - curSite = DBSite.ali213_gl; - document.lastElementChild.appendChild(document.createElement('style')).textContent = `.n_show_b {display: none !important;}` // 隐藏部分碍事元素 - break; - case "www.58pic.com": - if (location.pathname.indexOf("/tupian/") > -1) { - curSite = DBSite._58pic; - } else if (location.pathname.indexOf("/c/") > -1) { - curSite = DBSite._58pic_c; - } - break; - case "rarbgprx.org": - curSite = DBSite.rarbgprx; - break; - case "weibo.com": - curSite = DBSite.weibo_comment; - break; - case "www.afreecatv.com": - curSite = DBSite.afreecatv; - break; - default: - if (document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]')) { - // < 所有 Discuz!论坛 > - if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) - if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表 - curSite = DBSite.discuz_forum; - } else if (location.pathname.indexOf('thread') > -1) { // 帖子内 - curSite = DBSite.discuz_thread; - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 - }else if(location.pathname.indexOf('search') > -1) { // 搜索结果 - curSite = DBSite.discuz_search; - } + if (webType === 1) { // < 其他网站 > + switch (location.host) { + case 'www.423down.com': + if (location.pathname.indexOf('.html') === -1) curSite = DBSite._423down_postslist; + break; + case 'apphot.cc': + if (location.pathname.indexOf('.html') === -1) curSite = DBSite.apphot_postslist; + break; + case 'iao.su': + curSite = DBSite.iao_su_postslist; + break; + case 'www.appinn.com': + curSite = DBSite.appinn_postslist; + break; + case 'www.iplaysoft.com': + if (location.pathname.indexOf('.html') > -1 || location.pathname.indexOf('/p/') > -1) { // 文章内 + curSite = DBSite.iplaysoft_postcomments; + } else { // 其他页面 + curSite = DBSite.iplaysoft_postslist; + } + break; + case 'www.weidown.com': + if (location.pathname.indexOf('/search/') > -1) { + curSite = DBSite.weidown_search; + } else if (location.pathname.indexOf('/special/') > -1) { + curSite = DBSite.weidown_special; } else { - if (location.search.indexOf('mod=forumdisplay') > -1) { // 各版块帖子列表 - curSite = DBSite.discuz_forum; - } else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内 - curSite = DBSite.discuz_thread; - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 - } else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表 - curSite = DBSite.discuz_guide; - } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复 - curSite = DBSite.discuz_youspace; - } else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表 - curSite = DBSite.discuz_collection; - } else if (location.pathname.indexOf('search') > -1) { // 搜索结果 - curSite = DBSite.discuz_search; - } else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的 - curSite = DBSite.discuz_forum; - } + curSite = DBSite.weidown; + } + break; + case 'www.yxssp.com': + curSite = DBSite.yxssp; + break; + case 'fitgirl-repacks.site': + curSite = DBSite.fitgirl; + break; + case 'art.alphacoders.com': + curSite = DBSite.art_alphacoders; + setTimeout(art_alphacoders_beforeFunction_0, 1000); + break; + case 'wall.alphacoders.com': + case 'avatars.alphacoders.com': + case 'mobile.alphacoders.com': + curSite = DBSite.wall_alphacoders; + break; + case 'pubmed.ncbi.nlm.nih.gov': + curSite = DBSite.pubmed_postslist; + break; + case 'movie.douban.com': + if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评 + curSite = DBSite.douban_subject_comments; + } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评 + curSite = DBSite.douban_subject_reviews; + } else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论 + curSite = DBSite.douban_subject_episode; } - } else if (document.getElementById('flarum-loading') && location.pathname.indexOf('/d/') === -1) { - // < 所有 Flarum 论坛 > - curSite = DBSite.flarum; + break; + case 'search.douban.com': + curSite = DBSite.douban_search; + break; + case 'www.3dmgame.com': + curSite = DBSite._3dmgame; + break; + case 'www.gamersky.com': + if (location.pathname.indexOf('/ent/') > -1) { + curSite = DBSite.gamersky_ent; + } else { + curSite = DBSite.gamersky_gl; + } + break; + case 'www.ali213.net': + curSite = DBSite.ali213_www; + break; + case 'gl.ali213.net': + curSite = DBSite.ali213_gl; + document.lastElementChild.appendChild(document.createElement('style')).textContent = `.n_show_b {display: none !important;}` // 隐藏部分碍事元素 + break; + case 'www.58pic.com': + if (location.pathname.indexOf('/tupian/') > -1) { + curSite = DBSite._58pic; + } else if (location.pathname.indexOf('/c/') > -1) { + curSite = DBSite._58pic_c; + } + break; + case 'rarbgprx.org': + curSite = DBSite.rarbgprx; + break; + case 'weibo.com': + curSite = DBSite.weibo_comment; + break; + case 'www.afreecatv.com': + curSite = DBSite.afreecatv; + break; + } + } else if (webType === 2) { // < 所有 Discuz!论坛 > + if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) + if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表 + if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮 + curSite = DBSite.discuz_forum; + } else { + curSite = DBSite.discuz_guide; + } + } else if (location.pathname.indexOf('thread') > -1) { // 帖子内 + curSite = DBSite.discuz_thread; + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + }else if(location.pathname.indexOf('search') > -1) { // 搜索结果 + curSite = DBSite.discuz_search; } + } else { + if (location.search.indexOf('mod=forumdisplay') > -1) { // 各版块帖子列表 + if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮 + curSite = DBSite.discuz_forum; + } else { + curSite = DBSite.discuz_guide; + } + } else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内 + curSite = DBSite.discuz_thread; + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + } else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表 + curSite = DBSite.discuz_guide; + } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复 + curSite = DBSite.discuz_youspace; + } else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表 + curSite = DBSite.discuz_collection; + } else if (location.pathname.indexOf('search') > -1) { // 搜索结果 + curSite = DBSite.discuz_search; + } else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的 + curSite = DBSite.discuz_forum; + } + } + } else if (webType === 3) { // < 所有 Flarum 论坛 > + curSite = DBSite.flarum; } - curSite.pageUrl = ""; // 下一页URL + + + curSite.pageUrl = ''; // 下一页URL pageLoading(); // 自动无缝翻页 From b5360a08735f95f7500e329a3d3a49ad22cb4620 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Thu, 5 Aug 2021 00:33:28 +0800 Subject: [PATCH 0023/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E5=B8=96?= =?UTF-8?q?=E5=AD=90=E5=86=85=E8=87=AA=E5=8A=A8=E7=BF=BB=E9=A1=B5]=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E8=8F=9C=E5=8D=95=20(=E4=BB=85=20Discuz!=20?= =?UTF-8?q?=E8=AE=BA=E5=9D=9B);=20=E4=BF=AE=E5=A4=8D=20[AfreecaTV]=20?= =?UTF-8?q?=E7=BF=BB=E9=A1=B5=E5=A4=AA=E5=A4=9A=E5=AF=BC=E8=87=B4=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=B2=A1=E6=9C=89=E5=8A=A0=E8=BD=BD=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98;=20=E4=BC=98=E5=8C=96=20[=E6=B8=B8=E6=B0=91=E6=98=9F?= =?UTF-8?q?=E7=A9=BA]=20=E7=BF=BB=E9=A1=B5=E8=A7=84=E5=88=99=EF=BC=88?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=8B=E4=B8=80=E9=A1=B5=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E7=9A=84=20=E6=9B=B4=E5=A4=9A=E7=9B=B8=E5=85=B3=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E8=AF=B7=E5=85=B3=E6=B3=A8=EF=BC=9Axxx=20=E6=96=87?= =?UTF-8?q?=E5=AD=97=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 105 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 30 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 4cb533be6..2db617db3 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.3.9 +// @version 1.4.0 // @author X.I.U // @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... // @match *://*/* @@ -20,21 +20,22 @@ (function() { 'use strict'; + var webType, curSite = {SiteTypeID: 0}; // 目前支持的网站 - var websiteList = ['www.423down.com', 'apphot.cc', 'iao.su', 'www.appinn.com', 'www.iplaysoft.com', 'www.weidown.com', + const websiteList = ['www.423down.com', 'apphot.cc', 'iao.su', 'www.appinn.com', 'www.iplaysoft.com', 'www.weidown.com', 'art.alphacoders.com', 'wall.alphacoders.com', 'avatars.alphacoders.com', 'mobile.alphacoders.com', 'pubmed.ncbi.nlm.nih.gov', - 'movie.douban.com', - 'search.douban.com', + 'movie.douban.com', 'search.douban.com', 'www.3dmgame.com', 'www.gamersky.com', 'www.ali213.net', 'gl.ali213.net', 'www.58pic.com', 'rarbgprx.org', 'fitgirl-repacks.site', 'www.yxssp.com', 'weibo.com', - 'www.afreecatv.com'], webType, curSite = {SiteTypeID: 0}; + 'www.afreecatv.com']; if (GM_getValue('menu_disable') == null){GM_setValue('menu_disable', [])}; + if (GM_getValue('menu_discuz_thread_page') == null){GM_setValue('menu_discuz_thread_page', true)}; // 注册脚本菜单 if (menu_disable('check')) { // 当前网站是否已存在禁用列表中 GM_registerMenuCommand('❎ 已禁用 (点击对当前网站启用)', function(){menu_disable('del')}); @@ -51,21 +52,27 @@ return } GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')}); + if (webType === 2) { + GM_registerMenuCommand(`${GM_getValue('menu_discuz_thread_page')?'✅':'❎'} 帖子内自动翻页 (仅 Discuz! 论坛)`, function(){menu_switch(GM_getValue('menu_discuz_thread_page'), 'menu_discuz_thread_page', 'Discuz! 论坛帖子内翻页')}); + } } 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});}); + /* 自动翻页规则 type: 1 = 脚本实现自动无缝翻页 - 2 = 网站自带了自动无缝翻页功能,只需要点击下一页按钮即可,这时 nextText 为按钮文本,避免一瞬间加载太多次下一页 + 2 = 网站自带了自动无缝翻页功能,只需要点击下一页按钮即可 + nextText: 按钮文本,只有按钮文本为该文本时才会点击按钮加载下一页,避免一瞬间加载太多次下一页 + intervals: 点击间隔时间,对于没有按钮文字变化的按钮,可以手动指定间隔时间,单位:ms 3 = 依靠元素距离可视区域底部的距离来触发翻页 HT_insert: 1 = 插入该元素本身的前面; 2 = 插入该元素当中,第一个子元素前面; 3 = 插入该元素当中,最后一个子元素后面; 4 = 插入该元素本身的后面; - scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页),一般是访问网页速度越慢,该值就需要越大 + scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页),一般是访问网页速度越慢,该值就需要越大(如果 Type = 3,则相反) function: before = 插入前执行函数; after = 插入后执行函数; @@ -370,6 +377,9 @@ replaceE: 'css;.page_css', scrollElement: '.pagecss', scrollDelta: -1000 + }, + function: { + before: gamersky_gl_beforeFunction } }, ali213_www: { @@ -443,7 +453,7 @@ pageElement: 'css;.td-modules-container.td-module-number4 > div', HT_insert: ['css;.td-modules-container.td-module-number4', 3], replaceE: 'css;.page-nav.td-pb-padding-side', - scrollDelta: 900 + scrollDelta: 1000 } }, weibo_comment: { @@ -460,7 +470,7 @@ pager: { type: 2, nextLink: '.btn-more > button', - nextText: '查看更多', + intervals: 2000, scrollDelta: 1000 } } @@ -570,8 +580,10 @@ curSite = DBSite.discuz_guide; } } else if (location.pathname.indexOf('thread') > -1) { // 帖子内 - curSite = DBSite.discuz_thread; - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + if (GM_getValue('menu_discuz_thread_page')) { + curSite = DBSite.discuz_thread; + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + } }else if(location.pathname.indexOf('search') > -1) { // 搜索结果 curSite = DBSite.discuz_search; } @@ -583,8 +595,10 @@ curSite = DBSite.discuz_guide; } } else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内 - curSite = DBSite.discuz_thread; - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + if (GM_getValue('menu_discuz_thread_page')) { + curSite = DBSite.discuz_thread; + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + } } else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表 curSite = DBSite.discuz_guide; } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复 @@ -618,21 +632,29 @@ let scrollElement = document.querySelector(curSite.pager.scrollElement); //console.log(scrollElement.offsetTop - (scrollTop + scrollHeight), scrollDelta, curSite.SiteTypeID) if (scrollElement.offsetTop - (scrollTop + scrollHeight) <= scrollDelta) { - if (curSite.SiteTypeID === 25) curSite.pager.scrollDelta -= 800 // 游民星空的比较奇葩,需要特殊处理下 + if (curSite.SiteTypeID === 27) curSite.pager.scrollDelta -= 800 // 游民星空 gl 的比较奇葩,需要特殊处理下 ShowPager.loadMorePage(); } } else { if (document.documentElement.scrollHeight <= scrollHeight + scrollTop + scrollDelta) { if (curSite.pager.type === 2) { // 翻页类型 2 - let autopbn = document.querySelector(curSite.pager.nextLink); - if (autopbn) { // 如果正在加载,就不再点击 - if (!curSite.pager.nextText) { // 如果没有指定 nextText 就直接点击 - autopbn.click(); - } else if (autopbn.innerText.indexOf(curSite.pager.nextText) > -1){ // 如果指定了 nextText 就需要判断后再点击(避免已经在加载了,还重复点击) - autopbn.click(); + if (curSite.SiteTypeID > 0) { // 如果指定了间隔时间,那么就依靠这个判断时间到了没有~ + let autopbn = document.querySelector(curSite.pager.nextLink); + if (autopbn) { // 寻找下一页链接 + if (!curSite.pager.nextText) { // 如果没有指定 nextText 就直接点击 + autopbn.click(); + } else if (autopbn.textContent.indexOf(curSite.pager.nextText) > -1){ // 如果指定了 nextText 就需要判断后再点击(避免已经在加载了,还重复点击) + autopbn.click(); + } + // 对于没有按钮文字变化的按钮,可以手动指定间隔时间 + if (curSite.pager.intervals) { + let _SiteTypeID = curSite.SiteTypeID; + curSite.SiteTypeID = 0; + setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals) + } } } - } else { + } else { // 翻页类型 1 ShowPager.loadMorePage(); } } @@ -643,15 +665,15 @@ } - function getElementToPageTop(el) { + /*function getElementToPageTop(el) { if(el.parentElement) { return getElementToPageTop(el.parentElement) + el.offsetTop } return el.offsetTop - } + }*/ - // 隐藏帖子内的 [下一页] 按钮 + // 隐藏帖子内的 [下一页] 按钮(Discuz! 论坛) function hidePgbtn() { let style_hidePgbtn = document.createElement('style'); style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`; @@ -659,7 +681,7 @@ } - // iplaysoft 的插入前函数 + // iplaysoft 的插入前函数(加载图片) function iplaysoft_postslist_beforeFunction(pageElems) { pageElems.forEach(function (one) { let now = one.querySelector('img.lazyload') @@ -673,19 +695,20 @@ } - // iao.su 的插入前函数 + // iao.su 的插入前函数(加载图片) function iao_su_postslist_beforeFunction(pageElems) { pageElems.forEach(function (one) { let now = one.getElementsByClassName('post-card')[0] if (now) { - now.getElementsByClassName('blog-background')[0].style.backgroundImage = 'url("' + RegExp("(?<=loadBannerDirect\\(').*(?=', '',)").exec(now.getElementsByTagName("script")[0].innerText)[0]; + '")'; + now.getElementsByClassName('blog-background')[0].style.backgroundImage = 'url("' + now.getElementsByTagName('script')[0].textContent.split("'")[1] + '")'; + //now.getElementsByClassName('blog-background')[0].style.backgroundImage = 'url("' + RegExp("(?<=loadBannerDirect\\(').*(?=', '',)").exec(now.getElementsByTagName('script')[0].textContent)[0]; + '")'; } }); return pageElems } - // art_alphacoders + // art_alphacoders(图片结构调整) function art_alphacoders_beforeFunction_0() { let pageElems1 = document.querySelectorAll('.container-masonry > div') document.querySelector('.container-masonry').style.height = 'auto' @@ -695,7 +718,7 @@ } - // art_alphacoders 的插入前函数 + // art_alphacoders 的插入前函数(图片结构调整) function art_alphacoders_beforeFunction(pageElems) { pageElems.forEach(function (one) { one.setAttribute('style','float: left'); @@ -704,7 +727,7 @@ } - // 58pic 的插入前函数 + // 58pic 的插入前函数(加载图片) function _58pic_beforeFunction(pageElems) { let is_one = document.querySelector('.qtw-card.place-box.is-one'); if (is_one && is_one.style.display != 'none') { @@ -721,6 +744,17 @@ } + // 游民星空攻略 的插入前函数(移除下一页底部的 "更多相关内容请关注:xxx" 文字) + function gamersky_gl_beforeFunction(pageElems) { + pageElems.forEach(function (one) { + if (one.tagName === 'P' && one.textContent.indexOf('更多相关内容请关注') > -1) { + one.style.display = 'none'; + } + }); + return pageElems + } + + // 启用/禁用 (当前网站) function menu_disable(type) { switch(type) { @@ -761,6 +795,17 @@ } + // 菜单开关 + function menu_switch(menu_status, Name, Tips) { + if (menu_status === true){ + GM_setValue(`${Name}`, false); + }else{ + GM_setValue(`${Name}`, true); + } + location.reload(); + }; + + // 滚动条事件 function windowScroll(fn1) { var beforeScrollTop = document.documentElement.scrollTop, From eccd27cf704021b26faf711a0b4aa722fca1adb1 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Thu, 5 Aug 2021 11:19:51 +0800 Subject: [PATCH 0024/2043] README.md --- Autopage.user.js | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 2db617db3..71bda08dc 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -2,7 +2,7 @@ // @name 自动无缝翻页 // @version 1.4.0 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、423Down、Apphot、不死鸟、小众软件、异次元软件、微当下载、异星软件空间、豆瓣电影、微博评论、3DM游戏网、游侠网、游民星空、千图网、阿里小站、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、Apphot、不死鸟、小众软件、微当下载、异次元软件、异星软件空间、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... // @match *://*/* // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png diff --git a/README.md b/README.md index 70ab653f7..a9cd7c2b3 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ | [](https://www.zhihu.com/people/xiu2) | **知乎 增强** | **移除登录弹窗**、一键收起回答、屏蔽用户、屏蔽关键词、快... | **[安装](https://greasyfork.org/zh-CN/scripts/419081)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhihu-Enhanced.user.js)** | | [](https://www.v2ex.com/) | **V2ex 增强** | **自动签到**、链接转图片、自动无缝翻页、新标签页打开链接... | **[安装](https://greasyfork.org/zh-CN/scripts/424246)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/V2ex-Enhanced.user.js)** | | [](https://github.com/XIU2) | **Github 增强** | **高速下载** Git Clone/SSH、Release、Raw、Code(ZIP) 文件... | **[安装](https://greasyfork.org/zh-CN/scripts/412245)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/GithubEnhanced-High-Speed-Download.user.js)** | -| [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz! / Flarum 论坛**、423Down、不死鸟、小众软... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | +| [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz! / Flarum 论坛**、豆瓣、微博、千图网、423Do... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/413593)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Beautification.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 增强** | **自动回复**、自动无缝翻页、清理置顶帖子、自动滚动至隐藏... | **[安装](https://greasyfork.org/zh-CN/scripts/412890)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Enhanced.user.js)** | | [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | **智友邦论坛 美化** | 精简多余内容、样式优化、宽屏显示 | **[安装](https://greasyfork.org/zh-CN/scripts/412361)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)** | From 76e8f97941c435ffc7268aaccb844e3c4dfc3233 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Thu, 5 Aug 2021 16:58:34 +0800 Subject: [PATCH 0025/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E8=90=BD?= =?UTF-8?q?=E5=B0=98=E4=B9=8B=E6=9C=A8=E3=80=81=E8=80=81=E6=AE=81=E6=AE=81?= =?UTF-8?q?=E6=BC=82=E9=81=A5]=20=E6=94=AF=E6=8C=81;=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 710 +++++++++++++++++++++++++---------------------- 1 file changed, 383 insertions(+), 327 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 71bda08dc..8557e4d29 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.4.0 +// @version 1.4.1 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、Apphot、不死鸟、小众软件、微当下载、异次元软件、异星软件空间、RARBG、FitGirl Repacks、AlphaCoders、PubMed、AfreecaTV... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、Apphot、不死鸟、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... // @match *://*/* // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png @@ -22,17 +22,14 @@ 'use strict'; var webType, curSite = {SiteTypeID: 0}; // 目前支持的网站 - const websiteList = ['www.423down.com', 'apphot.cc', 'iao.su', 'www.appinn.com', 'www.iplaysoft.com', 'www.weidown.com', - 'art.alphacoders.com', 'wall.alphacoders.com', 'avatars.alphacoders.com', 'mobile.alphacoders.com', - 'pubmed.ncbi.nlm.nih.gov', - 'movie.douban.com', 'search.douban.com', - 'www.3dmgame.com', 'www.gamersky.com', 'www.ali213.net', 'gl.ali213.net', - 'www.58pic.com', - 'rarbgprx.org', - 'fitgirl-repacks.site', - 'www.yxssp.com', - 'weibo.com', - 'www.afreecatv.com']; + const websiteList = ['movie.douban.com', 'weibo.com', 'www.58pic.com', + 'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', + 'www.423down.com', 'apphot.cc', 'iao.su', 'www.appinn.com', 'www.weidown.com', 'www.luochenzhimu.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com', + 'rarbgprx.org', + 'pubmed.ncbi.nlm.nih.gov', + 'www.afreecatv.com', + 'art.alphacoders.com', 'wall.alphacoders.com', 'avatars.alphacoders.com', 'mobile.alphacoders.com', + 'fitgirl-repacks.site']; if (GM_getValue('menu_disable') == null){GM_setValue('menu_disable', [])}; if (GM_getValue('menu_discuz_thread_page') == null){GM_setValue('menu_discuz_thread_page', true)}; @@ -78,9 +75,9 @@ after = 插入后执行函数; parameter = 参数 */ - const DBSite = { + let DBSite = { discuz_forum: { - SiteTypeID: 1, + SiteTypeID: 0, pager: { type: 2, nextLink: '#autopbn', @@ -89,7 +86,7 @@ } }, discuz_thread: { - SiteTypeID: 2, + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="nxt"][@href]', @@ -100,7 +97,7 @@ } }, discuz_search: { - SiteTypeID: 3, + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="nxt"][@href]', @@ -111,7 +108,7 @@ } }, discuz_guide: { - SiteTypeID: 4, + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="nxt"][@href]', @@ -122,7 +119,7 @@ } }, discuz_youspace: { - SiteTypeID: 5, + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="nxt"][@href]', @@ -133,7 +130,7 @@ } }, discuz_collection: { - SiteTypeID: 6, + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="nxt"][@href]', @@ -144,130 +141,195 @@ } }, flarum: { - SiteTypeID: 7, + SiteTypeID: 0, pager: { type: 2, nextLink: '.DiscussionList-loadMore > button[title]', scrollDelta: 1000 } }, - _423down_postslist: { - SiteTypeID: 8, + douban_subject_comments: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//div[@class="paging"]//a[contains(text(),"下一页")][@href]', - pageElement: 'css;div.content-wrap ul.excerpt > li', - HT_insert: ['css;div.content-wrap ul.excerpt', 3], - replaceE: 'css;div.paging', - scrollDelta: 1500 + nextLink: '//a[@class="next"][@href]', + pageElement: 'css;#comments > .comment-item', + HT_insert: ['css;#paginator', 1], + replaceE: 'css;#paginator', + scrollDelta: 1000 } }, - apphot_postslist: { - SiteTypeID: 9, + douban_subject_reviews: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//div[@class="pagination"]//a[contains(text(),"下一页")][@href]', - pageElement: 'css;div.content > article.excerpt', - HT_insert: ['css;div.pagination', 1], - replaceE: 'css;div.pagination', - scrollDelta: 1500 + nextLink: '//link[@rel="next"][@href]', + pageElement: 'css;.review-list > div', + HT_insert: ['css;.review-list', 3], + replaceE: 'css;.paginator', + scrollDelta: 1000 } }, - iao_su_postslist: { - SiteTypeID: 10, + douban_subject_episode: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//li[@class="btn btn-primary next"]//a[@href]', - pageElement: 'css;#index > article, #archive > article', - HT_insert: ['css;ol.page-navigator', 1], - replaceE: 'css;ol.page-navigator', - scrollDelta: 800 - }, - function: { - before: iao_su_postslist_beforeFunction + nextLink: '//link[@rel="next"][@href]', + pageElement: 'css;#comments > div', + HT_insert: ['css;#comments', 3], + replaceE: 'css;.paginator', + scrollDelta: 1000 } }, - appinn_postslist: { - SiteTypeID: 11, + weibo_comment: { + SiteTypeID: 0, + pager: { + type: 2, + nextLink: 'a[action-type="click_more_comment"]', + nextText: '查看更多c', + scrollDelta: 1000 + } + }, + _58pic: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//a[@class="next page-numbers"][@href]', - pageElement: 'css;section#latest-posts > article', - HT_insert: ['css;nav.navigation.pagination', 1], - replaceE: 'css;div.nav-links', - scrollDelta: 1500 + nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]', + pageElement: 'css;.pic-box > .qtw-card', + HT_insert: ['css;.pic-box', 3], + replaceE: 'css;.page-box', + scrollDelta: 2000 + }, + function: { + before: _58pic_beforeFunction } }, - iplaysoft_postslist: { - SiteTypeID: 12, + _58pic_c: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//div[@class="pagenavi"]//a[@title="下一页"][@href]', - pageElement: 'css;#postlist > div.entry', - HT_insert: ['css;#postlist > .pagenavi-button', 1], - replaceE: 'css;.pagenavi-button, .pagenavi', - scrollDelta: 1200 + nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]', + pageElement: 'css;.list-box > .qtw-card', + HT_insert: ['css;.list-box', 3], + replaceE: 'css;.page-box', + scrollDelta: 4000 }, function: { - before: iplaysoft_postslist_beforeFunction + before: _58pic_beforeFunction } }, - iplaysoft_postcomments: { - SiteTypeID: 13, + _3dmgame: { + SiteTypeID: 0, pager: { - type: 2, - nextLink: '#loadHistoryComments', - nextText: '展开后面', - scrollDelta: 1200 + type: 3, + nextLink: '//li[@class="next"]/a[@href]', + pageElement: 'css;.news_warp_center > *', + HT_insert: ['css;.news_warp_center', 3], + replaceE: 'css;.pagewrap', + scrollElement: '.pagewrap', + scrollDelta: 400 } }, - pubmed_postslist: { - SiteTypeID: 14, + ali213_www: { + SiteTypeID: 0, pager: { - type: 2, - nextLink: 'button.load-button.next-page', - nextText: 'Show more', + type: 3, + nextLink: '//a[@id="after_this_page"][@href]', + pageElement: 'css;#Content >*:not(.news_ding):not(.page_fenye)', + HT_insert: ['css;.page_fenye', 1], + replaceE: 'css;.page_fenye', + scrollElement: '.page_fenye', + scrollDelta: 400 + } + }, + ali213_gl: { + SiteTypeID: 0, + pager: { + type: 3, + nextLink: '//a[@class="next n"][@href]', + pageElement: 'css;.c-detail >*', + HT_insert: ['css;.c-detail', 3], + replaceE: 'css;.page_fenye', + scrollElement: '.page_fenye', + scrollDelta: 400 + } + }, + gamersky_ent: { + SiteTypeID: 0, + pager: { + type: 3, + nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]', + pageElement: 'css;.Mid2L_con > *:not(.gs_nc_editor):not(.pagecss):not(.page_css):not(.gs_ccs_solve):not(.post_ding)', + HT_insert: ['css;.page_css', 1], + replaceE: 'css;.page_css', + scrollElement: '.page_css', + scrollDelta: 100 + } + }, + gamersky_gl: { + SiteTypeID: 0, + pager: { + type: 3, + nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]', + pageElement: 'css;.Mid2L_con > *:not(.gs_nc_editor):not(.pagecss):not(.gs_ccs_solve):not(.post_ding)', + HT_insert: ['css;.gs_nc_editor', 1], + replaceE: 'css;.page_css', + scrollElement: '.pagecss', + scrollDelta: -1000 + }, + function: { + before: gamersky_gl_beforeFunction + } + }, + _423down_postslist: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//div[@class="paging"]//a[contains(text(),"下一页")][@href]', + pageElement: 'css;div.content-wrap ul.excerpt > li', + HT_insert: ['css;div.content-wrap ul.excerpt', 3], + replaceE: 'css;div.paging', scrollDelta: 1500 } }, - wall_alphacoders: { - SiteTypeID: 15, + apphot_postslist: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//a[@id="next_page"][@href]', - pageElement: 'css;.thumb-container-big, .avatar-thumb, .thumb-element', - HT_insert: ['css;.thumb-container-big:nth-last-child(1), .avatar-thumb:nth-last-child(1), .thumb-element:nth-last-child(1)', 4], - replaceE: '//div[@class="hidden-xs hidden-sm"]/..', - scrollDelta: 1000 + nextLink: '//div[@class="pagination"]//a[contains(text(),"下一页")][@href]', + pageElement: 'css;div.content > article.excerpt', + HT_insert: ['css;div.pagination', 1], + replaceE: 'css;div.pagination', + scrollDelta: 1500 } }, - art_alphacoders: { - SiteTypeID: 16, + iao_su_postslist: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//a[@id="next_page"][@href]', - pageElement: 'css;.container-masonry > div', - HT_insert: ['css;.container-masonry', 3], - replaceE: '//div[@class="hidden-xs hidden-sm"]/..', - scrollDelta: 1000 + nextLink: '//li[@class="btn btn-primary next"]//a[@href]', + pageElement: 'css;#index > article, #archive > article', + HT_insert: ['css;ol.page-navigator', 1], + replaceE: 'css;ol.page-navigator', + scrollDelta: 800 }, function: { - before: art_alphacoders_beforeFunction + before: iao_su_postslist_beforeFunction } }, - fitgirl: { - SiteTypeID: 17, + appinn_postslist: { + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="next page-numbers"][@href]', - pageElement: 'css;article[id^="post-"]', - HT_insert: ['css;nav.navigation.paging-navigation', 1], - replaceE: 'css;nav.navigation.paging-navigation', - scrollDelta: 2000 + pageElement: 'css;section#latest-posts > article', + HT_insert: ['css;nav.navigation.pagination', 1], + replaceE: 'css;div.nav-links', + scrollDelta: 1500 } }, weidown: { - SiteTypeID: 18, + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -278,7 +340,7 @@ } }, weidown_search: { - SiteTypeID: 19, + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -289,7 +351,7 @@ } }, weidown_special: { - SiteTypeID: 20, + SiteTypeID: 0, pager: { type: 1, nextLink: '//a[@class="nextpage"][@href]', @@ -299,154 +361,67 @@ scrollDelta: 700 } }, - douban_subject_comments: { - SiteTypeID: 21, - pager: { - type: 1, - nextLink: '//a[@class="next"][@href]', - pageElement: 'css;#comments > .comment-item', - HT_insert: ['css;#paginator', 1], - replaceE: 'css;#paginator', - scrollDelta: 700 - } - }, - douban_subject_reviews: { - SiteTypeID: 22, - pager: { - type: 1, - nextLink: '//link[@rel="next"][@href]', - pageElement: 'css;.review-list > div', - HT_insert: ['css;.review-list', 3], - replaceE: 'css;.paginator', - scrollDelta: 700 - } - }, - douban_subject_episode: { - SiteTypeID: 23, - pager: { - type: 1, - nextLink: '//link[@rel="next"][@href]', - pageElement: 'css;#comments > div', - HT_insert: ['css;#comments', 3], - replaceE: 'css;.paginator', - scrollDelta: 700 - } - }, - douban_search: { - SiteTypeID: 24, - pager: { - type: 1, - nextLink: '//a[@class="next"][@href]', - pageElement: 'css;#root [class^="_"] [class^="sc-"]', - HT_insert: ['css;.paginator', 1], - replaceE: 'css;.paginator', - scrollDelta: 700 - } - }, - _3dmgame: { - SiteTypeID: 25, - pager: { - type: 3, - nextLink: '//li[@class="next"]/a[@href]', - pageElement: 'css;.news_warp_center > *', - HT_insert: ['css;.news_warp_center', 3], - replaceE: 'css;.pagewrap', - scrollElement: '.pagewrap', - scrollDelta: 400 - } - }, - gamersky_ent: { - SiteTypeID: 26, - pager: { - type: 3, - nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]', - pageElement: 'css;.Mid2L_con > *:not(.gs_nc_editor):not(.pagecss):not(.page_css):not(.gs_ccs_solve):not(.post_ding)', - HT_insert: ['css;.page_css', 1], - replaceE: 'css;.page_css', - scrollElement: '.page_css', - scrollDelta: 100 - } - }, - gamersky_gl: { - SiteTypeID: 27, - pager: { - type: 3, - nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]', - pageElement: 'css;.Mid2L_con > *:not(.gs_nc_editor):not(.pagecss):not(.gs_ccs_solve):not(.post_ding)', - HT_insert: ['css;.gs_nc_editor', 1], - replaceE: 'css;.page_css', - scrollElement: '.pagecss', - scrollDelta: -1000 - }, - function: { - before: gamersky_gl_beforeFunction - } - }, - ali213_www: { - SiteTypeID: 28, - pager: { - type: 3, - nextLink: '//a[@id="after_this_page"][@href]', - pageElement: 'css;#Content >*:not(.news_ding):not(.page_fenye)', - HT_insert: ['css;.page_fenye', 1], - replaceE: 'css;.page_fenye', - scrollElement: '.page_fenye', - scrollDelta: 400 - } - }, - ali213_gl: { - SiteTypeID: 29, - pager: { - type: 3, - nextLink: '//a[@class="next n"][@href]', - pageElement: 'css;.c-detail >*', - HT_insert: ['css;.c-detail', 3], - replaceE: 'css;.page_fenye', - scrollElement: '.page_fenye', - scrollDelta: 400 - } - }, - _58pic: { - SiteTypeID: 30, + luochenzhimu: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]', - pageElement: 'css;.pic-box > .qtw-card', - HT_insert: ['css;.pic-box', 3], - replaceE: 'css;.page-box', - scrollDelta: 2000 + nextLink: '//li[@class="next-page"]/a[@href]', + pageElement: 'css;.content > article', + HT_insert: ['css;.content > .pagination', 1], + replaceE: 'css;.content > .pagination', + scrollDelta: 1000 }, function: { - before: _58pic_beforeFunction + before: luochenzhimu_beforeFunction } }, - _58pic_c: { - SiteTypeID: 31, + iplaysoft_postslist: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]', - pageElement: 'css;.list-box > .qtw-card', - HT_insert: ['css;.list-box', 3], - replaceE: 'css;.page-box', - scrollDelta: 4000 + nextLink: '//div[@class="pagenavi"]//a[@title="下一页"][@href]', + pageElement: 'css;#postlist > div.entry', + HT_insert: ['css;#postlist > .pagenavi-button', 1], + replaceE: 'css;.pagenavi-button, .pagenavi', + scrollDelta: 1200 }, function: { - before: _58pic_beforeFunction + before: iplaysoft_postslist_beforeFunction } }, - rarbgprx: { - SiteTypeID: 32, + iplaysoft_postcomments: { + SiteTypeID: 0, + pager: { + type: 2, + nextLink: '#loadHistoryComments', + nextText: '展开后面', + scrollDelta: 1200 + } + }, + mpyit: { + SiteTypeID: 0, pager: { type: 1, - nextLink: '(//a[@title="next page"])[1][@href]', - pageElement: 'css;table.lista2t tr.lista2', - HT_insert: ['css;table.lista2t > tbody', 3], - replaceE: 'css;#pager_links', - scrollDelta: 900 + nextLink: '//a[@class="page-numbers"][@title="下一页"][@href]', + pageElement: 'css;#post > div[id^="post-"]', + HT_insert: ['css;#post > #pagenavi', 1], + replaceE: 'css;#post > #pagenavi', + scrollDelta: 1700 + } + }, + mpyit_category: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//a[@class="page-numbers"][@title="下一页"][@href]', + pageElement: 'css;#content > div[class^="entry_box"]', + HT_insert: ['css;#content > #pagenavi', 1], + replaceE: 'css;#content > #pagenavi', + scrollDelta: 1700 } }, yxssp: { - SiteTypeID: 33, + SiteTypeID: 0, pager: { type: 1, nextLink: '//div[@class="page-nav td-pb-padding-side"]/a[last()][@href]', @@ -456,29 +431,119 @@ scrollDelta: 1000 } }, - weibo_comment: { - SiteTypeID: 34, + rarbgprx: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '(//a[@title="next page"])[1][@href]', + pageElement: 'css;table.lista2t tr.lista2', + HT_insert: ['css;table.lista2t > tbody', 3], + replaceE: 'css;#pager_links', + scrollDelta: 900 + } + }, + pubmed_postslist: { + SiteTypeID: 0, pager: { type: 2, - nextLink: 'a[action-type="click_more_comment"]', - nextText: '查看更多c', - scrollDelta: 1000 + nextLink: 'button.load-button.next-page', + nextText: 'Show more', + scrollDelta: 1500 } }, afreecatv: { - SiteTypeID: 35, + SiteTypeID: 0, pager: { type: 2, nextLink: '.btn-more > button', intervals: 2000, scrollDelta: 1000 } + }, + alphacoders_art: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//a[@id="next_page"][@href]', + pageElement: 'css;.container-masonry > div', + HT_insert: ['css;.container-masonry', 3], + replaceE: '//div[@class="hidden-xs hidden-sm"]/..', + scrollDelta: 1000 + }, + function: { + before: alphacoders_art_beforeFunction + } + }, + alphacoders_wall: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//a[@id="next_page"][@href]', + pageElement: 'css;.thumb-container-big, .avatar-thumb, .thumb-element', + HT_insert: ['css;.thumb-container-big:nth-last-child(1), .avatar-thumb:nth-last-child(1), .thumb-element:nth-last-child(1)', 4], + replaceE: '//div[@class="hidden-xs hidden-sm"]/..', + scrollDelta: 1000 + } + }, + fitgirl: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//a[@class="next page-numbers"][@href]', + pageElement: 'css;article[id^="post-"]', + HT_insert: ['css;nav.navigation.paging-navigation', 1], + replaceE: 'css;nav.navigation.paging-navigation', + scrollDelta: 2000 + } } }; + // 生成 ID + generateID(); + + // 用于脚本判断 + const SiteType = { + GAMERSKY_GL: DBSite.gamersky_gl.SiteTypeID + }; if (webType === 1) { // < 其他网站 > switch (location.host) { + case 'movie.douban.com': + if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评 + curSite = DBSite.douban_subject_comments; + } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评 + curSite = DBSite.douban_subject_reviews; + } else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论 + curSite = DBSite.douban_subject_episode; + } + break; + case 'weibo.com': + curSite = DBSite.weibo_comment; + break; + case 'www.58pic.com': + if (location.pathname.indexOf('/tupian/') > -1) { + curSite = DBSite._58pic; + } else if (location.pathname.indexOf('/c/') > -1) { + curSite = DBSite._58pic_c; + } + break; + case 'www.3dmgame.com': + curSite = DBSite._3dmgame; + break; + case 'www.ali213.net': + curSite = DBSite.ali213_www; + break; + case 'gl.ali213.net': + curSite = DBSite.ali213_gl; + document.lastElementChild.appendChild(document.createElement('style')).textContent = `.n_show_b {display: none !important;}` // 隐藏部分碍事元素 + break; + case 'www.gamersky.com': + if (location.pathname.indexOf('/ent/') > -1) { + curSite = DBSite.gamersky_ent; + } else { + curSite = DBSite.gamersky_gl; + } + break; case 'www.423down.com': if (location.pathname.indexOf('.html') === -1) curSite = DBSite._423down_postslist; break; @@ -491,13 +556,6 @@ case 'www.appinn.com': curSite = DBSite.appinn_postslist; break; - case 'www.iplaysoft.com': - if (location.pathname.indexOf('.html') > -1 || location.pathname.indexOf('/p/') > -1) { // 文章内 - curSite = DBSite.iplaysoft_postcomments; - } else { // 其他页面 - curSite = DBSite.iplaysoft_postslist; - } - break; case 'www.weidown.com': if (location.pathname.indexOf('/search/') > -1) { curSite = DBSite.weidown_search; @@ -507,69 +565,48 @@ curSite = DBSite.weidown; } break; - case 'www.yxssp.com': - curSite = DBSite.yxssp; - break; - case 'fitgirl-repacks.site': - curSite = DBSite.fitgirl; - break; - case 'art.alphacoders.com': - curSite = DBSite.art_alphacoders; - setTimeout(art_alphacoders_beforeFunction_0, 1000); - break; - case 'wall.alphacoders.com': - case 'avatars.alphacoders.com': - case 'mobile.alphacoders.com': - curSite = DBSite.wall_alphacoders; - break; - case 'pubmed.ncbi.nlm.nih.gov': - curSite = DBSite.pubmed_postslist; + case 'www.luochenzhimu.com': + curSite = DBSite.luochenzhimu; break; - case 'movie.douban.com': - if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评 - curSite = DBSite.douban_subject_comments; - } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评 - curSite = DBSite.douban_subject_reviews; - } else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论 - curSite = DBSite.douban_subject_episode; + case 'www.iplaysoft.com': + if (location.pathname.indexOf('.html') > -1 || location.pathname.indexOf('/p/') > -1) { // 文章内 + curSite = DBSite.iplaysoft_postcomments; + } else { // 其他页面 + curSite = DBSite.iplaysoft_postslist; } break; - case 'search.douban.com': - curSite = DBSite.douban_search; - break; - case 'www.3dmgame.com': - curSite = DBSite._3dmgame; - break; - case 'www.gamersky.com': - if (location.pathname.indexOf('/ent/') > -1) { - curSite = DBSite.gamersky_ent; - } else { - curSite = DBSite.gamersky_gl; + case 'www.mpyit.com': + if (location.pathname === '/' && !location.search) { + curSite = DBSite.mpyit; + } else if (location.pathname.indexOf('/category/') > -1 || location.search.indexOf('?s=') > -1) { + curSite = DBSite.mpyit_category; } break; - case 'www.ali213.net': - curSite = DBSite.ali213_www; - break; - case 'gl.ali213.net': - curSite = DBSite.ali213_gl; - document.lastElementChild.appendChild(document.createElement('style')).textContent = `.n_show_b {display: none !important;}` // 隐藏部分碍事元素 - break; - case 'www.58pic.com': - if (location.pathname.indexOf('/tupian/') > -1) { - curSite = DBSite._58pic; - } else if (location.pathname.indexOf('/c/') > -1) { - curSite = DBSite._58pic_c; - } + case 'www.yxssp.com': + curSite = DBSite.yxssp; break; case 'rarbgprx.org': curSite = DBSite.rarbgprx; break; - case 'weibo.com': - curSite = DBSite.weibo_comment; + case 'pubmed.ncbi.nlm.nih.gov': + curSite = DBSite.pubmed_postslist; break; + case 'www.afreecatv.com': curSite = DBSite.afreecatv; break; + case 'art.alphacoders.com': + curSite = DBSite.alphacoders_art; + setTimeout(alphacoders_art_beforeFunction_0, 1000); + break; + case 'wall.alphacoders.com': + case 'avatars.alphacoders.com': + case 'mobile.alphacoders.com': + curSite = DBSite.alphacoders_wall; + break; + case 'fitgirl-repacks.site': + curSite = DBSite.fitgirl; + break; } } else if (webType === 2) { // < 所有 Discuz!论坛 > if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) @@ -632,7 +669,7 @@ let scrollElement = document.querySelector(curSite.pager.scrollElement); //console.log(scrollElement.offsetTop - (scrollTop + scrollHeight), scrollDelta, curSite.SiteTypeID) if (scrollElement.offsetTop - (scrollTop + scrollHeight) <= scrollDelta) { - if (curSite.SiteTypeID === 27) curSite.pager.scrollDelta -= 800 // 游民星空 gl 的比较奇葩,需要特殊处理下 + if (curSite.SiteTypeID === SiteType.GAMERSKY_GL) curSite.pager.scrollDelta -= 800 // 游民星空 gl 的比较奇葩,需要特殊处理下 ShowPager.loadMorePage(); } } else { @@ -681,14 +718,28 @@ } - // iplaysoft 的插入前函数(加载图片) - function iplaysoft_postslist_beforeFunction(pageElems) { + // 58pic 的插入前函数(加载图片) + function _58pic_beforeFunction(pageElems) { + let is_one = document.querySelector('.qtw-card.place-box.is-one'); + if (is_one && is_one.style.display != 'none') { + is_one.setAttribute('style', 'display: none;') + } pageElems.forEach(function (one) { - let now = one.querySelector('img.lazyload') - if (now && !now.getAttribute('src')) { - now.setAttribute('src',now.getAttribute('data-src')) - now.setAttribute('srcset',now.getAttribute('data-src')) - now.setAttribute('class','lazyloaded') + let now = one.querySelector('img.lazy') + if (now && now.getAttribute('src') != now.dataset.original) { + now.setAttribute('src', now.dataset.original) + now.setAttribute('style', 'display: block;') + } + }); + return pageElems + } + + + // 游民星空攻略 的插入前函数(移除下一页底部的 "更多相关内容请关注:xxx" 文字) + function gamersky_gl_beforeFunction(pageElems) { + pageElems.forEach(function (one) { + if (one.tagName === 'P' && one.textContent.indexOf('更多相关内容请关注') > -1) { + one.style.display = 'none'; } }); return pageElems @@ -708,51 +759,47 @@ } - // art_alphacoders(图片结构调整) - function art_alphacoders_beforeFunction_0() { - let pageElems1 = document.querySelectorAll('.container-masonry > div') - document.querySelector('.container-masonry').style.height = 'auto' - pageElems1.forEach(function (one) { - one.setAttribute('style','float: left'); - }); - } - - - // art_alphacoders 的插入前函数(图片结构调整) - function art_alphacoders_beforeFunction(pageElems) { + // luochenzhimu 的插入前函数(加载图片) + function luochenzhimu_beforeFunction(pageElems) { pageElems.forEach(function (one) { - one.setAttribute('style','float: left'); + let now = one.querySelector('img.thumb') + if (now) { + now.setAttribute('src', now.dataset.src) + } }); return pageElems } - // 58pic 的插入前函数(加载图片) - function _58pic_beforeFunction(pageElems) { - let is_one = document.querySelector('.qtw-card.place-box.is-one'); - if (is_one && is_one.style.display != 'none') { - is_one.setAttribute('style', 'display: none;') - } + // iplaysoft 的插入前函数(加载图片) + function iplaysoft_postslist_beforeFunction(pageElems) { pageElems.forEach(function (one) { - let now = one.querySelector('img.lazy') - if (now && now.getAttribute('src') != now.dataset.original) { - now.setAttribute('src', now.dataset.original) - now.setAttribute('style', 'display: block;') + let now = one.querySelector('img.lazyload') + if (now && !now.src) { + now.setAttribute('src', now.dataset.src) + now.setAttribute('srcset', now.dataset.src) + now.setAttribute('class', 'lazyloaded') } }); return pageElems } - // 游民星空攻略 的插入前函数(移除下一页底部的 "更多相关内容请关注:xxx" 文字) - function gamersky_gl_beforeFunction(pageElems) { + // alphacoders_art 的插入前函数(图片结构调整) + function alphacoders_art_beforeFunction(pageElems) { pageElems.forEach(function (one) { - if (one.tagName === 'P' && one.textContent.indexOf('更多相关内容请关注') > -1) { - one.style.display = 'none'; - } + one.setAttribute('style','float: left'); }); return pageElems } + // alphacoders_art(图片结构调整) + function alphacoders_art_beforeFunction_0() { + let pageElems1 = document.querySelectorAll('.container-masonry > div') + document.querySelector('.container-masonry').style.height = 'auto' + pageElems1.forEach(function (one) { + one.setAttribute('style','float: left'); + }); + } // 启用/禁用 (当前网站) @@ -806,6 +853,15 @@ }; + // 生成 ID + function generateID() { + let num = 0 + for (let val in DBSite) { + DBSite[val].SiteTypeID = num = num + 1; + } + } + + // 滚动条事件 function windowScroll(fn1) { var beforeScrollTop = document.documentElement.scrollTop, @@ -871,7 +927,7 @@ curSite.pager.startFilter && curSite.pager.startFilter(); GM_xmlhttpRequest({ url: url, - method: "GET", + method: 'GET', timeout: 5000, onload: function (response) { try { @@ -884,7 +940,7 @@ if (curSite.function && curSite.function.before) { if (curSite.function.parameter) { // 如果指定了参数 pageElems = curSite.function.before(curSite.function.parameter); - }else{ + } else { pageElems = curSite.function.before(pageElems); } } From 493a7a705091b78f0b78419fb11ab612adabe445 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Thu, 5 Aug 2021 17:13:51 +0800 Subject: [PATCH 0026/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E4=BA=BF?= =?UTF-8?q?=E7=A0=B4=E5=A7=90]=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 8557e4d29..ce338d6f2 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.4.1 +// @version 1.4.2 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、Apphot、不死鸟、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、Apphot、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... // @match *://*/* // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png @@ -24,7 +24,7 @@ // 目前支持的网站 const websiteList = ['movie.douban.com', 'weibo.com', 'www.58pic.com', 'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', - 'www.423down.com', 'apphot.cc', 'iao.su', 'www.appinn.com', 'www.weidown.com', 'www.luochenzhimu.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com', + 'www.423down.com', 'apphot.cc', 'iao.su', 'www.ypojie.com', 'www.appinn.com', 'www.weidown.com', 'www.luochenzhimu.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com', 'rarbgprx.org', 'pubmed.ncbi.nlm.nih.gov', 'www.afreecatv.com', @@ -565,6 +565,7 @@ curSite = DBSite.weidown; } break; + case 'www.ypojie.com': case 'www.luochenzhimu.com': curSite = DBSite.luochenzhimu; break; From 701abb1658ba39554694eea8bc638d2e9c75c458 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:12:45 +0800 Subject: [PATCH 0027/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 161 ++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 85 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index ce338d6f2..ff0b1e88e 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -2,7 +2,7 @@ // @name 自动无缝翻页 // @version 1.4.2 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、Apphot、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... // @match *://*/* // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png @@ -148,6 +148,20 @@ scrollDelta: 1000 } }, + dux: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//li[@class="next-page"]/a[@href]', + pageElement: 'css;.content > article', + HT_insert: ['css;.content > .pagination', 1], + replaceE: 'css;.content > .pagination', + scrollDelta: 1000 + }, + function: { + before: dux_beforeFunction + } + }, douban_subject_comments: { SiteTypeID: 0, pager: { @@ -281,7 +295,7 @@ before: gamersky_gl_beforeFunction } }, - _423down_postslist: { + _423down: { SiteTypeID: 0, pager: { type: 1, @@ -292,18 +306,7 @@ scrollDelta: 1500 } }, - apphot_postslist: { - SiteTypeID: 0, - pager: { - type: 1, - nextLink: '//div[@class="pagination"]//a[contains(text(),"下一页")][@href]', - pageElement: 'css;div.content > article.excerpt', - HT_insert: ['css;div.pagination', 1], - replaceE: 'css;div.pagination', - scrollDelta: 1500 - } - }, - iao_su_postslist: { + iao_su: { SiteTypeID: 0, pager: { type: 1, @@ -314,10 +317,10 @@ scrollDelta: 800 }, function: { - before: iao_su_postslist_beforeFunction + before: iao_su_beforeFunction } }, - appinn_postslist: { + appinn: { SiteTypeID: 0, pager: { type: 1, @@ -361,20 +364,6 @@ scrollDelta: 700 } }, - luochenzhimu: { - SiteTypeID: 0, - pager: { - type: 1, - nextLink: '//li[@class="next-page"]/a[@href]', - pageElement: 'css;.content > article', - HT_insert: ['css;.content > .pagination', 1], - replaceE: 'css;.content > .pagination', - scrollDelta: 1000 - }, - function: { - before: luochenzhimu_beforeFunction - } - }, iplaysoft_postslist: { SiteTypeID: 0, pager: { @@ -497,66 +486,71 @@ } } }; - // 生成 ID + // 生成 SiteTypeID generateID(); - // 用于脚本判断 + // 用于脚本判断(针对部分特殊的网站) const SiteType = { GAMERSKY_GL: DBSite.gamersky_gl.SiteTypeID }; - if (webType === 1) { // < 其他网站 > + // < 其他网站 > + if (webType === 1) { switch (location.host) { - case 'movie.douban.com': - if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评 + case 'apphot.cc': // < APPHOT > + case 'www.ypojie.com': // < 亿破姐 > + case 'www.luochenzhimu.com': // < 落尘之木 > + if (location.pathname.indexOf('.html') === -1) curSite = DBSite.dux; + if (location.host === 'apphot.cc') curSite.pager.scrollDelta = 1600; // 对于速度慢的网站,需要增加翻页敏感度 + break; + // 以上几个都是 WordPress 的 DUX 主题 + case 'movie.douban.com': // < 豆瓣评论 > + if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评 curSite = DBSite.douban_subject_comments; - } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评 + } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评 curSite = DBSite.douban_subject_reviews; - } else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论 + } else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论 curSite = DBSite.douban_subject_episode; } break; - case 'weibo.com': + case 'weibo.com': // < 微博评论 > curSite = DBSite.weibo_comment; break; - case 'www.58pic.com': + case 'www.58pic.com': // < 千图网 > if (location.pathname.indexOf('/tupian/') > -1) { curSite = DBSite._58pic; } else if (location.pathname.indexOf('/c/') > -1) { curSite = DBSite._58pic_c; } break; - case 'www.3dmgame.com': + case 'www.3dmgame.com': // < 3DM > curSite = DBSite._3dmgame; break; - case 'www.ali213.net': + case 'www.ali213.net': // < 游侠网 > curSite = DBSite.ali213_www; break; - case 'gl.ali213.net': + case 'gl.ali213.net': // < 游侠网 - 攻略页 > curSite = DBSite.ali213_gl; document.lastElementChild.appendChild(document.createElement('style')).textContent = `.n_show_b {display: none !important;}` // 隐藏部分碍事元素 break; - case 'www.gamersky.com': + case 'www.gamersky.com': // < 游民星空 > if (location.pathname.indexOf('/ent/') > -1) { curSite = DBSite.gamersky_ent; } else { curSite = DBSite.gamersky_gl; } break; - case 'www.423down.com': - if (location.pathname.indexOf('.html') === -1) curSite = DBSite._423down_postslist; - break; - case 'apphot.cc': - if (location.pathname.indexOf('.html') === -1) curSite = DBSite.apphot_postslist; + case 'www.423down.com': // < 423down > + if (location.pathname.indexOf('.html') === -1) curSite = DBSite._423down; break; - case 'iao.su': - curSite = DBSite.iao_su_postslist; + case 'iao.su': // < 不死鸟 > + curSite = DBSite.iao_su; break; - case 'www.appinn.com': - curSite = DBSite.appinn_postslist; + case 'www.appinn.com': // < 小众软件 > + curSite = DBSite.appinn; break; - case 'www.weidown.com': + case 'www.weidown.com': // < 微当下载 > if (location.pathname.indexOf('/search/') > -1) { curSite = DBSite.weidown_search; } else if (location.pathname.indexOf('/special/') > -1) { @@ -565,38 +559,33 @@ curSite = DBSite.weidown; } break; - case 'www.ypojie.com': - case 'www.luochenzhimu.com': - curSite = DBSite.luochenzhimu; - break; - case 'www.iplaysoft.com': + case 'www.iplaysoft.com': // < 异次元软件 > if (location.pathname.indexOf('.html') > -1 || location.pathname.indexOf('/p/') > -1) { // 文章内 curSite = DBSite.iplaysoft_postcomments; } else { // 其他页面 curSite = DBSite.iplaysoft_postslist; } break; - case 'www.mpyit.com': + case 'www.mpyit.com': // < 老殁殁漂遥 > if (location.pathname === '/' && !location.search) { curSite = DBSite.mpyit; } else if (location.pathname.indexOf('/category/') > -1 || location.search.indexOf('?s=') > -1) { curSite = DBSite.mpyit_category; } break; - case 'www.yxssp.com': + case 'www.yxssp.com': // < 异星软件空间 > curSite = DBSite.yxssp; break; - case 'rarbgprx.org': + case 'rarbgprx.org': // < RARBG > curSite = DBSite.rarbgprx; break; - case 'pubmed.ncbi.nlm.nih.gov': + case 'pubmed.ncbi.nlm.nih.gov': // < 国外学术网站 > curSite = DBSite.pubmed_postslist; break; - - case 'www.afreecatv.com': + case 'www.afreecatv.com': // < 直播网站 > curSite = DBSite.afreecatv; break; - case 'art.alphacoders.com': + case 'art.alphacoders.com': // < 壁纸网站 > curSite = DBSite.alphacoders_art; setTimeout(alphacoders_art_beforeFunction_0, 1000); break; @@ -605,11 +594,12 @@ case 'mobile.alphacoders.com': curSite = DBSite.alphacoders_wall; break; - case 'fitgirl-repacks.site': + case 'fitgirl-repacks.site': // < 游戏下载网站 > curSite = DBSite.fitgirl; break; } - } else if (webType === 2) { // < 所有 Discuz!论坛 > + // < 所有 Discuz!论坛 > + } else if (webType === 2) { if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾) if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表 if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮 @@ -620,9 +610,9 @@ } else if (location.pathname.indexOf('thread') > -1) { // 帖子内 if (GM_getValue('menu_discuz_thread_page')) { curSite = DBSite.discuz_thread; - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 } - }else if(location.pathname.indexOf('search') > -1) { // 搜索结果 + } else if(location.pathname.indexOf('search') > -1) { // 搜索结果 curSite = DBSite.discuz_search; } } else { @@ -635,7 +625,7 @@ } else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内 if (GM_getValue('menu_discuz_thread_page')) { curSite = DBSite.discuz_thread; - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 } } else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表 curSite = DBSite.discuz_guide; @@ -645,11 +635,12 @@ curSite = DBSite.discuz_collection; } else if (location.pathname.indexOf('search') > -1) { // 搜索结果 curSite = DBSite.discuz_search; - } else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的 + } else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的 curSite = DBSite.discuz_forum; } } - } else if (webType === 3) { // < 所有 Flarum 论坛 > + // < 所有 Flarum 论坛 > + } else if (webType === 3) { curSite = DBSite.flarum; } @@ -719,6 +710,18 @@ } + // dux 的插入前函数(加载图片) + function dux_beforeFunction(pageElems) { + pageElems.forEach(function (one) { + let now = one.querySelector('img.thumb[data-src]') + if (now) { + now.setAttribute('src', now.dataset.src) + } + }); + return pageElems + } + + // 58pic 的插入前函数(加载图片) function _58pic_beforeFunction(pageElems) { let is_one = document.querySelector('.qtw-card.place-box.is-one'); @@ -748,7 +751,7 @@ // iao.su 的插入前函数(加载图片) - function iao_su_postslist_beforeFunction(pageElems) { + function iao_su_beforeFunction(pageElems) { pageElems.forEach(function (one) { let now = one.getElementsByClassName('post-card')[0] if (now) { @@ -760,18 +763,6 @@ } - // luochenzhimu 的插入前函数(加载图片) - function luochenzhimu_beforeFunction(pageElems) { - pageElems.forEach(function (one) { - let now = one.querySelector('img.thumb') - if (now) { - now.setAttribute('src', now.dataset.src) - } - }); - return pageElems - } - - // iplaysoft 的插入前函数(加载图片) function iplaysoft_postslist_beforeFunction(pageElems) { pageElems.forEach(function (one) { From ae39a6bfd2504f76a317c2909f9b329da245fdde Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 6 Aug 2021 00:59:41 +0800 Subject: [PATCH 0028/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E5=8F=A4?= =?UTF-8?q?=E9=A3=8E=E6=BC=AB=E7=94=BB=E7=BD=91]=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 148 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 129 insertions(+), 19 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index ff0b1e88e..1f2949fae 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.4.2 +// @version 1.4.3 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... // @match *://*/* // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png @@ -25,6 +25,7 @@ const websiteList = ['movie.douban.com', 'weibo.com', 'www.58pic.com', 'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', 'www.423down.com', 'apphot.cc', 'iao.su', 'www.ypojie.com', 'www.appinn.com', 'www.weidown.com', 'www.luochenzhimu.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com', + 'www.gufengmh8.com', 'rarbgprx.org', 'pubmed.ncbi.nlm.nih.gov', 'www.afreecatv.com', @@ -64,6 +65,7 @@ nextText: 按钮文本,只有按钮文本为该文本时才会点击按钮加载下一页,避免一瞬间加载太多次下一页 intervals: 点击间隔时间,对于没有按钮文字变化的按钮,可以手动指定间隔时间,单位:ms 3 = 依靠元素距离可视区域底部的距离来触发翻页 + 4 = 针对部分简单动态加载的网站 HT_insert: 1 = 插入该元素本身的前面; 2 = 插入该元素当中,第一个子元素前面; @@ -484,6 +486,18 @@ replaceE: 'css;nav.navigation.paging-navigation', scrollDelta: 2000 } + }, + gufengmh8: { + SiteTypeID: 0, + pager: { + type: 4, + pageElement: 'css;body > script:first-child', + HT_insert: ['css;#images', 3], + intervals: 5000, + functionNext: gufengmh8_functionNext, + functionAdd: gufengmh8_functionAdd, + scrollDelta: 2333 + } } }; // 生成 SiteTypeID @@ -576,6 +590,9 @@ case 'www.yxssp.com': // < 异星软件空间 > curSite = DBSite.yxssp; break; + case 'www.gufengmh8.com': // < 古风漫画网 > + curSite = DBSite.gufengmh8; + break; case 'rarbgprx.org': // < RARBG > curSite = DBSite.rarbgprx; break; @@ -653,7 +670,7 @@ function pageLoading() { if (curSite.SiteTypeID > 0) { windowScroll(function (direction, e) { - if (direction === "down") { // 下滑才准备翻页 + if (direction === 'down') { // 下滑才准备翻页 let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop, scrollHeight = window.innerHeight || document.documentElement.clientHeight, scrollDelta = curSite.pager.scrollDelta; @@ -683,8 +700,17 @@ } } } - } else { // 翻页类型 1 + } else if (curSite.pager.type === 1) { // 翻页类型 1 ShowPager.loadMorePage(); + } else if (curSite.pager.type === 4) { // 翻页类型 4 + if (curSite.SiteTypeID > 0) { + curSite.pager.functionNext(); + if (curSite.pager.intervals) { + let _SiteTypeID = curSite.SiteTypeID; + curSite.SiteTypeID = 0; + setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals) + } + } } } } @@ -794,6 +820,63 @@ } + // gufengmh8 + function gufengmh8_functionNext() { + if (curSite.pageUrl) { // 如果已经有下一页的 URL 则直接获取 + getPageElems(curSite.pageUrl) + } else { + let pageElems = document.querySelector(curSite.pager.pageElement.replace('css;', '')); // 寻找数据所在元素 + if (pageElems) { + let comicUrl, nextId; + pageElems.textContent.split(';').forEach(function (one){ // 分号 ; 分割为数组并遍历 + //console.log(one) + if (one.indexOf('comicUrl') > -1) { // 下一页 URL 前半部分 + comicUrl = one.split('"')[1]; + } else if (one.indexOf('nextChapterData') > -1) { // 下一页 URL 的后半部分 ID + nextId = one.split('"id":')[1].split(',')[0]; + } + }) + if (comicUrl && nextId && nextId != 'null') { // 组合到一起就是下一页 URL + curSite.pageUrl = comicUrl + nextId + '.html' + //console.log(curSite.pageUrl) + getPageElems(curSite.pageUrl); // 访问下一页 URL 获取 + } + } + } + } + + // gufengmh8 + function gufengmh8_functionAdd(pageElems) { + if (pageElems) { + curSite.pageUrl = ''; // 留空后,下一页 URL 依然交给 gufengmh8_function 函数获取(方便点) + pageElems = pageElems[0]; + //console.log(pageElems) + let chapterImages, chapterPath; + //console.log(pageElems.textContent) + document.querySelector(curSite.pager.pageElement.replace('css;', '')).innerText = pageElems.textContent; // 将当前网页内的数据所在元素内容改为刚刚获取的下一页数据内容,以便循环获取下一页 URL(gufengmh8_function 函数) + pageElems.textContent.split(';').forEach(function (one){ // 分号 ; 分割为数组并遍历 + //console.log(one) + if (one.indexOf('chapterImages') > -1) { // 图片文件名数组 + chapterImages = one.replace(/^.+\[/, '').replace(']', '').replaceAll('"', '').split(',') + } else if (one.indexOf('chapterPath') > -1) { // 图片文件路径 + chapterPath = one.split('"')[1]; + } else if (one.indexOf('pageTitle') > -1) { // 网页标题 + window.document.title = one.split('"')[1]; // 修改当前网页标题为下一页的标题 + } + }) + if (chapterImages && chapterPath) { + let _img = ''; + chapterImages.forEach(function (one2){ // 遍历图片文件名数组,组合为 img 标签 + _img += '' + //console.log('https://res.xiaoqinre.com/' + chapterPath + one2) + }) + document.querySelector(curSite.pager.HT_insert[0].replace('css;', '')).insertAdjacentHTML(addTo(curSite.pager.HT_insert[1]), _img); // 将 img 标签插入到网页中 + + } + } + } + + // 启用/禁用 (当前网站) function menu_disable(type) { switch(type) { @@ -854,6 +937,47 @@ } + // 类型 4 专用 + function getPageElems(url) { + GM_xmlhttpRequest({ + url: url, + method: 'GET', + timeout: 5000, + onload: function (response) { + try { + //console.log(`${response.responseText}`) + var newBody = ShowPager.createDocumentByString(response.responseText); + let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody); + if (pageElems.length >= 0) { + curSite.pager.functionAdd(pageElems) + } + } catch (e) { + console.log(e); + } + } + }); + } + + + // 插入位置 + function addTo(num) { + switch (num) { + case 1: + return 'beforebegin' + break; + case 2: + return 'afterbegin' + break; + case 3: + return 'beforeend' + break; + case 4: + return 'afterend' + break; + } + } + + // 滚动条事件 function windowScroll(fn1) { var beforeScrollTop = document.documentElement.scrollTop, @@ -937,21 +1061,7 @@ } } // 插入位置 - let addTo; - switch (curSite.pager.HT_insert[1]) { - case 1: - addTo = "beforebegin" - break; - case 2: - addTo = "afterbegin" - break; - case 3: - addTo = "beforeend" - break; - case 4: - addTo = "afterend" - break; - } + let addTo = addTo(curSite.pager.HT_insert[1]); // 插入新页面元素 pageElems.forEach(function (one) { toElement.insertAdjacentElement(addTo, one); From ea524a9c78b90a5fbe9eebafc5fd105128674224 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 6 Aug 2021 11:39:36 +0800 Subject: [PATCH 0029/2043] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=B8=8A?= =?UTF-8?q?=E4=B8=AA=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E7=BF=BB=E9=A1=B5=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 1f2949fae..e9e64ba2c 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.4.3 +// @version 1.4.4 // @author X.I.U // @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... // @match *://*/* @@ -1061,10 +1061,10 @@ } } // 插入位置 - let addTo = addTo(curSite.pager.HT_insert[1]); + let addTo1 = addTo(curSite.pager.HT_insert[1]); // 插入新页面元素 pageElems.forEach(function (one) { - toElement.insertAdjacentElement(addTo, one); + toElement.insertAdjacentElement(addTo1, one); }); // 替换待替换元素 try { From 6339c681fd688501c2a2287fbcdfc457c3b3ecd6 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 6 Aug 2021 11:48:22 +0800 Subject: [PATCH 0030/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[=E7=99=BE?= =?UTF-8?q?=E5=BA=A6=E6=90=9C=E7=B4=A2]=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 26 ++++++++++++++++++++------ README.md | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index e9e64ba2c..3cb52023b 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.4.4 +// @version 1.4.5 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、百度、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... // @match *://*/* // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png @@ -22,7 +22,7 @@ 'use strict'; var webType, curSite = {SiteTypeID: 0}; // 目前支持的网站 - const websiteList = ['movie.douban.com', 'weibo.com', 'www.58pic.com', + const websiteList = ['www.baidu.com', 'movie.douban.com', 'weibo.com', 'www.58pic.com', 'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', 'www.423down.com', 'apphot.cc', 'iao.su', 'www.ypojie.com', 'www.appinn.com', 'www.weidown.com', 'www.luochenzhimu.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com', 'www.gufengmh8.com', @@ -164,6 +164,17 @@ before: dux_beforeFunction } }, + baidu: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//div[@id="page"]//a[contains(text(),"下一页")][@href]', + pageElement: 'css;#content_left > *', + HT_insert: ['css;#content_left', 3], + replaceE: 'css;#page', + scrollDelta: 1200 + } + }, douban_subject_comments: { SiteTypeID: 0, pager: { @@ -519,6 +530,9 @@ if (location.host === 'apphot.cc') curSite.pager.scrollDelta = 1600; // 对于速度慢的网站,需要增加翻页敏感度 break; // 以上几个都是 WordPress 的 DUX 主题 + case 'www.baidu.com': // < 百度搜索 > + if (location.pathname === '/s') curSite = DBSite.baidu; + break; case 'movie.douban.com': // < 豆瓣评论 > if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评 curSite = DBSite.douban_subject_comments; @@ -945,7 +959,7 @@ timeout: 5000, onload: function (response) { try { - //console.log(`${response.responseText}`) + //console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText) var newBody = ShowPager.createDocumentByString(response.responseText); let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody); if (pageElems.length >= 0) { @@ -1035,7 +1049,7 @@ if (curSite.pager) { let curPageEle = getElementByXpath(curSite.pager.nextLink); var url = this.getFullHref(curPageEle); - //console.log(`${url} ${curPageEle} ${curSite.pageUrl}`); + console.log(`${url} ${curPageEle} ${curSite.pageUrl}`); if (url === '') return; if (curSite.pageUrl === url) return;// 避免重复加载相同的页面 curSite.pageUrl = url; @@ -1047,7 +1061,7 @@ timeout: 5000, onload: function (response) { try { - //console.log(`${response.responseText}`) + //console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText) var newBody = ShowPager.createDocumentByString(response.responseText); let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody); let toElement = getAllElements(curSite.pager.HT_insert[0])[0]; diff --git a/README.md b/README.md index a9cd7c2b3..43b58e0bf 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ | [](https://www.zhihu.com/people/xiu2) | **知乎 增强** | **移除登录弹窗**、一键收起回答、屏蔽用户、屏蔽关键词、快... | **[安装](https://greasyfork.org/zh-CN/scripts/419081)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhihu-Enhanced.user.js)** | | [](https://www.v2ex.com/) | **V2ex 增强** | **自动签到**、链接转图片、自动无缝翻页、新标签页打开链接... | **[安装](https://greasyfork.org/zh-CN/scripts/424246)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/V2ex-Enhanced.user.js)** | | [](https://github.com/XIU2) | **Github 增强** | **高速下载** Git Clone/SSH、Release、Raw、Code(ZIP) 文件... | **[安装](https://greasyfork.org/zh-CN/scripts/412245)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/GithubEnhanced-High-Speed-Download.user.js)** | -| [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz! / Flarum 论坛**、豆瓣、微博、千图网、423Do... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | +| [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz! / Flarum 论坛**、百度、豆瓣、微博、千图网... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/413593)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Beautification.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 增强** | **自动回复**、自动无缝翻页、清理置顶帖子、自动滚动至隐藏... | **[安装](https://greasyfork.org/zh-CN/scripts/412890)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Enhanced.user.js)** | | [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | **智友邦论坛 美化** | 精简多余内容、样式优化、宽屏显示 | **[安装](https://greasyfork.org/zh-CN/scripts/412361)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)** | From c93b026e6f4e1af9f4e220330e666f1c6f0265f0 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 6 Aug 2021 13:00:11 +0800 Subject: [PATCH 0031/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 131 +++++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 62 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 3cb52023b..c5091621d 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -997,59 +997,54 @@ var beforeScrollTop = document.documentElement.scrollTop, fn = fn1 || function () {}; setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件 - window.addEventListener("scroll", function (e) { + window.addEventListener('scroll', function (e) { var afterScrollTop = document.documentElement.scrollTop, delta = afterScrollTop - beforeScrollTop; if (delta == 0) return false; - fn(delta > 0 ? "down" : "up", e); + fn(delta > 0 ? 'down' : 'up', e); beforeScrollTop = afterScrollTop; }, false); }, 1000) } - var ShowPager = { // 修改自 https://greasyfork.org/scripts/14178 + // 修改自 https://greasyfork.org/scripts/14178 , https://github.com/machsix/Super-preloader + var ShowPager = { getFullHref: function (e) { if(e == null) return ''; - "string" != typeof e && (e = e.getAttribute("href")); + 'string' != typeof e && (e = e.getAttribute('href')); var t = this.getFullHref.a; - return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href; + if (t) {return t} + ((this.getFullHref.a = t = document.createElement('a')), t.href = e, t.href) + if (t.href) {return t.href} + //return t || ((this.getFullHref.a = t = document.createElement('a')), t.href = e, t.href); }, createDocumentByString: function (e) { if (e) { - if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml"); + if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml'); var t; - try { - t = (new DOMParser).parseFromString(e, "text/html"); - } catch (e) { - } + try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {} if (t) return t; - if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try { - (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), - t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body")); - } catch (e) { + if (document.implementation.createHTMLDocument) { + t = document.implementation.createHTMLDocument('ADocument'); + } else { + try {((t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), t.documentElement.appendChild(t.createElement('head')), t.documentElement.appendChild(t.createElement('body')));} catch (e) {} } if (t) { - var r = document.createRange(); + var r = document.createRange(), + n = r.createContextualFragment(e); r.selectNodeContents(document.body); - var n = r.createContextualFragment(e); t.body.appendChild(n); - for (var a, o = { - TITLE: !0, - META: !0, - LINK: !0, - STYLE: !0, - BASE: !0 - }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); + for (var a, o = { TITLE: !0, META: !0, LINK: !0, STYLE: !0, BASE: !0}, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); return t; } - } else console.error("没有找到要转成DOM的字符串"); + } else console.error('没有找到要转成 DOM 的字符串'); }, loadMorePage: function () { if (curSite.pager) { let curPageEle = getElementByXpath(curSite.pager.nextLink); var url = this.getFullHref(curPageEle); - console.log(`${url} ${curPageEle} ${curSite.pageUrl}`); + //console.log(`${url} ${curPageEle} ${curSite.pageUrl}`); if (url === '') return; if (curSite.pageUrl === url) return;// 避免重复加载相同的页面 curSite.pageUrl = url; @@ -1063,8 +1058,9 @@ try { //console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText) var newBody = ShowPager.createDocumentByString(response.responseText); - let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody); - let toElement = getAllElements(curSite.pager.HT_insert[0])[0]; + let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody), + toElement = getAllElements(curSite.pager.HT_insert[0])[0]; + if (pageElems.length >= 0) { // 如果有插入前函数就执行函数 if (curSite.function && curSite.function.before) { @@ -1074,12 +1070,14 @@ pageElems = curSite.function.before(pageElems); } } + // 插入位置 let addTo1 = addTo(curSite.pager.HT_insert[1]); // 插入新页面元素 pageElems.forEach(function (one) { toElement.insertAdjacentElement(addTo1, one); }); + // 替换待替换元素 try { let oriE = getAllElements(curSite.pager.replaceE); @@ -1110,44 +1108,53 @@ }, }; - - function getElementByXpath(e, t, r) { - r = r || document, t = t || r; - try { - return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } catch (t) { - return void console.error("无效的xpath"); - } + function getElementByCSS(css, contextNode = document) { + return contextNode.querySelector(css); } - - - function getAllElements(e, t, r, n, o) { - let getAllElementsByXpath = function(e, t, r) { - return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - } - - var i, s = []; - if (!e) return s; - if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" == typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) { - return (t || document).querySelectorAll(e); - }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else { - if (!(i = e(r, n, o))) return s; - if (i.nodeType) return s[0] = i, s; - } - return function makeArray(e) { - var t, r, n, o = []; - if (e.pop) { - for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n))); - return a()(o); + function getAllElementsByCSS(css, contextNode = document) { + return [].slice.call(contextNode.querySelectorAll(css)); + } + function getElementByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + try { + const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); + // 应该总是返回一个元素节点 + return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue; + } catch (err) { + throw new Error(`Invalid xpath: ${xpath}`); } - if (e.item) { - for (t = e.length; t;) o[--t] = e[t]; - return o; + } + function getAllElementsByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + const result = []; + try { + const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + for (let i = 0; i < query.snapshotLength; i++) { + const node = query.snapshotItem(i); + // 如果是 Element 节点 + if (node.nodeType === 1) result.push(node); + } + } catch (err) { + throw new Error(`无效 Xpath: ${xpath}`); } - if (e.iterateNext) { - for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t); - return o; + return result; + } + function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) { + if (!selector) return []; + contextNode = contextNode || doc; + if (typeof selector === 'string') { + if (selector.search(/^css;/i) === 0) { + return getAllElementsByCSS(selector.slice(4), contextNode); + } else { + return getAllElementsByXpath(selector, contextNode, doc); + } + } else { + const query = selector(doc, win, _cplink); + if (!Array.isArray(query)) { + throw new Error('getAllElements 返回错误类型'); + } else { + return query; + } } - }(i); } })(); \ No newline at end of file From c4845dfb22b14a8a9e4415934dad1b400f5b272c Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 6 Aug 2021 20:02:46 +0800 Subject: [PATCH 0032/2043] README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 43b58e0bf..c427e94fc 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ | [](https://bbs.3dmgame.com) | **3DM论坛 增强** | **自动回复**、自动无缝翻页、清理置顶帖子、自动滚动至隐藏... | **[安装](https://greasyfork.org/zh-CN/scripts/412890)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Enhanced.user.js)** | | [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | **智友邦论坛 美化** | 精简多余内容、样式优化、宽屏显示 | **[安装](https://greasyfork.org/zh-CN/scripts/412361)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)** | | [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | **智友邦论坛 增强** | 自动签到、**自动回复**、自动无缝翻页、快捷回到顶部、附件... | **[安装](https://greasyfork.org/zh-CN/scripts/412362)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Enhanced.user.js)** | -| [](https://www.lanzou.com) | **蓝奏云网盘 增强 \*** | 刷新不回根目录、**右键显示菜单**、自动显示更多文件、自动... | **[安装](https://greasyfork.org/zh-CN/scripts/419224)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** | +| [](https://www.lanzou.com) | **蓝奏云网盘 增强 \*** | 刷新不回根目录、**右键显示菜单**、显示更多文件、自动密码... | **[安装](https://greasyfork.org/zh-CN/scripts/419224)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** | | [](https://translate.google.cn) | ~~_**Google 翻译 美化**_~~ | ~~_精简多余内容、修复翻译结果溢出屏幕问题_~~ | ~~_**[安装](https://zhuanlan.zhihu.com/p/286815739)** \| **[备用](https://zhuanlan.zhihu.com/p/286815739)**_~~ | | [](https://github.com/XIU2) | **新标签页打开链接 \*** | 将网页中所有链接改为新标签页打开~ | **[安装](https://greasyfork.org/zh-CN/scripts/429714)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/TargetBlank.user.js)** | | [](https://www.52pojie.cn) | **吾爱破解论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/412681)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/52pojie-Beautification.user.js)** | From 7edc75bf7dc2fb95e3f630531446f70d68caa6b1 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 6 Aug 2021 20:06:48 +0800 Subject: [PATCH 0033/2043] README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c427e94fc..aaca373b7 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ | [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz! / Flarum 论坛**、百度、豆瓣、微博、千图网... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/413593)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Beautification.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 增强** | **自动回复**、自动无缝翻页、清理置顶帖子、自动滚动至隐藏... | **[安装](https://greasyfork.org/zh-CN/scripts/412890)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Enhanced.user.js)** | -| [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | **智友邦论坛 美化** | 精简多余内容、样式优化、宽屏显示 | **[安装](https://greasyfork.org/zh-CN/scripts/412361)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)** | -| [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | **智友邦论坛 增强** | 自动签到、**自动回复**、自动无缝翻页、快捷回到顶部、附件... | **[安装](https://greasyfork.org/zh-CN/scripts/412362)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Enhanced.user.js)** | +| [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | ~~_**智友邦论坛 美化**_~~ | ~~_精简多余内容、样式优化、宽屏显示_~~ | ~~_**[安装](https://greasyfork.org/zh-CN/scripts/412361)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)**_~~ | +| [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | ~~_**智友邦论坛 增强**_~~ | ~~_自动签到、**自动回复**、自动无缝翻页、快捷回到顶部、附件..._~~ | ~~_**[安装](https://greasyfork.org/zh-CN/scripts/412362)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Enhanced.user.js)**_~~ | | [](https://www.lanzou.com) | **蓝奏云网盘 增强 \*** | 刷新不回根目录、**右键显示菜单**、显示更多文件、自动密码... | **[安装](https://greasyfork.org/zh-CN/scripts/419224)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** | | [](https://translate.google.cn) | ~~_**Google 翻译 美化**_~~ | ~~_精简多余内容、修复翻译结果溢出屏幕问题_~~ | ~~_**[安装](https://zhuanlan.zhihu.com/p/286815739)** \| **[备用](https://zhuanlan.zhihu.com/p/286815739)**_~~ | | [](https://github.com/XIU2) | **新标签页打开链接 \*** | 将网页中所有链接改为新标签页打开~ | **[安装](https://greasyfork.org/zh-CN/scripts/429714)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/TargetBlank.user.js)** | From 18a13ca9d70510e1f80c56c30aff90885c441cc6 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Fri, 6 Aug 2021 20:11:58 +0800 Subject: [PATCH 0034/2043] README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aaca373b7..a4968be54 100644 --- a/README.md +++ b/README.md @@ -25,15 +25,15 @@ | [](https://github.com/XIU2) | **自动无缝翻页 \*** | **所有 Discuz! / Flarum 论坛**、百度、豆瓣、微博、千图网... | **[安装](https://greasyfork.org/zh-CN/scripts/419215)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Autopage.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/413593)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Beautification.user.js)** | | [](https://bbs.3dmgame.com) | **3DM论坛 增强** | **自动回复**、自动无缝翻页、清理置顶帖子、自动滚动至隐藏... | **[安装](https://greasyfork.org/zh-CN/scripts/412890)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Enhanced.user.js)** | -| [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | ~~_**智友邦论坛 美化**_~~ | ~~_精简多余内容、样式优化、宽屏显示_~~ | ~~_**[安装](https://greasyfork.org/zh-CN/scripts/412361)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)**_~~ | -| [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | ~~_**智友邦论坛 增强**_~~ | ~~_自动签到、**自动回复**、自动无缝翻页、快捷回到顶部、附件..._~~ | ~~_**[安装](https://greasyfork.org/zh-CN/scripts/412362)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Enhanced.user.js)**_~~ | | [](https://www.lanzou.com) | **蓝奏云网盘 增强 \*** | 刷新不回根目录、**右键显示菜单**、显示更多文件、自动密码... | **[安装](https://greasyfork.org/zh-CN/scripts/419224)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** | -| [](https://translate.google.cn) | ~~_**Google 翻译 美化**_~~ | ~~_精简多余内容、修复翻译结果溢出屏幕问题_~~ | ~~_**[安装](https://zhuanlan.zhihu.com/p/286815739)** \| **[备用](https://zhuanlan.zhihu.com/p/286815739)**_~~ | | [](https://github.com/XIU2) | **新标签页打开链接 \*** | 将网页中所有链接改为新标签页打开~ | **[安装](https://greasyfork.org/zh-CN/scripts/429714)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/TargetBlank.user.js)** | | [](https://www.52pojie.cn) | **吾爱破解论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/412681)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/52pojie-Beautification.user.js)** | | [](https://www.52pojie.cn) | **吾爱破解论坛 增强** | **自动签到**、自动无缝翻页、屏蔽导读悬赏贴 (最新发表页)... | **[安装](https://greasyfork.org/zh-CN/scripts/412680)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/52pojie-Enhanced.user.js)** | | [](https://hostloc.com) | **全球主机交流论坛 增强 \*** | **自动访问空间(22积分)、屏蔽用户**、屏蔽关键词、自动无缝翻... | **[安装](https://greasyfork.org/zh-CN/scripts/414005)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Hostloc-Enhanced.user.js)** | | [](https://store.steampowered.com) | **Steam 创意工坊大图 修复** | 修复 Steam 创意工坊预览大图无法显示的问题 | **[安装](https://github.com/XIU2/UserScript/raw/master/SteamWorkshopImageRepair.user.js)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/SteamWorkshopImageRepair.user.js)** | +| [](https://translate.google.cn) | ~~_**Google 翻译 美化**_~~ | ~~_精简多余内容、修复翻译结果溢出屏幕问题_~~ | ~~_**[安装](https://zhuanlan.zhihu.com/p/286815739)** \| **[备用](https://zhuanlan.zhihu.com/p/286815739)**_~~ | +| [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | ~~_**智友邦论坛 美化**_~~ | ~~_精简多余内容、样式优化、宽屏显示_~~ | ~~_**[安装](https://greasyfork.org/zh-CN/scripts/412361)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)**_~~ | +| [](http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline) | ~~_**智友邦论坛 增强**_~~ | ~~_自动签到、**自动回复**、自动无缝翻页、快捷回到顶部、附件..._~~ | ~~_**[安装](https://greasyfork.org/zh-CN/scripts/412362)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Enhanced.user.js)**_~~ | > _脚本名称末尾 **`*`** 代表该脚本为**网友主动提出需求**而写的。如果你也有需求,可以[告诉我](https://github.com/XIU2/UserScript/issues/new/choose)!_ > _所有脚本均在 **Chrome、Firefox、Edge 浏览器 + Tampermonkey 扩展** 环境下测试通过!_ From 5cdde0ca9f21b7805d760139ff70bb8ac589e86f Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sat, 7 Aug 2021 13:27:53 +0800 Subject: [PATCH 0035/2043] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3dm-Enhanced.user.js | 166 ++++++++++++++++++------------------ 52pojie-Enhanced.user.js | 167 ++++++++++++++++++------------------ Autopage.user.js | 137 ++++++++++++++---------------- Hostloc-Enhanced.user.js | 178 +++++++++++++++++++-------------------- V2ex-Enhanced.user.js | 134 ++++++++++++++--------------- Zhiyoo-Enhanced.user.js | 178 +++++++++++++++++++-------------------- 6 files changed, 476 insertions(+), 484 deletions(-) diff --git a/3dm-Enhanced.user.js b/3dm-Enhanced.user.js index da01b7253..8a8ede5d3 100644 --- a/3dm-Enhanced.user.js +++ b/3dm-Enhanced.user.js @@ -194,29 +194,6 @@ } - // 自动翻页 - function pageLoading() { - if (curSite.SiteTypeID > 0){ - windowScroll(function (direction, e) { - if (direction === "down") { // 下滑才准备翻页 - let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; - let scrollDelta = 666; - if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) { - if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了 - let autopbn = document.querySelector('#autopbn'); - if (autopbn && autopbn.innerText == "下一页 »"){ // 如果已经在加载中了,就忽略 - autopbn.click(); - } - }else{ - ShowPager.loadMorePage(); - } - } - } - }); - } - } - - // 自动回复 function autoReply(){ if (loginStatus){ @@ -271,58 +248,73 @@ } + // 自动翻页 + function pageLoading() { + if (curSite.SiteTypeID > 0){ + windowScroll(function (direction, e) { + if (direction === 'down') { // 下滑才准备翻页 + let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; + let scrollDelta = 666; + if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) { + if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了 + let autopbn = document.querySelector('#autopbn'); + if (autopbn && autopbn.innerText == "下一页 »"){ // 如果已经在加载中了,就忽略 + autopbn.click(); + } + }else{ + ShowPager.loadMorePage(); + } + } + } + }); + } + } + + // 滚动条事件 function windowScroll(fn1) { var beforeScrollTop = document.documentElement.scrollTop, fn = fn1 || function () {}; setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件 - window.addEventListener("scroll", function (e) { + window.addEventListener('scroll', function (e) { var afterScrollTop = document.documentElement.scrollTop, delta = afterScrollTop - beforeScrollTop; if (delta == 0) return false; - fn(delta > 0 ? "down" : "up", e); + fn(delta > 0 ? 'down' : 'up', e); beforeScrollTop = afterScrollTop; }, false); }, 1000) } - var ShowPager = { // 修改自 https://greasyfork.org/scripts/14178 + // 修改自 https://greasyfork.org/scripts/14178 , https://github.com/machsix/Super-preloader + var ShowPager = { getFullHref: function (e) { if(e == null) return ''; - "string" != typeof e && (e = e.getAttribute("href")); + 'string' != typeof e && (e = e.getAttribute('href')); var t = this.getFullHref.a; - return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href; + return t || (this.getFullHref.a = t = document.createElement('a')), (t.href = e), t.href; }, createDocumentByString: function (e) { if (e) { - if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml"); + if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml'); var t; - try { - t = (new DOMParser).parseFromString(e, "text/html"); - } catch (e) { - } + try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {} if (t) return t; - if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try { - (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), - t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body")); - } catch (e) { + if (document.implementation.createHTMLDocument) { + t = document.implementation.createHTMLDocument('ADocument'); + } else { + try {((t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), t.documentElement.appendChild(t.createElement('head')), t.documentElement.appendChild(t.createElement('body')));} catch (e) {} } if (t) { - var r = document.createRange(); + var r = document.createRange(), + n = r.createContextualFragment(e); r.selectNodeContents(document.body); - var n = r.createContextualFragment(e); t.body.appendChild(n); - for (var a, o = { - TITLE: !0, - META: !0, - LINK: !0, - STYLE: !0, - BASE: !0 - }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); + for (var a, o = { TITLE: !0, META: !0, LINK: !0, STYLE: !0, BASE: !0}, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); return t; } - } else console.error("没有找到要转成DOM的字符串"); + } else console.error('没有找到要转成 DOM 的字符串'); }, loadMorePage: function () { if (curSite.pager) { @@ -371,45 +363,53 @@ } }, }; - - - function getElementByXpath(e, t, r) { - r = r || document, t = t || r; - try { - return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } catch (t) { - return void console.error("无效的xpath"); - } + function getElementByCSS(css, contextNode = document) { + return contextNode.querySelector(css); } - - - function getAllElements(e, t, r, n, o) { - let getAllElementsByXpath = function(e, t, r) { - return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - } - - var i, s = []; - if (!e) return s; - if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" == typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) { - return (t || document).querySelectorAll(e); - }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else { - if (!(i = e(r, n, o))) return s; - if (i.nodeType) return s[0] = i, s; - } - return function makeArray(e) { - var t, r, n, o = []; - if (e.pop) { - for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n))); - return a()(o); + function getAllElementsByCSS(css, contextNode = document) { + return [].slice.call(contextNode.querySelectorAll(css)); + } + function getElementByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + try { + const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); + // 应该总是返回一个元素节点 + return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue; + } catch (err) { + throw new Error(`Invalid xpath: ${xpath}`); } - if (e.item) { - for (t = e.length; t;) o[--t] = e[t]; - return o; + } + function getAllElementsByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + const result = []; + try { + const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + for (let i = 0; i < query.snapshotLength; i++) { + const node = query.snapshotItem(i); + // 如果是 Element 节点 + if (node.nodeType === 1) result.push(node); + } + } catch (err) { + throw new Error(`无效 Xpath: ${xpath}`); } - if (e.iterateNext) { - for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t); - return o; + return result; + } + function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) { + if (!selector) return []; + contextNode = contextNode || doc; + if (typeof selector === 'string') { + if (selector.search(/^css;/i) === 0) { + return getAllElementsByCSS(selector.slice(4), contextNode); + } else { + return getAllElementsByXpath(selector, contextNode, doc); + } + } else { + const query = selector(doc, win, _cplink); + if (!Array.isArray(query)) { + throw new Error('getAllElements 返回错误类型'); + } else { + return query; + } } - }(i); } })(); \ No newline at end of file diff --git a/52pojie-Enhanced.user.js b/52pojie-Enhanced.user.js index e4d7c4195..60df54ee1 100644 --- a/52pojie-Enhanced.user.js +++ b/52pojie-Enhanced.user.js @@ -184,30 +184,6 @@ pageLoading(); // 自动翻页 - // 自动翻页 - function pageLoading() { - if (!menu_value('menu_pageLoading')) return - if (curSite.SiteTypeID > 0) { - windowScroll(function (direction, e) { - if (direction === "down") { // 下滑才准备翻页 - let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; - let scrollDelta = curSite.pager.scrollDelta; - if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) { - if (curSite.pager.type === 1) { - ShowPager.loadMorePage(); - } else { - let autopbn = document.querySelector(curSite.pager.nextLink); - if (autopbn && autopbn.innerText == curSite.pager.nextText) { // 如果正在加载,就不再点击 - autopbn.click(); - } - } - } - } - }); - } - } - - // 自动签到(后台) function qianDao() { if (!menu_value('menu_autoClockIn')) return @@ -259,60 +235,75 @@ } + // 自动翻页 + function pageLoading() { + if (!menu_value('menu_pageLoading')) return + if (curSite.SiteTypeID > 0) { + windowScroll(function (direction, e) { + if (direction === "down") { // 下滑才准备翻页 + let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; + let scrollDelta = curSite.pager.scrollDelta; + if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) { + if (curSite.pager.type === 1) { + ShowPager.loadMorePage(); + } else { + let autopbn = document.querySelector(curSite.pager.nextLink); + if (autopbn && autopbn.innerText == curSite.pager.nextText) { // 如果正在加载,就不再点击 + autopbn.click(); + } + } + } + } + }); + } + } + + // 滚动条事件 function windowScroll(fn1) { var beforeScrollTop = document.documentElement.scrollTop, fn = fn1 || function () {}; setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件 - window.addEventListener("scroll", function (e) { + window.addEventListener('scroll', function (e) { var afterScrollTop = document.documentElement.scrollTop, delta = afterScrollTop - beforeScrollTop; if (delta == 0) return false; - fn(delta > 0 ? "down" : "up", e); + fn(delta > 0 ? 'down' : 'up', e); beforeScrollTop = afterScrollTop; }, false); }, 1000) } - // 自动无缝翻页,修改自 https://greasyfork.org/scripts/14178 + // 修改自 https://greasyfork.org/scripts/14178 , https://github.com/machsix/Super-preloader function showPager() { ShowPager = { getFullHref: function (e) { if(e == null) return ''; - "string" != typeof e && (e = e.getAttribute("href")); + 'string' != typeof e && (e = e.getAttribute('href')); var t = this.getFullHref.a; - return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href; + return t || (this.getFullHref.a = t = document.createElement('a')), (t.href = e), t.href; }, createDocumentByString: function (e) { if (e) { - if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml"); + if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml'); var t; - try { - t = (new DOMParser).parseFromString(e, "text/html"); - } catch (e) { - } + try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {} if (t) return t; - if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try { - (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), - t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body")); - } catch (e) { + if (document.implementation.createHTMLDocument) { + t = document.implementation.createHTMLDocument('ADocument'); + } else { + try {((t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), t.documentElement.appendChild(t.createElement('head')), t.documentElement.appendChild(t.createElement('body')));} catch (e) {} } if (t) { - var r = document.createRange(); + var r = document.createRange(), + n = r.createContextualFragment(e); r.selectNodeContents(document.body); - var n = r.createContextualFragment(e); t.body.appendChild(n); - for (var a, o = { - TITLE: !0, - META: !0, - LINK: !0, - STYLE: !0, - BASE: !0 - }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); + for (var a, o = { TITLE: !0, META: !0, LINK: !0, STYLE: !0, BASE: !0}, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); return t; } - } else console.error("没有找到要转成DOM的字符串"); + } else console.error('没有找到要转成 DOM 的字符串'); }, loadMorePage: function () { if (curSite.pager) { @@ -364,45 +355,53 @@ }, }; } - - - function getElementByXpath(e, t, r) { - r = r || document, t = t || r; - try { - return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } catch (t) { - return void console.error("无效的xpath"); - } + function getElementByCSS(css, contextNode = document) { + return contextNode.querySelector(css); } - - - function getAllElements(e, t, r, n, o) { - let getAllElementsByXpath = function(e, t, r) { - return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - } - - var i, s = []; - if (!e) return s; - if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" == typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) { - return (t || document).querySelectorAll(e); - }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else { - if (!(i = e(r, n, o))) return s; - if (i.nodeType) return s[0] = i, s; - } - return function makeArray(e) { - var t, r, n, o = []; - if (e.pop) { - for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n))); - return a()(o); + function getAllElementsByCSS(css, contextNode = document) { + return [].slice.call(contextNode.querySelectorAll(css)); + } + function getElementByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + try { + const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); + // 应该总是返回一个元素节点 + return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue; + } catch (err) { + throw new Error(`Invalid xpath: ${xpath}`); } - if (e.item) { - for (t = e.length; t;) o[--t] = e[t]; - return o; + } + function getAllElementsByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + const result = []; + try { + const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + for (let i = 0; i < query.snapshotLength; i++) { + const node = query.snapshotItem(i); + // 如果是 Element 节点 + if (node.nodeType === 1) result.push(node); + } + } catch (err) { + throw new Error(`无效 Xpath: ${xpath}`); } - if (e.iterateNext) { - for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t); - return o; + return result; + } + function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) { + if (!selector) return []; + contextNode = contextNode || doc; + if (typeof selector === 'string') { + if (selector.search(/^css;/i) === 0) { + return getAllElementsByCSS(selector.slice(4), contextNode); + } else { + return getAllElementsByXpath(selector, contextNode, doc); + } + } else { + const query = selector(doc, win, _cplink); + if (!Array.isArray(query)) { + throw new Error('getAllElements 返回错误类型'); + } else { + return query; + } } - }(i); } })(); \ No newline at end of file diff --git a/Autopage.user.js b/Autopage.user.js index c5091621d..a30342bee 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.4.5 +// @version 1.4.6 // @author X.I.U // @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、百度、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... // @match *://*/* @@ -674,79 +674,13 @@ } else if (webType === 3) { curSite = DBSite.flarum; } - - curSite.pageUrl = ''; // 下一页URL pageLoading(); // 自动无缝翻页 - // 自动无缝翻页 - function pageLoading() { - if (curSite.SiteTypeID > 0) { - windowScroll(function (direction, e) { - if (direction === 'down') { // 下滑才准备翻页 - let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop, - scrollHeight = window.innerHeight || document.documentElement.clientHeight, - scrollDelta = curSite.pager.scrollDelta; - if (curSite.pager.type === 3) { // 翻页类型 3 - let scrollElement = document.querySelector(curSite.pager.scrollElement); - //console.log(scrollElement.offsetTop - (scrollTop + scrollHeight), scrollDelta, curSite.SiteTypeID) - if (scrollElement.offsetTop - (scrollTop + scrollHeight) <= scrollDelta) { - if (curSite.SiteTypeID === SiteType.GAMERSKY_GL) curSite.pager.scrollDelta -= 800 // 游民星空 gl 的比较奇葩,需要特殊处理下 - ShowPager.loadMorePage(); - } - } else { - if (document.documentElement.scrollHeight <= scrollHeight + scrollTop + scrollDelta) { - if (curSite.pager.type === 2) { // 翻页类型 2 - if (curSite.SiteTypeID > 0) { // 如果指定了间隔时间,那么就依靠这个判断时间到了没有~ - let autopbn = document.querySelector(curSite.pager.nextLink); - if (autopbn) { // 寻找下一页链接 - if (!curSite.pager.nextText) { // 如果没有指定 nextText 就直接点击 - autopbn.click(); - } else if (autopbn.textContent.indexOf(curSite.pager.nextText) > -1){ // 如果指定了 nextText 就需要判断后再点击(避免已经在加载了,还重复点击) - autopbn.click(); - } - // 对于没有按钮文字变化的按钮,可以手动指定间隔时间 - if (curSite.pager.intervals) { - let _SiteTypeID = curSite.SiteTypeID; - curSite.SiteTypeID = 0; - setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals) - } - } - } - } else if (curSite.pager.type === 1) { // 翻页类型 1 - ShowPager.loadMorePage(); - } else if (curSite.pager.type === 4) { // 翻页类型 4 - if (curSite.SiteTypeID > 0) { - curSite.pager.functionNext(); - if (curSite.pager.intervals) { - let _SiteTypeID = curSite.SiteTypeID; - curSite.SiteTypeID = 0; - setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals) - } - } - } - } - } - } - }); - } - } - - - /*function getElementToPageTop(el) { - if(el.parentElement) { - return getElementToPageTop(el.parentElement) + el.offsetTop - } - return el.offsetTop - }*/ - - // 隐藏帖子内的 [下一页] 按钮(Discuz! 论坛) function hidePgbtn() { - let style_hidePgbtn = document.createElement('style'); - style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`; - document.head.appendChild(style_hidePgbtn); + document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}'; } @@ -891,6 +825,68 @@ } + // 自动无缝翻页 + function pageLoading() { + if (curSite.SiteTypeID > 0) { + windowScroll(function (direction, e) { + if (direction === 'down') { // 下滑才准备翻页 + let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop, + scrollHeight = window.innerHeight || document.documentElement.clientHeight, + scrollDelta = curSite.pager.scrollDelta; + if (curSite.pager.type === 3) { // 翻页类型 3 + let scrollElement = document.querySelector(curSite.pager.scrollElement); + //console.log(scrollElement.offsetTop - (scrollTop + scrollHeight), scrollDelta, curSite.SiteTypeID) + if (scrollElement.offsetTop - (scrollTop + scrollHeight) <= scrollDelta) { + if (curSite.SiteTypeID === SiteType.GAMERSKY_GL) curSite.pager.scrollDelta -= 800 // 游民星空 gl 的比较奇葩,需要特殊处理下 + ShowPager.loadMorePage(); + } + } else { + if (document.documentElement.scrollHeight <= scrollHeight + scrollTop + scrollDelta) { + if (curSite.pager.type === 2) { // 翻页类型 2 + if (curSite.SiteTypeID > 0) { // 如果指定了间隔时间,那么就依靠这个判断时间到了没有~ + let autopbn = document.querySelector(curSite.pager.nextLink); + if (autopbn) { // 寻找下一页链接 + if (!curSite.pager.nextText) { // 如果没有指定 nextText 就直接点击 + autopbn.click(); + } else if (autopbn.textContent.indexOf(curSite.pager.nextText) > -1){ // 如果指定了 nextText 就需要判断后再点击(避免已经在加载了,还重复点击) + autopbn.click(); + } + // 对于没有按钮文字变化的按钮,可以手动指定间隔时间 + if (curSite.pager.intervals) { + let _SiteTypeID = curSite.SiteTypeID; + curSite.SiteTypeID = 0; + setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals) + } + } + } + } else if (curSite.pager.type === 1) { // 翻页类型 1 + ShowPager.loadMorePage(); + } else if (curSite.pager.type === 4) { // 翻页类型 4 + if (curSite.SiteTypeID > 0) { + curSite.pager.functionNext(); + if (curSite.pager.intervals) { + let _SiteTypeID = curSite.SiteTypeID; + curSite.SiteTypeID = 0; + setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals) + } + } + } + } + } + } + }); + } + } + + + /*function getElementToPageTop(el) { + if(el.parentElement) { + return getElementToPageTop(el.parentElement) + el.offsetTop + } + return el.offsetTop + }*/ + + // 启用/禁用 (当前网站) function menu_disable(type) { switch(type) { @@ -1014,10 +1010,7 @@ if(e == null) return ''; 'string' != typeof e && (e = e.getAttribute('href')); var t = this.getFullHref.a; - if (t) {return t} - ((this.getFullHref.a = t = document.createElement('a')), t.href = e, t.href) - if (t.href) {return t.href} - //return t || ((this.getFullHref.a = t = document.createElement('a')), t.href = e, t.href); + return t || (this.getFullHref.a = t = document.createElement('a')), (t.href = e), t.href; }, createDocumentByString: function (e) { if (e) { diff --git a/Hostloc-Enhanced.user.js b/Hostloc-Enhanced.user.js index 8718798a0..7d6d361a2 100644 --- a/Hostloc-Enhanced.user.js +++ b/Hostloc-Enhanced.user.js @@ -446,37 +446,6 @@ }*/ - // 自动翻页 - function pageLoading() { - if (!menu_value('menu_pageLoading')) return - if (curSite.SiteTypeID > 0){ - windowScroll(function (direction, e) { - if (direction === "down") { // 下滑才准备翻页 - let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; - if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + 999) { - if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了 - let autopbn = document.querySelector('#autopbn'); - if (autopbn && autopbn.innerText === "下一页 »"){ // 如果已经在加载中了,就忽略 - autopbn.click(); - let timer = setInterval(function(){ // 在下一页加载完成后 - if (document.querySelector('#autopbn').innerText === "下一页 »") { - if (menu_value('menu_delate255')) delate255(); // 隐藏 255 权限帖子 - if (menu_value('menu_blockUsers')) blockUsers('forum'); // 屏蔽用户(黑名单) - if (menu_value('menu_blockKeywords')) blockKeywords(); // 屏蔽关键词(帖子标题) - clearInterval(timer); - } - }, 10); - } - }else{ - ShowPager.loadMorePage(); - } - } - } - }); - } - } - - // 自动显示帖子内被隐藏的回复 function showPosts() { if(menu_value('menu_showhide')){ @@ -550,58 +519,81 @@ } + // 自动翻页 + function pageLoading() { + if (!menu_value('menu_pageLoading')) return + if (curSite.SiteTypeID > 0){ + windowScroll(function (direction, e) { + if (direction === "down") { // 下滑才准备翻页 + let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; + if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + 999) { + if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了 + let autopbn = document.querySelector('#autopbn'); + if (autopbn && autopbn.innerText === "下一页 »"){ // 如果已经在加载中了,就忽略 + autopbn.click(); + let timer = setInterval(function(){ // 在下一页加载完成后 + if (document.querySelector('#autopbn').innerText === "下一页 »") { + if (menu_value('menu_delate255')) delate255(); // 隐藏 255 权限帖子 + if (menu_value('menu_blockUsers')) blockUsers('forum'); // 屏蔽用户(黑名单) + if (menu_value('menu_blockKeywords')) blockKeywords(); // 屏蔽关键词(帖子标题) + clearInterval(timer); + } + }, 10); + } + }else{ + ShowPager.loadMorePage(); + } + } + } + }); + } + } + + // 滚动条事件 function windowScroll(fn1) { var beforeScrollTop = document.documentElement.scrollTop, fn = fn1 || function () {}; setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件 - window.addEventListener("scroll", function (e) { + window.addEventListener('scroll', function (e) { var afterScrollTop = document.documentElement.scrollTop, delta = afterScrollTop - beforeScrollTop; if (delta == 0) return false; - fn(delta > 0 ? "down" : "up", e); + fn(delta > 0 ? 'down' : 'up', e); beforeScrollTop = afterScrollTop; }, false); }, 1000) } - var ShowPager = { // 修改自 https://greasyfork.org/scripts/14178 + // 修改自 https://greasyfork.org/scripts/14178 , https://github.com/machsix/Super-preloader + var ShowPager = { getFullHref: function (e) { if(e == null) return ''; - "string" != typeof e && (e = e.getAttribute("href")); + 'string' != typeof e && (e = e.getAttribute('href')); var t = this.getFullHref.a; - return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href; + return t || (this.getFullHref.a = t = document.createElement('a')), (t.href = e), t.href; }, createDocumentByString: function (e) { if (e) { - if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml"); + if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml'); var t; - try { - t = (new DOMParser).parseFromString(e, "text/html"); - } catch (e) { - } + try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {} if (t) return t; - if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try { - (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), - t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body")); - } catch (e) { + if (document.implementation.createHTMLDocument) { + t = document.implementation.createHTMLDocument('ADocument'); + } else { + try {((t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), t.documentElement.appendChild(t.createElement('head')), t.documentElement.appendChild(t.createElement('body')));} catch (e) {} } if (t) { - var r = document.createRange(); + var r = document.createRange(), + n = r.createContextualFragment(e); r.selectNodeContents(document.body); - var n = r.createContextualFragment(e); t.body.appendChild(n); - for (var a, o = { - TITLE: !0, - META: !0, - LINK: !0, - STYLE: !0, - BASE: !0 - }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); + for (var a, o = { TITLE: !0, META: !0, LINK: !0, STYLE: !0, BASE: !0}, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); return t; } - } else console.error("没有找到要转成DOM的字符串"); + } else console.error('没有找到要转成 DOM 的字符串'); }, loadMorePage: function () { if (curSite.pager) { @@ -657,46 +649,54 @@ } }, }; - - - function getElementByXpath(e, t, r) { - r = r || document, t = t || r; + function getElementByCSS(css, contextNode = document) { + return contextNode.querySelector(css); + } + function getAllElementsByCSS(css, contextNode = document) { + return [].slice.call(contextNode.querySelectorAll(css)); + } + function getElementByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; try { - return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } catch (t) { - return void console.error("无效的xpath"); + const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); + // 应该总是返回一个元素节点 + return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue; + } catch (err) { + throw new Error(`Invalid xpath: ${xpath}`); } } - - - function getAllElements(e, t, r, n, o) { - let getAllElementsByXpath = function(e, t, r) { - return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - } - - var i, s = []; - if (!e) return s; - if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" == typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) { - return (t || document).querySelectorAll(e); - }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else { - if (!(i = e(r, n, o))) return s; - if (i.nodeType) return s[0] = i, s; - } - return function makeArray(e) { - var t, r, n, o = []; - if (e.pop) { - for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n))); - return a()(o); + function getAllElementsByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + const result = []; + try { + const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + for (let i = 0; i < query.snapshotLength; i++) { + const node = query.snapshotItem(i); + // 如果是 Element 节点 + if (node.nodeType === 1) result.push(node); } - if (e.item) { - for (t = e.length; t;) o[--t] = e[t]; - return o; + } catch (err) { + throw new Error(`无效 Xpath: ${xpath}`); + } + return result; + } + function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) { + if (!selector) return []; + contextNode = contextNode || doc; + if (typeof selector === 'string') { + if (selector.search(/^css;/i) === 0) { + return getAllElementsByCSS(selector.slice(4), contextNode); + } else { + return getAllElementsByXpath(selector, contextNode, doc); } - if (e.iterateNext) { - for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t); - return o; + } else { + const query = selector(doc, win, _cplink); + if (!Array.isArray(query)) { + throw new Error('getAllElements 返回错误类型'); + } else { + return query; } - }(i); + } } diff --git a/V2ex-Enhanced.user.js b/V2ex-Enhanced.user.js index 2990d69b5..77698ece1 100644 --- a/V2ex-Enhanced.user.js +++ b/V2ex-Enhanced.user.js @@ -89,7 +89,7 @@ pageElement: 'css;.cell.item', HT_insert: ['//div[@id="Main"]//div[@class="box"]//div[@class="cell"][last()]', 1], replaceE: 'css;#Main > .box > .cell[style]:not(.item) > table', - scrollDelta: 1000 + scrollDelta: 1500 }, function: { after: linksBlank, @@ -104,7 +104,7 @@ pageElement: 'css;#notifications > div', HT_insert: ['css;#notifications', 3], replaceE: 'css;#Main > .box > .cell[style] > table', - scrollDelta: 1000 + scrollDelta: 1500 }, function: { after: linksBlank, @@ -119,7 +119,7 @@ pageElement: '//div[@id="Main"]//div[@class="box"]//div[@class="dock_area"] | //*[@id="Main"]//div[@class="box"]//div[@class="inner"] | //*[@id="Main"]//div[@class="box"]//div[@class="dock_area"][last()]/following-sibling::div[@class="cell"][1]', HT_insert: ['//div[@id="Main"]//div[@class="box"]//div[@class="cell"][last()]', 1], replaceE: 'css;#Main > .box > .cell[style] > table', - scrollDelta: 1000 + scrollDelta: 1500 }, function: { after: linksBlank, @@ -134,7 +134,7 @@ pageElement: 'css;#TopicsNode > div', HT_insert: ['css;#TopicsNode', 3], replaceE: 'css;#Main > .box > .cell[style] > table', - scrollDelta: 1000 + scrollDelta: 1500 }, function: { after: linksBlank, @@ -149,7 +149,7 @@ pageElement: 'css;.cell[id^="r_"]', HT_insert: ['//div[starts-with(@id, "r_")][last()]/following-sibling::div[@class="cell"][1]', 1], replaceE: 'css;#Main > .box > .cell[style] > table', - scrollDelta: 1000 + scrollDelta: 1500 } }, reply_positive: { // 帖子内容页(正序) @@ -160,7 +160,7 @@ pageElement: 'css;.cell[id^="r_"]', HT_insert: ['//div[starts-with(@id, "r_")][1]', 1], replaceE: 'css;#Main > .box > .cell[style] > table', - scrollDelta: 1000 + scrollDelta: 1500 } }, balance: { // 账户余额页 @@ -171,7 +171,7 @@ pageElement: '//div[@id="Main"]//div[@class="cell"][last()]/preceding-sibling::div[1]//tr[position()>1]', HT_insert: ['//div[@id="Main"]//div[@class="cell"][last()]/preceding-sibling::div[1]//tr[last()]', 4], replaceE: 'css;#Main > .box > .cell[style] > table', - scrollDelta: 700 + scrollDelta: 1000 } } }; @@ -366,7 +366,7 @@ function pageLoading() { if (curSite.SiteTypeID > 0){ windowScroll(function (direction, e) { - if (direction === "down") { // 下滑才准备翻页 + if (direction === 'down') { // 下滑才准备翻页 let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; //console.log(document.documentElement.scrollHeight) let scrollDelta = curSite.pager.scrollDelta; @@ -391,59 +391,51 @@ var beforeScrollTop = document.documentElement.scrollTop, fn = fn1 || function () {}; setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件 - window.addEventListener("scroll", function (e) { + window.addEventListener('scroll', function (e) { var afterScrollTop = document.documentElement.scrollTop, delta = afterScrollTop - beforeScrollTop; if (delta == 0) return false; - fn(delta > 0 ? "down" : "up", e); + fn(delta > 0 ? 'down' : 'up', e); beforeScrollTop = afterScrollTop; }, false); }, 1000) } - var ShowPager = { // 修改自 https://greasyfork.org/scripts/14178 + // 修改自 https://greasyfork.org/scripts/14178 , https://github.com/machsix/Super-preloader + var ShowPager = { getFullHref: function (e) { if(e == null) return ''; - "string" != typeof e && (e = e.getAttribute("href")); + 'string' != typeof e && (e = e.getAttribute('href')); var t = this.getFullHref.a; - return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href; + return t || (this.getFullHref.a = t = document.createElement('a')), (t.href = e), t.href; }, createDocumentByString: function (e) { if (e) { - if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml"); + if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml'); var t; - try { - t = (new DOMParser).parseFromString(e, "text/html"); - } catch (e) { - } + try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {} if (t) return t; - if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try { - (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), - t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body")); - } catch (e) { + if (document.implementation.createHTMLDocument) { + t = document.implementation.createHTMLDocument('ADocument'); + } else { + try {((t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), t.documentElement.appendChild(t.createElement('head')), t.documentElement.appendChild(t.createElement('body')));} catch (e) {} } if (t) { - var r = document.createRange(); + var r = document.createRange(), + n = r.createContextualFragment(e); r.selectNodeContents(document.body); - var n = r.createContextualFragment(e); t.body.appendChild(n); - for (var a, o = { - TITLE: !0, - META: !0, - LINK: !0, - STYLE: !0, - BASE: !0 - }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); + for (var a, o = { TITLE: !0, META: !0, LINK: !0, STYLE: !0, BASE: !0}, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); return t; } - } else console.error("没有找到要转成DOM的字符串"); + } else console.error('没有找到要转成 DOM 的字符串'); }, loadMorePage: function () { if (curSite.pager) { let curPageEle = getElementByXpath(curSite.pager.nextLink); var url = this.getFullHref(curPageEle); - //console.log(`${url} ${curPageEle} ${curSite.pageUrl}`); + console.log(`${url} ${curPageEle} ${curSite.pageUrl}`); if(url === '') return; if(curSite.pageUrl === url) return;// 不会重复加载相同的页面 curSite.pageUrl = url; @@ -516,45 +508,53 @@ } }, }; - - - function getElementByXpath(e, t, r) { - r = r || document, t = t || r; + function getElementByCSS(css, contextNode = document) { + return contextNode.querySelector(css); + } + function getAllElementsByCSS(css, contextNode = document) { + return [].slice.call(contextNode.querySelectorAll(css)); + } + function getElementByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; try { - return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } catch (t) { - return void console.error("无效的xpath"); + const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); + // 应该总是返回一个元素节点 + return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue; + } catch (err) { + throw new Error(`Invalid xpath: ${xpath}`); } } - - - function getAllElements(e, t, r, n, o) { - let getAllElementsByXpath = function(e, t, r) { - return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - } - - var i, s = []; - if (!e) return s; - if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" == typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) { - return (t || document).querySelectorAll(e); - }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else { - if (!(i = e(r, n, o))) return s; - if (i.nodeType) return s[0] = i, s; - } - return function makeArray(e) { - var t, r, n, o = []; - if (e.pop) { - for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n))); - return a()(o); + function getAllElementsByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + const result = []; + try { + const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + for (let i = 0; i < query.snapshotLength; i++) { + const node = query.snapshotItem(i); + // 如果是 Element 节点 + if (node.nodeType === 1) result.push(node); } - if (e.item) { - for (t = e.length; t;) o[--t] = e[t]; - return o; + } catch (err) { + throw new Error(`无效 Xpath: ${xpath}`); + } + return result; + } + function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) { + if (!selector) return []; + contextNode = contextNode || doc; + if (typeof selector === 'string') { + if (selector.search(/^css;/i) === 0) { + return getAllElementsByCSS(selector.slice(4), contextNode); + } else { + return getAllElementsByXpath(selector, contextNode, doc); } - if (e.iterateNext) { - for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t); - return o; + } else { + const query = selector(doc, win, _cplink); + if (!Array.isArray(query)) { + throw new Error('getAllElements 返回错误类型'); + } else { + return query; } - }(i); + } } })(); \ No newline at end of file diff --git a/Zhiyoo-Enhanced.user.js b/Zhiyoo-Enhanced.user.js index ad0f0cae1..7b8e267d3 100644 --- a/Zhiyoo-Enhanced.user.js +++ b/Zhiyoo-Enhanced.user.js @@ -248,23 +248,6 @@ } - // 自动无缝翻页 - function pageLoading() { - if (!menu_value('menu_pageLoading')) return - if (curSite.SiteTypeID > 0){ - windowScroll(function (direction, e) { - if (direction === "down") { // 下滑才准备翻页 - let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; - let scrollDelta = 666; - if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) { - ShowPager.loadMorePage(); - } - } - }); - } - } - - // 回到顶部(右键点击空白处) function backToTop() { if (!menu_value('menu_backToTop')) return @@ -333,58 +316,67 @@ } + // 自动无缝翻页 + function pageLoading() { + if (!menu_value('menu_pageLoading')) return + if (curSite.SiteTypeID > 0){ + windowScroll(function (direction, e) { + if (direction === 'down') { // 下滑才准备翻页 + let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; + let scrollDelta = 666; + if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) { + ShowPager.loadMorePage(); + } + } + }); + } + } + + // 滚动条事件 function windowScroll(fn1) { var beforeScrollTop = document.documentElement.scrollTop, fn = fn1 || function () {}; setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件 - window.addEventListener("scroll", function (e) { + window.addEventListener('scroll', function (e) { var afterScrollTop = document.documentElement.scrollTop, delta = afterScrollTop - beforeScrollTop; if (delta == 0) return false; - fn(delta > 0 ? "down" : "up", e); + fn(delta > 0 ? 'down' : 'up', e); beforeScrollTop = afterScrollTop; }, false); }, 1000) } - var ShowPager = { // 修改自 https://greasyfork.org/scripts/14178 + // 修改自 https://greasyfork.org/scripts/14178 , https://github.com/machsix/Super-preloader + var ShowPager = { getFullHref: function (e) { if(e == null) return ''; - "string" != typeof e && (e = e.getAttribute("href")); + 'string' != typeof e && (e = e.getAttribute('href')); var t = this.getFullHref.a; - return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href; + return t || (this.getFullHref.a = t = document.createElement('a')), (t.href = e), t.href; }, createDocumentByString: function (e) { if (e) { - if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml"); + if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml'); var t; - try { - t = (new DOMParser).parseFromString(e, "text/html"); - } catch (e) { - } + try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {} if (t) return t; - if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try { - (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), - t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body")); - } catch (e) { + if (document.implementation.createHTMLDocument) { + t = document.implementation.createHTMLDocument('ADocument'); + } else { + try {((t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), t.documentElement.appendChild(t.createElement('head')), t.documentElement.appendChild(t.createElement('body')));} catch (e) {} } if (t) { - var r = document.createRange(); + var r = document.createRange(), + n = r.createContextualFragment(e); r.selectNodeContents(document.body); - var n = r.createContextualFragment(e); t.body.appendChild(n); - for (var a, o = { - TITLE: !0, - META: !0, - LINK: !0, - STYLE: !0, - BASE: !0 - }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); + for (var a, o = { TITLE: !0, META: !0, LINK: !0, STYLE: !0, BASE: !0}, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a); return t; } - } else console.error("没有找到要转成DOM的字符串"); + } else console.error('没有找到要转成 DOM 的字符串'); }, loadMorePage: function () { if (curSite.pager) { @@ -435,57 +427,65 @@ } }, }; - - - function getElementByXpath(e, t, r) { - r = r || document, t = t || r; - try { - return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } catch (t) { - return void console.error("无效的xpath"); - } + function getElementByCSS(css, contextNode = document) { + return contextNode.querySelector(css); } - - - function getAllElements(e, t, r, n, o) { - let getAllElementsByXpath = function(e, t, r) { - return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - } - - var i, s = []; - if (!e) return s; - if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" == typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) { - return (t || document).querySelectorAll(e); - }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else { - if (!(i = e(r, n, o))) return s; - if (i.nodeType) return s[0] = i, s; - } - return function makeArray(e) { - var t, r, n, o = []; - if (e.pop) { - for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n))); - return a()(o); + function getAllElementsByCSS(css, contextNode = document) { + return [].slice.call(contextNode.querySelectorAll(css)); + } + function getElementByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + try { + const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); + // 应该总是返回一个元素节点 + return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue; + } catch (err) { + throw new Error(`Invalid xpath: ${xpath}`); } - if (e.item) { - for (t = e.length; t;) o[--t] = e[t]; - return o; + } + function getAllElementsByXpath(xpath, contextNode, doc = document) { + contextNode = contextNode || doc; + const result = []; + try { + const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + for (let i = 0; i < query.snapshotLength; i++) { + const node = query.snapshotItem(i); + // 如果是 Element 节点 + if (node.nodeType === 1) result.push(node); + } + } catch (err) { + throw new Error(`无效 Xpath: ${xpath}`); + } + return result; + } + function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) { + if (!selector) return []; + contextNode = contextNode || doc; + if (typeof selector === 'string') { + if (selector.search(/^css;/i) === 0) { + return getAllElementsByCSS(selector.slice(4), contextNode); + } else { + return getAllElementsByXpath(selector, contextNode, doc); + } + } else { + const query = selector(doc, win, _cplink); + if (!Array.isArray(query)) { + throw new Error('getAllElements 返回错误类型'); + } else { + return query; + } } - if (e.iterateNext) { - for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t); - return o; + } + + + // 获取GET参数 + function getQueryVariable(variable) { + var query = window.location.search.substring(1); + var vars = query.split("&"); + for (var i=0;i Date: Sat, 7 Aug 2021 18:21:02 +0800 Subject: [PATCH 0036/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[GreasyFork]=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 81 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 20 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index a30342bee..1700eb9f8 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.4.6 +// @version 1.4.7 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、百度、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、AlphaCoders、FitGirl Repacks... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、百度、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、GreasyFork、AlphaCoders、FitGirl Repacks... // @match *://*/* // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png @@ -26,9 +26,7 @@ 'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', 'www.423down.com', 'apphot.cc', 'iao.su', 'www.ypojie.com', 'www.appinn.com', 'www.weidown.com', 'www.luochenzhimu.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com', 'www.gufengmh8.com', - 'rarbgprx.org', - 'pubmed.ncbi.nlm.nih.gov', - 'www.afreecatv.com', + 'rarbgprx.org', 'pubmed.ncbi.nlm.nih.gov', 'www.afreecatv.com', 'greasyfork.org', 'art.alphacoders.com', 'wall.alphacoders.com', 'avatars.alphacoders.com', 'mobile.alphacoders.com', 'fitgirl-repacks.site']; @@ -433,6 +431,18 @@ scrollDelta: 1000 } }, + gufengmh8: { + SiteTypeID: 0, + pager: { + type: 4, + pageElement: 'css;body > script:first-child', + HT_insert: ['css;#images', 3], + intervals: 5000, + functionNext: gufengmh8_functionNext, + functionAdd: gufengmh8_functionAdd, + scrollDelta: 2333 + } + }, rarbgprx: { SiteTypeID: 0, pager: { @@ -462,6 +472,39 @@ scrollDelta: 1000 } }, + greasyfork: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//a[@class="next_page"][@href]', + pageElement: 'css;ol#browse-script-list > li', + HT_insert: ['css;ol#browse-script-list', 3], + replaceE: 'css;.pagination', + scrollDelta: 1000 + } + }, + greasyfork_feedback: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//a[@class="next_page"][@href]', + pageElement: 'css;.script-discussion-list > div', + HT_insert: ['css;.script-discussion-list', 3], + replaceE: 'css;.pagination', + scrollDelta: 1500 + } + }, + greasyfork_discussions: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//a[@class="next_page"][@href]', + pageElement: 'css;.discussion-list > div', + HT_insert: ['css;.discussion-list', 3], + replaceE: 'css;.pagination', + scrollDelta: 1000 + } + }, alphacoders_art: { SiteTypeID: 0, pager: { @@ -497,18 +540,6 @@ replaceE: 'css;nav.navigation.paging-navigation', scrollDelta: 2000 } - }, - gufengmh8: { - SiteTypeID: 0, - pager: { - type: 4, - pageElement: 'css;body > script:first-child', - HT_insert: ['css;#images', 3], - intervals: 5000, - functionNext: gufengmh8_functionNext, - functionAdd: gufengmh8_functionAdd, - scrollDelta: 2333 - } } }; // 生成 SiteTypeID @@ -534,9 +565,9 @@ if (location.pathname === '/s') curSite = DBSite.baidu; break; case 'movie.douban.com': // < 豆瓣评论 > - if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评 + if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评列表 curSite = DBSite.douban_subject_comments; - } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评 + } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评列表 curSite = DBSite.douban_subject_reviews; } else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论 curSite = DBSite.douban_subject_episode; @@ -616,6 +647,15 @@ case 'www.afreecatv.com': // < 直播网站 > curSite = DBSite.afreecatv; break; + case 'greasyfork.org': // < GreasyFork > + if (location.pathname.indexOf('/scripts') + 8 === location.pathname.length) { + curSite = DBSite.greasyfork; + } else if (location.pathname.lastIndexOf('/feedback') + 9 === location.pathname.length) { + curSite = DBSite.greasyfork_feedback; + } else if (location.pathname.lastIndexOf('/discussions') + 12 === location.pathname.length) { + curSite = DBSite.greasyfork_discussions; + } + break; case 'art.alphacoders.com': // < 壁纸网站 > curSite = DBSite.alphacoders_art; setTimeout(alphacoders_art_beforeFunction_0, 1000); @@ -1049,10 +1089,11 @@ timeout: 5000, onload: function (response) { try { - //console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText) + console.log('最终 URL:' + response.finalUrl, '返回内容:' + newBody) var newBody = ShowPager.createDocumentByString(response.responseText); let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody), toElement = getAllElements(curSite.pager.HT_insert[0])[0]; + //console.log(curSite.pager.pageElement, pageElems) if (pageElems.length >= 0) { // 如果有插入前函数就执行函数 From 74593211216ab2c9c6a7c246a59ed251e09b5f5a Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sat, 7 Aug 2021 23:41:59 +0800 Subject: [PATCH 0037/2043] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20[Steam=20?= =?UTF-8?q?=E5=88=9B=E6=84=8F=E5=B7=A5=E5=9D=8A]=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Autopage.user.js | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/Autopage.user.js b/Autopage.user.js index 1700eb9f8..ee2265b03 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -1,8 +1,8 @@ // ==UserScript== // @name 自动无缝翻页 -// @version 1.4.7 +// @version 1.4.8 // @author X.I.U -// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、百度、豆瓣、微博、千图网、3DM、游侠网、游民星空、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、GreasyFork、AlphaCoders、FitGirl Repacks... +// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、百度、豆瓣、微博、千图网、3DM、游侠网、游民星空、Steam 创意工坊、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、GreasyFork、AlphaCoders、FitGirl Repacks... // @match *://*/* // @connect www.gamersky.com // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png @@ -23,7 +23,7 @@ var webType, curSite = {SiteTypeID: 0}; // 目前支持的网站 const websiteList = ['www.baidu.com', 'movie.douban.com', 'weibo.com', 'www.58pic.com', - 'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', + 'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', 'steamcommunity.com', 'www.423down.com', 'apphot.cc', 'iao.su', 'www.ypojie.com', 'www.appinn.com', 'www.weidown.com', 'www.luochenzhimu.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com', 'www.gufengmh8.com', 'rarbgprx.org', 'pubmed.ncbi.nlm.nih.gov', 'www.afreecatv.com', 'greasyfork.org', @@ -306,6 +306,17 @@ before: gamersky_gl_beforeFunction } }, + steamcommunity: { + SiteTypeID: 0, + pager: { + type: 1, + nextLink: '//a[@class="pagebtn"][last()][@href]', + pageElement: 'css;.workshopBrowseItems > *', + HT_insert: ['css;.workshopBrowseItems', 3], + replaceE: 'css;.workshopBrowsePaging', + scrollDelta: 1000 + } + }, _423down: { SiteTypeID: 0, pager: { @@ -547,7 +558,8 @@ // 用于脚本判断(针对部分特殊的网站) const SiteType = { - GAMERSKY_GL: DBSite.gamersky_gl.SiteTypeID + GAMERSKY_GL: DBSite.gamersky_gl.SiteTypeID, + STEAMCOMMUNITY: DBSite.steamcommunity.SiteTypeID }; @@ -600,6 +612,9 @@ curSite = DBSite.gamersky_gl; } break; + case 'steamcommunity.com': // < Steam 创意工坊 > + curSite = DBSite.steamcommunity; + break; case 'www.423down.com': // < 423down > if (location.pathname.indexOf('.html') === -1) curSite = DBSite._423down; break; @@ -1089,7 +1104,7 @@ timeout: 5000, onload: function (response) { try { - console.log('最终 URL:' + response.finalUrl, '返回内容:' + newBody) + //console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText) var newBody = ShowPager.createDocumentByString(response.responseText); let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody), toElement = getAllElements(curSite.pager.HT_insert[0])[0]; @@ -1108,9 +1123,19 @@ // 插入位置 let addTo1 = addTo(curSite.pager.HT_insert[1]); // 插入新页面元素 - pageElems.forEach(function (one) { - toElement.insertAdjacentElement(addTo1, one); - }); + if (curSite.SiteTypeID === SiteType.STEAMCOMMUNITY) { + pageElems.forEach(function (one) { + if (one.tagName === 'SCRIPT') { // 对于