Skip to content

Commit bb3a5f5

Browse files
committed
优化 [添加历史记录] 功能
1 parent c7f62f8 commit bb3a5f5

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

Autopage.user.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:zh-CN 自动无缝翻页
44
// @name:zh-TW 自動無縫翻頁
55
// @name:en AutoPager
6-
// @version 5.2.2
6+
// @version 5.2.3
77
// @author X.I.U
88
// @description ⭐无缝衔接下一页内容到网页底部(类似瀑布流)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、微博、NGA、V2EX、B 站(Bilibili)、煎蛋网、龙的天空、起点中文、IT之家、千图网、千库网、Pixabay、Pixiv、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE 动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、小众软件、【动漫狂、漫画猫、漫画屋、漫画 DB、动漫之家、拷贝漫画、HiComic、Mangabz、Xmanhua 等漫画网站...】、PubMed、Z-Library、GreasyFork、Github、StackOverflow(以上仅一小部分,更多的写不下了...
99
// @description:zh-TW ⭐無縫銜接下一頁內容到網頁底部(類似瀑布流)⭐,支持各論壇、社交、遊戲、漫畫、小說、學術、搜索引擎(Google、Bing、Yahoo...) 等網站~
@@ -323,6 +323,7 @@ function: {
323323
nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
324324
pageE: 'id("threadlist")//table[./tbody[contains(@id, "normalthread_")]]/tbody[not(@id="separatorline")]',
325325
replaceE: '.pg, .pages',
326+
forceHTTPS: true,
326327
scrollD: 1500
327328
}
328329
}, // Discuz! 论坛 - 导读页 及 帖子列表(不带无缝加载下一页按钮的)
@@ -331,6 +332,7 @@ function: {
331332
nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
332333
pageE: '#waterfall > li',
333334
replaceE: '.pg, .pages',
335+
forceHTTPS: true,
334336
scrollD: 1500
335337
}
336338
}, // Discuz! 论坛 - 图片模式的帖子列表(不带无缝加载下一页按钮的)
@@ -341,6 +343,7 @@ function: {
341343
nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
342344
pageE: '#postlist > div[id^="post_"]',
343345
replaceE: '//div[contains(@class,"pg") or contains(@class,"pages")][./a[contains(@class,"nxt") or contains(@class,"next") or contains(@class,"prev")][not(contains(@href,"javascript") or contains(@href,"commentmore"))]]',
346+
forceHTTPS: true,
344347
scrollD: 1500
345348
},
346349
function: {
@@ -353,6 +356,7 @@ function: {
353356
nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
354357
pageE: '#threadlist > ul',
355358
replaceE: '.pg, .pages',
359+
forceHTTPS: true,
356360
scrollD: 1500
357361
}
358362
}, // Discuz! 论坛 - 搜索页
@@ -361,6 +365,7 @@ function: {
361365
nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
362366
pageE: 'form:not([action^="search.php?"]) tbody > tr:not(.th)',
363367
replaceE: '.pg, .pages',
368+
forceHTTPS: true,
364369
scrollD: 1500
365370
}
366371
}, // Discuz! 论坛 - 回复页、主题页(别人的)
@@ -369,6 +374,7 @@ function: {
369374
nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
370375
pageE: '#ct .bm_c table > tbody',
371376
replaceE: '.pg, .pages',
377+
forceHTTPS: true,
372378
scrollD: 1500
373379
}
374380
}, // Discuz! 论坛 - 淘帖页
@@ -377,6 +383,7 @@ function: {
377383
pager: {
378384
nextL: '//a[@class="nxt" or @class="next"] | //div[@class="page"]/a[text()="下一页" or contains(text(), ">")]',
379385
replaceE: '.pg, .page',
386+
forceHTTPS: true,
380387
scrollD: 1000
381388
}
382389
}, // Discuz! 论坛 - 触屏手机版 - 帖子内
@@ -1444,7 +1451,7 @@ function: {
14441451
window.addEventListener('urlchange', function(){
14451452
lp = location.pathname;
14461453
//console.log(nowLocation, location.href)
1447-
if (curSite.history !== false && window.top.document.xiu_nowUrl === location.href) {nowLocation = location.href; return}
1454+
if (curSite.history !== false && window.top.document.Autopage_nowUrl === location.href) {nowLocation = location.href; return}
14481455
if (nowLocation == location.href) return
14491456
if (curSite.pager && curSite.pager.type == 5) {
14501457
if (self != top) {window.top.location.href = location.href;} else {if (getCSS('iframe#Autopage_iframe')) {getCSS('iframe#Autopage_iframe').remove();}}
@@ -2859,11 +2866,18 @@ function: {
28592866
function getNextE(css) {
28602867
if (!css) css = curSite.pager.nextL;
28612868
let next = getOne(css);
2862-
if (next && next.nodeType === 1 && next.href && next.href.slice(0,4) === 'http' && next.href != curSite.pageUrl) {
2863-
if (curSite.pager.forceHTTPS && location.protocol === 'https:') {
2864-
curSite.pageUrl = next.href.replace(/^http:/,'https:');
2869+
if (next && next.nodeType === 1 && next.href && next.href.slice(0,4) === 'http') {
2870+
if (next.href != curSite.pageUrl) {
2871+
if (curSite.pager.forceHTTPS && location.protocol === 'https:') {
2872+
if (next.href.replace(/^http:/,'https:') === curSite.pageUrl) {
2873+
return false
2874+
}
2875+
curSite.pageUrl = next.href.replace(/^http:/,'https:');
2876+
} else {
2877+
curSite.pageUrl = next.href;
2878+
}
28652879
} else {
2866-
curSite.pageUrl = next.href;
2880+
return false
28672881
}
28682882
//console.log(curSite.pageUrl)
28692883
return true
@@ -3007,8 +3021,10 @@ function: {
30073021
//console.log(pageE.querySelector('title'), curSite.pageUrl)
30083022
title = title || pageE.querySelector('title').textContent || window.top.document.title;
30093023
url = url || curSite.pageUrl;
3010-
window.top.document.xiu_nowUrl = curSite.pageUrl;
3011-
window.top.history.pushState('xiu_history', title, url);
3024+
window.top.document.Autopage_nowUrl = curSite.pageUrl;
3025+
// 对于下一页 URL 和当前网页 URL 的协议不同时,跳过
3026+
if (url.indexOf(window.top.location.protocol) === -1) return
3027+
window.top.history.pushState('Autopage_history', title, url);
30123028
window.top.document.title = title;
30133029
}
30143030
// 插入 <Script>

0 commit comments

Comments
 (0)