Skip to content

Commit 5699801

Browse files
committed
新增 [插画世界 (vilipix)] 支持; 调整 [Pixiv] 规则翻页模式; 优化 翻页模式 5 (滚动条效果)
1 parent 03446bb commit 5699801

1 file changed

Lines changed: 95 additions & 33 deletions

File tree

Autopage.user.js

Lines changed: 95 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 自动无缝翻页
3-
// @version 3.6.0
3+
// @version 3.6.1
44
// @author X.I.U
55
// @description 无缝拼接下一页内容(瀑布流),目前支持:[所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、DUX/XIU/D8/Begin(WP主题)」网站]、百度、谷歌、必应、搜狗、头条搜索、360 搜索、微信搜索、贴吧、豆瓣、微博、NGA、V2EX、B 站(Bilibili)、Pixiv、蓝奏云、煎蛋网、糗事百科、龙的天空、起点小说、IT之家、千图网、Pixabay、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、片库、茶杯狐、NO视频、低端影视、奈菲影视、音范丝、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE 动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、极简插件、小众软件、动漫狂、漫画猫、漫画 DB、动漫之家、拷贝漫画、包子漫画、古风漫画网、Mangabz、PubMed、GreasyFork、Github、StackOverflow(以上仅一小部分,更多的写不下了...
66
// @match *://*/*
@@ -1327,31 +1327,33 @@
13271327
functionStart: function() {locationChange = true;
13281328
if (location.pathname == '/') {
13291329
forceTarget();
1330-
} else if (indexOF('/tags/') && self == top) {
1330+
} else if (indexOF('/tags/')/* && self == top*/) {
13311331
curSite = DBSite.pixiv;
1332-
if (indexOF('/novels')) {insStyle('ul[class*="-1 "] > li {display: inline !important;}')} else {insStyle('a[href^="/premium/lead/lp"], div[class*="-0 "] > div[class*="-4 "] > section:first-of-type {display: none}');}
1332+
if (!indexOF('/novels'))insStyle('a[href^="/premium/lead/lp"], div[class*="-0 "] > div[class*="-4 "] > section:first-of-type {display: none}');
13331333
} else if (indexOF('/users/') && /\/(artworks|illustrations|manga)/.test(location.pathname)) {
13341334
curSite = DBSite.pixiv_user;
13351335
} else if (indexOF('/artworks/')) {
13361336
setTimeout(function(){getXpath('//button[contains(string(), "查看全部") or contains(string(), "See all") or contains(string(), "すべて見る") or contains(string(), "모두 보기")]').click();}, 1000)
13371337
}
13381338
},
13391339
forceTarget: true,
1340+
hiddenPN: true,
13401341
iframe: true,
1342+
insStyle: 'ul[class*="-1 "] > li {display: inline !important;} #root{margin-bottom: -175px;}',
13411343
pager: {
1342-
type: 6,
1344+
type: 5,
13431345
nextL: 'css;a[aria-disabled="false"][class*="filterProps-Styled-Component"][href]:last-child',
13441346
pageE: '//ul[contains(@class, "-1 ")]/li',
13451347
insertP: ['//ul[contains(@class, "-1 ")]', 3],
13461348
replaceE: '//nav[./a[@aria-disabled="false"][contains(@class, "filterProps-Styled-Component")]]',
13471349
history: function() {if (/p=\d+/.test(location.search)) {return false;} else {return true;}},
1348-
loadTime: 1000,
1349-
scrollD: 1000
1350+
scrollD: 2000
13501351
}
13511352
}, // Pixiv - 分类页
13521353
pixiv_user: {
13531354
forceTarget: true,
13541355
hiddenPN: true,
1356+
insStyle: 'ul[class*="-1 "] > li {display: inline !important;} #root{margin-bottom: -125px;}',
13551357
pager: {
13561358
type: 5,
13571359
nextL: 'css;a[aria-disabled="false"][class*="filterProps-Styled-Component"][href]:last-child',
@@ -1362,6 +1364,27 @@
13621364
scrollD: 2000
13631365
}
13641366
}, // Pixiv - 用户作品页
1367+
vilipix: {
1368+
host: 'www.vilipix.com',
1369+
functionStart: function() {locationChange = true;
1370+
if (location.pathname == '/') {
1371+
forceTarget();
1372+
} else if (indexOF('/tags/') || indexOF('/user/') || indexOF('/new') || indexOF('/ranking')) {
1373+
curSite = DBSite.vilipix;
1374+
}
1375+
},
1376+
forceTarget: true,
1377+
pager: {
1378+
type: 6,
1379+
nextL: function() {let next = getCSS('li.number.active+li.number'); if (next) {return (location.origin + location.pathname + '?p=' + next.textContent)} else {return '';}},
1380+
pageE: 'css;ul.illust-content > li',
1381+
insertP: ['css;ul.illust-content', 3],
1382+
replaceE: 'css;ul.el-pager',
1383+
history: function() {if (/p=\d+/.test(location.search)) {return false;} else {return true;}},
1384+
loadTime: 800,
1385+
scrollD: 2000
1386+
}
1387+
}, // vilipix
13651388
_58pic: {
13661389
host: 'www.58pic.com',
13671390
functionStart: function() {insStyle('.qt-model-t.login-model {display: none !important;}');
@@ -4875,6 +4898,24 @@
48754898
}
48764899
if (curSite.insStyle) insStyle(curSite.insStyle)
48774900

4901+
// 对翻页模式 5 的子 iframe 添加一个跟随滚动的事件
4902+
if (curSite.pager.type === 5 && self != top) {
4903+
var beforeScrollTop = document.documentElement.scrollTop || document.body.scrollTop
4904+
window.addEventListener('scroll', function (e) {
4905+
let scrollTop = window.parent.document.documentElement.scrollTop || window.parent.document.body.scrollTop,
4906+
clientHeight = window.parent.document.documentElement.clientHeight || window.parent.document.body.clientHeight,
4907+
scrollHeight = window.parent.document.documentElement.scrollHeight || window.parent.document.body.scrollHeight,
4908+
afterScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
4909+
delta = afterScrollTop - beforeScrollTop;
4910+
if (delta == 0) return false;
4911+
beforeScrollTop = afterScrollTop;
4912+
//console.log(delta, scrollHeight - (scrollTop + clientHeight), '2222')
4913+
if (delta > 0 && scrollTop + clientHeight < scrollHeight) {
4914+
window.parent.scrollBy(0, delta*2);
4915+
}
4916+
}, false);
4917+
}
4918+
48784919
curSite.pageUrl = ''; // 下一页URL
48794920
//console.log(curSite);
48804921
pageLoading(); // 自动无缝翻页
@@ -5778,15 +5819,21 @@
57785819
// <<<<< 翻页类型 5(插入 iframe 方式来加载下一页)>>>>>
57795820
} else if (curSite.pager.type === 5) {
57805821
if (typeof curSite.pager.nextL == 'function') {
5781-
curSite.pager.nextL();
5822+
let tempUrl = curSite.pager.nextL();
5823+
if (tempUrl === '' || curSite.pageUrl === tempUrl) return;
5824+
curSite.pageUrl = tempUrl;
5825+
insIframe(curSite.pageUrl);
57825826
} else if (getE_nextL(curSite.pager.nextL)) {
57835827
insIframe(curSite.pageUrl);
57845828
}
57855829

57865830
// <<<<< 翻页类型 6(通过 iframe 获取下一页动态加载内容)>>>>>
57875831
} else if (curSite.pager.type === 6) {
57885832
if (typeof curSite.pager.nextL == 'function') {
5789-
curSite.pager.nextL();
5833+
let tempUrl = curSite.pager.nextL();
5834+
if (tempUrl === '' || curSite.pageUrl === tempUrl) return;
5835+
curSite.pageUrl = tempUrl;
5836+
insIframe_(curSite.pageUrl);
57905837
} else if (getE_nextL(curSite.pager.nextL)) {
57915838
insIframe_(curSite.pageUrl);
57925839
}
@@ -5807,25 +5854,30 @@
58075854
// 翻页类型 5(插入 iframe 方式加载下一页)
58085855
function insIframe(src) {
58095856
// 停用当前页面翻页
5857+
if (!pausePage) return
58105858
curSite.SiteTypeID = 0;
5859+
pausePage = false
5860+
5861+
var beforeScrollTop = document.documentElement.scrollTop || document.body.scrollTop
58115862
// 当滚动条到底部时(即完全显示 iframe 框架),隐藏当前页面的滚动条
5812-
window.addEventListener('scroll', function (e) {
5863+
window.addEventListener('scroll', function () {
58135864
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
5865+
clientHeight = document.documentElement.clientHeight || document.body.clientHeight,
58145866
scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight,
5815-
clientHeight = document.documentElement.clientHeight || document.body.clientHeight
5816-
if (scrollTop + clientHeight + 10 >= scrollHeight) {
5817-
if (!getCSS('#xiu-scroll')) {
5818-
let newStyle = document.createElement('style'); newStyle.id = 'xiu-scroll';
5819-
newStyle.textContent = 'html::-webkit-scrollbar {width: 0 !important;height: 0 !important;} html {scrollbar-width: none !important;}';
5820-
if (curSite.pager.insStyle) newStyle.textContent += curSite.pager.insStyle;
5821-
document.lastElementChild.appendChild(newStyle);
5822-
}
5823-
} else {
5824-
if (getCSS('#xiu-scroll')) {
5825-
getCSS('#xiu-scroll').remove();
5826-
}
5867+
afterScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
5868+
delta = afterScrollTop - beforeScrollTop;
5869+
if (delta == 0) return false;
5870+
beforeScrollTop = afterScrollTop;
5871+
5872+
//console.log(delta, scrollHeight - (scrollTop + clientHeight + 10), '1111')
5873+
if (delta > 0 && scrollTop + clientHeight + 10 >= scrollHeight && !getCSS('#xiu-scroll')) {
5874+
let newStyle = document.createElement('style'); newStyle.id = 'xiu-scroll';
5875+
newStyle.textContent = 'html::-webkit-scrollbar {width: 0 !important;height: 0 !important;} html {scrollbar-width: none !important;}';
5876+
if (curSite.pager.insStyle) newStyle.textContent += curSite.pager.insStyle;
5877+
document.lastElementChild.appendChild(newStyle);
5878+
} else if (delta < 0 && getCSS('#xiu-scroll')) {
5879+
getCSS('#xiu-scroll').remove();
58275880
}
5828-
//console.log(`${scrollTop} + ${clientHeight} >= ${scrollTop + clientHeight} / ${scrollHeight}`)
58295881
}, false);
58305882

58315883
// 创建 iframe
@@ -5854,28 +5906,38 @@
58545906
pausePage = false
58555907

58565908
// 如果不存在,则创建一个 iframe
5857-
let iframe = document.getElementById('xiu2_iframe');
5909+
let iframe = document.getElementById('xiu_iframe');
58585910
if (!iframe) {
58595911
iframe = document.createElement('iframe');
5860-
iframe.style = 'position: absolute; width: 100%; height: 100%; border: none; display: none;';
5861-
iframe.id = 'xiu2_iframe';
5912+
iframe.style = 'position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; border: none; z-index: -999; /*visibility: hidden;*/';
5913+
iframe.id = 'xiu_iframe';
58625914
iframe.src = src;
58635915
}
58645916

58655917
// 加载完成后才继续
58665918
iframe.onload = function() {
5867-
iframe.contentWindow.scrollTo(0, 999999); // 滚动到底部,以触发网页的滚动条相关加载事件
5919+
//iframe.contentWindow.scrollTo(0, 999999); // 滚动到底部,以触发网页的滚动条相关加载事件
58685920
//iframe.contentWindow.scrollTo({top: 9999999, behavior: 'smooth'});
58695921
if (!curSite.pager.loadTime) curSite.pager.loadTime = 100; // 默认 100ms
5870-
setTimeout(function() {
5871-
//console.log(getOne(curSite.pager.insertP[0], iframe.contentWindow.document))
5872-
processResult(iframe.contentWindow.document); // 插入/替换元素等
5873-
pausePage = true; // 恢复翻页
5874-
}, curSite.pager.loadTime) // 预留加载时间,确保网页加载完成
5922+
//console.log(curSite.pager.loadTime, curSite.pager.loadTime/30)
5923+
console.time('sort');
5924+
let time1 = 0 ,time2 = setInterval(function(){
5925+
let scrollHeight = (iframe.contentWindow.document.documentElement.scrollHeight || iframe.contentWindow.document.body.scrollHeight)/10
5926+
iframe.contentWindow.scrollTo(0, 999999);
5927+
iframe.contentWindow.scrollTo(0, scrollHeight*time1);
5928+
//console.log(time1, iframe.contentWindow.document.documentElement.scrollHeight || iframe.contentWindow.document.body.scrollHeight)
5929+
if (++time1 == 10) {
5930+
console.timeEnd('sort');
5931+
clearInterval(time2);
5932+
processResult(iframe.contentWindow.document); // 插入/替换元素等
5933+
//console.log(iframe.contentWindow.document.documentElement.scrollHeight || iframe.contentWindow.document.body.scrollHeight)
5934+
pausePage = true; // 恢复翻页
5935+
}
5936+
}, curSite.pager.loadTime/10)
58755937
}
58765938

58775939
// 插入 iframe(如果已存在则直接改 src)
5878-
if (document.getElementById('xiu2_iframe')) {
5940+
if (document.getElementById('xiu_iframe')) {
58795941
iframe.src = src;
58805942
} else {
58815943
document.lastElementChild.appendChild(iframe);
@@ -5950,7 +6012,7 @@
59506012
}
59516013

59526014

5953-
// 翻页类型 1/3 // 修改自 https://greasyfork.org/scripts/14178 、 https://github.com/machsix/Super-preloader
6015+
// 翻页类型 1/3 修改自 https://greasyfork.org/scripts/14178 、 https://github.com/machsix/Super-preloader
59546016
var ShowPager = {
59556017
getFullHref: function (e) {
59566018
if (e != null && e.nodeType === 1 && e.href && e.href.slice(0,4) === 'http') return e.href;

0 commit comments

Comments
 (0)