|
3 | 3 | // @name:zh-CN 自动无缝翻页 |
4 | 4 | // @name:zh-TW 自動無縫翻頁 |
5 | 5 | // @name:en AutoPager |
6 | | -// @version 5.2.0 |
| 6 | +// @version 5.2.1 |
7 | 7 | // @author X.I.U |
8 | 8 | // @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(以上仅一小部分,更多的写不下了... |
9 | 9 | // @description:zh-TW 無縫追加下一頁內容(瀑布流),支持各論壇、社交、遊戲、漫畫、小說、學術、搜索引擎(Google、Bing、Yahoo...) 等網站~ |
@@ -1367,37 +1367,48 @@ function: { |
1367 | 1367 | } |
1368 | 1368 | // 获取外置翻页规则 |
1369 | 1369 | function getRulesUrl(update = false) { |
1370 | | - if (GM_getValue('menu_ruleUpdateTime') == null) update = true |
1371 | | - if (update) GM_setValue('menu_ruleUpdateTime', '1970/1/1'); |
1372 | | - //console.log(new Date().getTime()); |
1373 | | - let timeNow = new Date().getFullYear() + '/' + (new Date().getMonth() + 1) + '/' + new Date().getDate(), |
1374 | | - timeOld = GM_getValue('menu_ruleUpdateTime'); |
1375 | | - if (!timeOld || timeOld != timeNow) { // 是新的一天 |
1376 | | - GM_setValue('menu_ruleUpdateTime', timeNow); // 写入时间以供后续比较 |
| 1370 | + // 如果是原来的时间格式 或 刚安装脚本,则需要立即更新 |
| 1371 | + if (typeof(GM_getValue('menu_ruleUpdateTime', '')) == 'string') update = true |
1377 | 1372 |
|
| 1373 | + if (update) { // 手动更新(或安装后首次更新) |
| 1374 | + GM_setValue('menu_ruleUpdateTime', parseInt(+new Date()/1000)); // 写入当前时间戳 |
| 1375 | + getRulesUrl_(update, true); // 立即更新规则 |
| 1376 | + } else { // 自动更新 |
| 1377 | + if (parseInt(+new Date()/1000) - GM_getValue('menu_ruleUpdateTime', 0) > 86400) getRulesUrl_(); // 距离上次检查更新超过 1 天,则对比远程时间戳 |
| 1378 | + } |
| 1379 | + |
| 1380 | + function getRulesUrl_(update = false, notification = false) { |
1378 | 1381 | GM_xmlhttpRequest({ |
1379 | | - url: 'https://userscript.xiu2.xyz/other/Autopage/rules.json', |
| 1382 | + url: (update === true) ? 'https://userscript.xiu2.xyz/other/Autopage/rules.json' : 'https://userscript.xiu2.xyz/other/Autopage/ruleUpdateTime.json', |
1380 | 1383 | method: 'GET', |
1381 | | - responseType: 'json', |
1382 | | - overrideMimeType: 'application/json; charset=utf-8', |
| 1384 | + responseType: (update === true) ? 'json' : 'text', |
| 1385 | + overrideMimeType: (update === true) ? 'application/json; charset=utf-8' : 'text/plain; charset=utf-8', |
1383 | 1386 | timeout: 5000, |
1384 | 1387 | onload: function (response) { |
1385 | 1388 | try { |
1386 | 1389 | //console.log('最终 URL:' + response.finalUrl, '返回内容:',response.response) |
1387 | 1390 | if (response.response) { |
1388 | | - GM_setValue('menu_rules', response.response); |
1389 | | - if (update) { |
1390 | | - curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码 |
1391 | | - registerMenuCommand(); // 重新判断规则 |
1392 | | - //console.log(new Date().getTime()); |
1393 | | - //console.log(curSite); |
1394 | | - if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式 |
1395 | | - curSite.pageUrl = ''; // 下一页URL |
1396 | | - pageLoading(); // 自动无缝翻页 |
1397 | | - |
1398 | | - if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码 |
1399 | | - pausePageEvent(); // 左键双击网页空白处暂停翻页 |
1400 | | - GM_notification({text: '✅ 已更新外置翻页规则!\n如果依然无法翻页,则说明还不支持当前网页,欢迎点击此处提交申请~', timeout: 5000, onclick: function(){window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});}}); |
| 1391 | + |
| 1392 | + if (!update) { // 获取远程时间戳并对比 |
| 1393 | + if (parseInt(response.response) && parseInt(response.response) > GM_getValue('menu_ruleUpdateTime', 0)) { |
| 1394 | + GM_setValue('menu_ruleUpdateTime', parseInt(+new Date()/1000)); // 写入当前时间戳 |
| 1395 | + getRulesUrl_(true); |
| 1396 | + } else {GM_setValue('menu_ruleUpdateTime', parseInt(+new Date()/1000));} |
| 1397 | + |
| 1398 | + } else { // 写入最新规则 |
| 1399 | + |
| 1400 | + GM_setValue('menu_rules', response.response); |
| 1401 | + if (notification) { // 通知并重新判断 |
| 1402 | + curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码 |
| 1403 | + registerMenuCommand(); // 重新判断规则 |
| 1404 | + if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式 |
| 1405 | + curSite.pageUrl = ''; // 下一页URL |
| 1406 | + pageLoading(); // 自动无缝翻页 |
| 1407 | + |
| 1408 | + if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码 |
| 1409 | + pausePageEvent(); // 左键双击网页空白处暂停翻页 |
| 1410 | + GM_notification({text: '✅ 已更新外置翻页规则!\n如果依然无法翻页,则说明还不支持当前网页,欢迎点击此处提交申请~', timeout: 5000, onclick: function(){window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});}}); |
| 1411 | + } |
1401 | 1412 | } |
1402 | 1413 | } else { |
1403 | 1414 | GM_notification({text: '❌ 更新失败,请联系作者解决...', timeout: 5000}); |
|
0 commit comments