新增 [blank: 3] 规则; 新增 超时重试 功能; 新增 [s1.byrutor.com] 支持

This commit is contained in:
xiu2
2022-03-27 10:08:56 +08:00
parent 5c41a7b01a
commit 8e2209812b
2 changed files with 55 additions and 36 deletions
+40 -35
View File
@@ -3,7 +3,7 @@
// @name:zh-CN 自动无缝翻页
// @name:zh-TW 自動無縫翻頁
// @name:en AutoPager
// @version 5.4.9
// @version 5.5.0
// @author X.I.U
// @description ⭐无缝衔接下一页内容到网页底部(类似瀑布流)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、微博、NGA、V2EX、煎蛋网、龙的天空、起点中文、千图网、千库网、Pixabay、Pixiv、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、RuTracker、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE 动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、小众软件、【动漫狂、漫画猫、漫画屋、漫画 DB、动漫之家、拷贝漫画、HiComic、Mangabz、Xmanhua 等漫画网站...】、PubMed、Z-Library、GreasyFork、Github、StackOverflow(以上仅一小部分,更多的写不下了...
// @description:zh-TW ⭐無縫銜接下一頁內容到網頁底部(類似瀑布流)⭐,支持各論壇、社交、遊戲、漫畫、小說、學術、搜索引擎(Google、Bing、Yahoo...) 等網站~
@@ -13,6 +13,7 @@
// @connect raw.iqiq.io
// @connect raw.fastgit.org
// @connect hk1.monika.love
// @connect cdn.staticaly.com
// @connect www.xuexiniu.com
// @connect bbs.xuexiniu.com
// @connect weili.ooopic.com
@@ -308,7 +309,7 @@
thread: 对于社区类网站,要在 帖子内 的规则中加入这个,用于脚本的 [帖子内自动翻页] 功能(即用户可以选择开启/关闭所有社区类网站帖子内的自动翻页)
style: 要插入网页的 CSS Style 样式
retry: 允许获取失败后重试
blank: 强制新标签页打开链接(1 = base 方式2 = 点击委托事件方式
blank: 强制新标签页打开链接(1 = <base>2 = 对 body 点击事件委托,3 = 仅对 pageE 的父元素点击事件委托
pager: {
type: 翻页模式
@@ -1441,11 +1442,9 @@ function: {
let urlArr = ['https://raw.iqiq.io/XIU2/UserScript/master/other/Autopage/rules.json',
'https://hk1.monika.love/XIU2/UserScript/master/other/Autopage/rules.json',
'https://raw.fastgit.org/XIU2/UserScript/master/other/Autopage/rules.json']
//'https://cdn.staticaly.com/gh/XIU2/UserScript/master/other/Autopage/rules.json',
//'https://cdn.jsdelivr.net/gh/XIU2/UserScript/other/Autopage/rules.json',
//'https://fastly.jsdelivr.net/gh/XIU2/UserScript/other/Autopage/rules.json',
//'https://github.do/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json'
'https://raw.fastgit.org/XIU2/UserScript/master/other/Autopage/rules.json',
'https://cdn.staticaly.com/gh/XIU2/UserScript/master/other/Autopage/rules.json',
'https://cdn.staticaly.com/gh/XIU2/UserScript/master/other/Autopage/rules.json']
if (update) { // 手动更新(或安装后首次更新)
GM_notification({text: '🔄 更新外置翻页规则中,请勿操作网页...', timeout: 3000});
@@ -1483,16 +1482,16 @@ function: {
GM_notification({text: '❌ 为空!更新失败,请联系作者解决...', timeout: 5000});
}
} catch (e) {
console.log(e);
console.log('URL' + url, e);
GM_notification({text: '❌ 报错!更新失败,请联系作者解决...', timeout: 5000});
}
},
onerror: function (response) {
console.log(response)
console.log('URL' + url, response)
GM_notification({text: '❌ 错误!更新失败,请联系作者解决...', timeout: 5000});
},
ontimeout: function (response) {
console.log(response)
console.log('URL' + url, response)
GM_notification({text: '❌ 超时!更新失败,请联系作者解决...', timeout: 5000});
}
})
@@ -2637,12 +2636,13 @@ function: {
}
},
onerror: function (response) {
console.log(response)
console.log('URL' + url, response)
GM_notification({text: '❌ 获取下一页失败...', timeout: 5000});
},
ontimeout: function (response) {
console.log(response)
GM_notification({text: '❌ 获取下一页超时...', timeout: 5000});
setTimeout(function(){curSite.pageUrl = '';}, 3000)
console.log('URL' + url, response)
GM_notification({text: '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...', timeout: 5000});
}
});
}
@@ -2688,12 +2688,13 @@ function: {
}
},
onerror: function (response) {
console.log(response)
console.log('URL' + url, response)
GM_notification({text: '❌ 获取下一页失败...', timeout: 5000});
},
ontimeout: function (response) {
console.log(response)
GM_notification({text: '❌ 获取下一页超时...', timeout: 5000});
setTimeout(function(){curSite.pageUrl = '';}, 3000)
console.log('URL' + url, response)
GM_notification({text: '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...', timeout: 5000});
}
});
}
@@ -3214,35 +3215,39 @@ function: {
// 强制新标签页打开链接
function forceTarget() {
// 过渡
// 过渡,过几个星期后删除这两个判断
if (curSite.forceTarget != undefined && curSite.blank == undefined) curSite.blank = curSite.forceTarget
if (curSite.blank === true) curSite.blank = 2
// 过渡,过几个星期后删除这两个判断
if (curSite.blank === 1) {
document.head.appendChild(document.createElement('base')).target = '_blank';
} else if (curSite.blank === 2 || curSite.blank === true) {
document.body.addEventListener('click', function(e) {
if (e.target.tagName === 'A') {
forceTarget_(e.target, e);
} else {
let path = e.path || e.composedPath();
for (let i = 1; i < path.length - 3; i++) {
//console.log(path[i])
if (path[i].tagName === 'A') {
forceTarget_(path[i], e);
break;
}
}
}
});
} else {
let d;
if (curSite.blank === 2) {
d = document.body
} else if (curSite.blank === 3) {
let dd = toE5pop(getAll(curSite.pager.pageE));
if (dd && dd.parentElement != null) d = dd.parentElement
}
if (!d) return
function forceTarget_(target, e){
if (target.href && target.target != '_blank' && !(target.getAttribute('onclick')) && target.href.slice(0,4) == 'http' && target.getAttribute('href').slice(0,1) != '#') {
e.preventDefault(); // 阻止默认打开链接事件
//console.log(target.href);
//window.top.location.href = target.href;
window.GM_openInTab(target.href, {active: true,insert: true,setParent: true});
}
}
//document.head.appendChild(document.createElement('base')).target = '_top';
d.addEventListener('click', function(e) {
//console.log(e.target.tagName, e.path)
if (e.target.tagName === 'A') {
forceTarget_(e.target, e);
} else {
let path = e.path || e.composedPath();
for (let i = 1; i < path.length - 4; i++) {if (path[i].tagName === 'A') {forceTarget_(path[i], e); break;}}
}
});
}
}
// 判断元素是否隐藏(隐藏返回 true)
+15 -1
View File
@@ -1821,7 +1821,7 @@
"replaceE": ".gensmall[align='right']"
}
},
"byrutor": {
"byrut.org": {
"host": "byrut.org",
"url": "return (!fun.indexOF(/^\\/\\d+-/))",
"blank": 1,
@@ -1831,6 +1831,20 @@
"replaceE": ".bottom-page"
}
},
"s1.byrutor.com": {
"host": "s1.byrutor.com",
"url": "return (!fun.indexOF('do=search','s') && fun.getCSS('.paging-wrapper-bottom') != null)",
"blank": 3,
"pager": {
"nextL": ".paging-wrapper-bottom > span + a",
"pageE": "div[id^='entryID']",
"replaceE": ".paging-wrapper-bottom",
"scrollD": 2000
},
"function": {
"bF": "pageE.forEach(function (one) {let now = one.querySelector('span.hilink');if (now) {now.outerHTML = now.outerHTML.replace('data-link=','href=').replaceAll('span','a');};}); return pageE"
}
},
"GBAtemp - 帖子内": {
"host": "gbatemp.net",
"url": "/^\\/threads\\//",