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 0001/2015] =?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 0002/2015] =?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 0003/2015] =?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 0004/2015] 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 0005/2015] 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 0006/2015] 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 0007/2015] =?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 0008/2015] =?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 0009/2015] =?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') { // 对于