Greasy Fork镜像 支持简体中文。

自動無縫翻頁

⭐無縫加載 下一頁內容 至網頁底部(類似瀑布流,无限滚动,無需手働點擊下一頁)⭐,支持各論壇、社交、遊戲、漫畫、小說、學術、搜索引擎(Google、Bing、Yahoo...) 等網站~

安裝腳本?
作者推薦腳本

您可能也會喜歡 知乎增強

安裝腳本
  1. // ==UserScript==
  2. // @name AutoPager
  3. // @name:zh-CN 自动无缝翻页
  4. // @name:zh-TW 自動無縫翻頁
  5. // @name:ru Автостраничник
  6. // @version 6.6.56
  7. // @author X.I.U
  8. // @description ⭐Append the next page content to the bottom seamlessly (like a waterfall, Unlimited scrolling, no need to manually click on the next page) ⭐, support various forums, social networking, games, comics, novels, academics, search engines (Google, Bing, Yahoo...) and other websites~
  9. // @description:zh-CN ⭐无缝加载 下一页内容 至网页底部(类似瀑布流,无限滚动,无需手动点击下一页)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、MyBB、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(以上仅一小部分常见网站,更多的写不下了...
  10. // @description:zh-TW ⭐無縫加載 下一頁內容 至網頁底部(類似瀑布流,无限滚动,無需手働點擊下一頁)⭐,支持各論壇、社交、遊戲、漫畫、小說、學術、搜索引擎(Google、Bing、Yahoo...) 等網站~
  11. // @description:ru ⭐Плавно добавляет содержимое следующей страницы к нижней части (как водопад, неограниченная прокрутка, не нужно вручную нажимать на следующую страницу) ⭐, поддерживает различные форумы, соцсети, игры, комиксы, романы, научные статьи, поисковики (Google, Bing, Yahoo...) и другие сайты~
  12. // @match *://*/*
  13. // @connect userscript.xiu2.xyz
  14. // @connect userscript.h233.eu.org
  15. // @connect bitbucket.org
  16. // @connect jsd.onmicrosoft.cn
  17. // @connect wget.la
  18. // @connect cdn.wget.la
  19. // @connect ghfast.top
  20. // @connect raw.ixnic.net
  21. // @connect ghproxy.cfd
  22. // @connect raw.github.site
  23. // @connect raw.github.store
  24. // @connect raw.dgithub.xyz
  25. // @connect gh-proxy.ygxz.in
  26. // @connect ghproxy.net
  27. // @connect github.moeyy.xyz
  28. // @connect github.7boe.top
  29. // @connect github.starrlzy.cn
  30. // @connect cdn.jsdmirror.com
  31. // @connect js.cdn.haah.net
  32. // @connect gh.akass.cn
  33. // @connect raw.kkgithub.com
  34. // @connect gcore.jsdelivr.net
  35. // @connect fastly.jsdelivr.net
  36. // @connect jsd.proxy.aks.moe
  37. // @connect jsdelivr.pai233.top
  38. // @connect gh-proxy.com
  39. // @connect www.xuexiniu.com
  40. // @connect bbs.xuexiniu.com
  41. // @connect weili.ooopic.com
  42. // @connect www.ykmh.com
  43. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAALfElEQVRYhX2Xe3Bd1XXGf3vvc859X+nq6nUlW5Yly7JlI2xsYzAwtnk4ATpAxkNTHm0mnaTT/gHTTvrIBDLTpp1JUoZppqHQls5AKTR2INOWJJQSXF4x2BhsJCRZ8kuWZckPSVf3/Trn7N3RVTFpQrNn1l97n7O/vda31reWMKMPcmUJA9U8vrwHGdqCHn4HPzePaIxhVSoYbYRXrn7BeMVbCUduF6kVUXHwvQP+6amDaqDnoIompmQytaBnTmB8H5lowrjgFss48SBeI/hUEEZeudLi1ywhJEIJdL6Q8rzal/1a5SGC4XZrYBvWwEZobMdLdH6RH+z/Io1taEeh52fe8tOZbysl/ouWFvANYP7fSz4DgAEBBIL4xiS8ubmnVcTZK68aRK29Dtm8dgnZJydRW+/E2nrnp19nz+7U77+60zt0qMz07J/KxuQTwrIw4rMBCDP6wC+FIIcO34eudDdXf/7jD52Opi772lugY3AZr++hp06gz48j+waRqTWYmVHcS+chEMFeuw1hBzBzY7g/fQE9fmqBYPzBQKrpVa/R4OkCAnXlSvXnX9sIllk220BE4Z8OdHoj54YCK6Od1i2/iUmuRyDRk6NUn3+M0pv/hnf0AE40jEjEqP3oe6Rf/CGOWUTNjFKby2MP7EBtugURFWFxfOhB4+o4yfhrGAdZsxHaqZt6dNce9KXYFSPfGWS68JFqTXSqO7+MCaTqETGTwxSeeoRCOoPT2YUIhFC2jbQF/uwUatU6rPbVUM5T+OfHUO3dWKv6kSsGUIOD6PEPr+fswnanpecFZYVQhFAyjPS9Tj4xw2rcU+pJApEutWsvRjaBW8NUShilkE1JIqlUPfi6VMLNFTBVr+7KYKqJ8uEjlM+dJrR5K0L7eB+9hTd2CFrWYt33h0jH3O5Nj37TBGtgZUBkUN/6q4dQ7UmsnlW450//gU5PPRq460uQXAu+j//i99A/+UdUMoXqbMNkz2OnUkixlF4u9spe/HMTULyEaA7jXkoT2fEbQIXi838DJ4cRDXHkEjc2b0MPHdptZubGpBUbM0UfKQpBRDmKWRSD3tTMk87gddA2WGe4+dkzMD0CyQ5qP/4XVDCAvfkaLMvHamzEClpQzGDF46iuJOH1CaKr2tDZRfzhQ0Ru24NYsYrCM4/jDb+FiHdi3XU/0s3vr7WsGKxcfyPSy+bxi0UqJ8f/IriiE2vrnuWsLefQk8NoO4AMBBB9/XjDI6hQCjdTxq9WCaQ6ULaDFrIeKr3oIlv70Olz2K1xlAVaSUQojD786nKi9e5A3LBHMHn0W+LUUaS1FI9q+iZZWLhHdq/FxFbWSSfsIDIQwVw4g/GK2OuuhloNMzaCaF+DNBJtQfX8LFYigElX0OkQtZKHVy3jqwDlqWncCzPI3nU4t+2FWrH+OLHzHpRl3109memTOhqDi9NfkefHEKvWLTO+VKD68Qf4G27CueFWhJ/Df+0lVFcXJOJYnobm1ZjsJUxuFjyDjK/GNK2gND4ESuDPXcCOSaI7thPqX0ft8OtUn/oTKOQgkET39KJU4RbpZXOtNRW717p+FyRSdYT+v36H4u/fQXbfc3iRDkT3FsTGjWAWEU0OZKfAU9CyEdXVD2lQPduplmo4jkBEbMzK1VgDu5EVTe3gm1RHx6Bcxpz6YLkEO0lMYeFGi6z7eVMqhkT/ZrCb0LNT+NMTRH/nt/BLRdy3X8Nv68Lu6cZEHURjE6K3hirYeLRhDWyA4jxzH40RXJwkeuM29MpN+JcziEsz+Avz6GgcW1pYbUlEQCyHwYpSyxS7rGo+v8man4ZMATrAHf+QSt7FTkWR4QbsjlbIX8IMH0VuuAqj4piGAbhmEPPzI/injnNxMUPuwOtseOIxKKTJ7/8BTBxDdXcjO9sJdTeg01VqH4wg3CDB9bshHMKORbGolVOmeRW09dVdUxkbp3ruNM7GXnS1hK5OYSoSbBDZBcxCBtF3DcUzk6hkhGA0RmtHKx1rOkE04lbzWC1tqMRt1CZHUafPIs8H6/JsNTcgN+9YFq1qgbBUFUvnK9qrVghXCvWN8MBmivueJDtylqaeBKWJaXR4JZEtNyBWrkGt6AJboCZO4J49Rc64xGIhcgtZgm6egKhgtUQQto17WeHOLqCNj5Vowbr7q4j+Lcs1JhhEphcXLTebd0jPwpkx6Lwa++bbCR95ALecp5a6BrvrJoLdHajmMOTnKb3+BrVMntjARpzeFbz8jcfpa22gGm+kMJlm95Zu9M9+iI5G0G3d6EgIUSnjzs/gv/Icgd6rqcvz0IeYWnXc8pEtYnEe8gtXNL7xz74LehHSE3DqNP7EIdx3p5DSh7JNJePiBE/gN3Uz8NWHae5sRJYXqKQvU+raQPg7L6L3/QNMHcfp6EREGjC5LDp9GaOs5VQ/NQI93YctOxFPlwniDh/C3n47JHvrQPTBl3DHjiIDQUQ4jGhOYcqaQFuE0Nl53OnLRHfsZV33KsTxd6GlHeaP477zMl5uAWv7dkyLg6kZREsb+vgCcvPOuoaYuWNQWERs3jAuQ6nooXK6TH566cXnrjQK7uwFaoseWA3oJf2WEhEJUjm/gMgXCfdvQlFFv/R3uCND6FIRv7MfMnOIiaPoI/8NEb2kWAhfoLbdjLr2jmUv/8f+pVbkHRGNnZHum2/udxxtCn4j/vgEIjNTD4O9upfIprUYoxBKo9Z14jumTq7YYD9WayvuR++hs1lkshmha4iuNeDYiIAFMoCevIi+cJHaa29gmvsRTUn0R29g9u1D7bxxv+jrRnpD56cCkdjfV9NzpA+8A5VlLojWAczlGVTAYKXimIU8MlsjtKEXgiF0aRGdm8cEYnXm+O+/gdAGuWsP3shhTHoOEYqCCEF2DsrF5f+e/xiikUldrT6l3z+GevSaTahaZdRY6uFqxRXR1sRyzU/21Gu6OTOMfzmPd6kI8TgiX8B4imouj1QCKmVUNITJ59AnR1F77kH4ZaRnQFroMyeRW3egdt6DwIX391Gshv+4LK2jtcuLqK9t7ALjZXzH1uVM/mb/7BTRnjZEex+idQ2EAnjjR/BdF1PIoV2Bae/F/fh9dL5IYE0XUmpMNo+ev4AINSJWb0UPHa63Z7SvRN3/CHJpFHj2G4iZzAuBbTu+GWpIEGxrQ/3RnlvxG5M4kYa3Lc2u4uyFblnIE+xfAbF2RMtqZGsn/uTYUgHH+dz9eFMnqYx8gO+CEwkjhcDPF/DLHurSaeTm3RiWMsDHeuDrSFvBv3+bi08+N1Vwuj/vZWtu+dwclZlFrESoeZmZysJXoTsCjnVk8dDQBuN+n8RDD9fbcdG7leBX1iOkQjhBOHmQfKGAHW3CS6fR+QClmYuYMyPY265DtPVgtfctiw4V/GcfYfGNQzj3/u4DqlormUoZEQwuc0I//eSnY4G0wPJjmdGhw+mh0fWxNZ0037cXccPd1MXgk+GjNE/tR3+Le+YEyg5TnT6LXlwgcu1u7C99HZlsv3K2+vjvkTs2RvDe3747tm7Dy1SKvzSYPP/MLwxFAkIKEzEye2zswOXX395lJyK0fOFzRHfuglQfqPin59Nn0RNDuJk09vprkd0brmx5H7xCbfgQbrZ83OkfvN1pj0+ZmkBYNhjzCwCeffr/AsBDJyU6kqBwbPzRuTcP/GXV82lYlaJpfQ+BjVdhXX0tNKTAjvzKqKXPTeC++1NKY0c9kVz1SGzb9X8tjIdfzSFCDfUw/noA0scPuxBrwcvmmH3rQIvMm3/y0XdJS4JfIpiIUG9g+wcg6KDnZpGZNDQ0Ii5cSAtlPRHYct13axWvJNwadiiAli4iEP8VAJ89HQtR129TLiG1nos0Nt8dSOi12qi9lRq3utVqT/lirql24hW3vLBQi3d3XUqu73+PZOonBNR/WnbYSMeGTO5/Xf6ZtwDwPwtFRezQVs+sAAAAAElFTkSuQmCC
  44. // @grant GM_xmlhttpRequest
  45. // @grant GM_registerMenuCommand
  46. // @grant GM_unregisterMenuCommand
  47. // @grant GM_openInTab
  48. // @grant GM_getValue
  49. // @grant GM_setValue
  50. // @grant GM_notification
  51. // @grant GM_info
  52. // @grant GM.info
  53. // @grant window.onurlchange
  54. // @grant unsafeWindow
  55. // @sandbox JavaScript
  56. // @license GPL-3.0 License
  57. // @run-at document-end
  58. // @namespace https://github.com/XIU2/UserScript
  59. // @supportURL https://github.com/XIU2/UserScript
  60. // @homepageURL https://github.com/XIU2/UserScript
  61. // @exclude https://*.taobao.com/*
  62. // @exclude https://*.tmall.com/*
  63. // @exclude https://*.1688.com/*
  64. // @exclude https://*.jd.com/*
  65. // @exclude https://*.vip.com/*
  66. // @exclude https://*.suning.com/*
  67. // @exclude https://*.aliexpress.com/*
  68. // @exclude https://*.paypal.com/*
  69. // @exclude https://*.iqiyi.com/*
  70. // @exclude https://*.youku.com/*
  71. // @exclude https://m.v.qq.com/*
  72. // @exclude https://v.qq.com/*
  73. // @exclude https://*.acfun.cn/*
  74. // @exclude https://t.bilibili.com/*
  75. // @exclude https://www.bilibili.com/*
  76. // @exclude https://live.bilibili.com/*
  77. // @exclude https://space.bilibili.com/*
  78. // @exclude https://manga.bilibili.com/*
  79. // @exclude https://member.bilibili.com/*
  80. // @exclude https://message.bilibili.com/*
  81. // @exclude https://*.youtube.com/*
  82. // @exclude https://*.youtube-nocookie.com/*
  83. // @exclude https://*.cnki.net/*
  84. // @exclude https://mail.qq.com/*
  85. // @exclude https://weread.qq.com/*
  86. // @exclude https://*.weread.qq.com/*
  87. // @exclude https://www.qidian.com/chapter/*
  88. // @exclude https://bz.zzzmh.cn/*
  89. // @exclude https://wallhaven.cc/*
  90. // @exclude https://chrome.zzzmh.cn/*
  91. // @exclude https://*.guazi.com/*
  92. // @exclude https://*.liepin.com/*
  93. // @exclude https://*.58.com/*
  94. // ==/UserScript==
  95.  
  96. (function() {
  97. 'use strict';
  98. let urlArr = [ // 外置翻页规则更新地址分流,以确保更新成功率(记得 connect)
  99. 'https://github.7boe.top/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  100. 'https://github.starrlzy.cn/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  101. 'https://cdn.jsdmirror.com/gh/XIU2/UserScript/other/Autopage/rules.json',
  102. 'https://js.cdn.haah.net/gh/XIU2/UserScript/other/Autopage/rules.json',
  103. 'https://gh.akass.cn/XIU2/UserScript/master/other/Autopage/rules.json',
  104. 'https://raw.kkgithub.com/XIU2/UserScript/master/other/Autopage/rules.json',
  105. //'https://gcore.jsdelivr.net/gh/XIU2/UserScript/other/Autopage/rules.json',
  106. 'https://fastly.jsdelivr.net/gh/XIU2/UserScript/other/Autopage/rules.json',
  107. //'https://jsd.proxy.aks.moe/gh/XIU2/UserScript/other/Autopage/rules.json',
  108. 'https://jsdelivr.pai233.top/gh/XIU2/UserScript/other/Autopage/rules.json',
  109. 'https://gh-proxy.com/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  110. ]
  111. const urlArr2 = [
  112. 'https://userscript.h233.eu.org/other/Autopage/rules.json',
  113. 'https://userscript.xiu2.xyz/other/Autopage/rules.json',
  114. 'https://bitbucket.org/xiu2/userscript/raw/master/other/Autopage/rules.json',
  115. 'https://jsd.onmicrosoft.cn/gh/XIU2/UserScript/other/Autopage/rules.json',
  116. 'https://wget.la/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  117. 'https://cdn.wget.la/gh/XIU2/UserScript/other/Autopage/rules.json',
  118. 'https://ghfast.top/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  119. //'https://raw.ixnic.net/XIU2/UserScript/master/other/Autopage/rules.json', // 解析空
  120. 'https://ghproxy.cfd/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  121. //'https://raw.github.site/XIU2/UserScript/master/other/Autopage/rules.json', // 挂了
  122. //'https://raw.github.store/XIU2/UserScript/master/other/Autopage/rules.json', // 挂了
  123. 'https://raw.dgithub.xyz/XIU2/UserScript/master/other/Autopage/rules.json',
  124. 'https://gh-proxy.ygxz.in/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  125. 'https://ghproxy.net/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  126. 'https://github.moeyy.xyz/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  127. ],
  128. loadMoreExclude1 = ['.smzdm.com','stackoverflow.com'],
  129. loadMoreExclude2 = ['.steampowered.com','.zcool.com.cn'];
  130.  
  131. var menuAll = [
  132. ['menu_disable', '✅ 已启用 (点击对当前网站禁用)', '❌ 已禁用 (点击对当前网站启用)', []],
  133. ['menu_thread', '帖子内自动翻页 (社区类网站)', '帖子内自动翻页 (社区类网站)', true],
  134. ['menu_page_number', '显示当前页码及点击暂停翻页', '显示当前页码及点击暂停翻页', true],
  135. ['menu_pause_page', '左键双击网页空白处暂停翻页', '左键双击网页空白处暂停翻页', false],
  136. ['menu_history', '添加历史记录+修改地址/标题', '添加历史记录+修改地址/标题', true],
  137. ['menu_rules', '更新外置翻页规则 (定期自动)', '更新外置翻页规则 (定期自动)', {}],
  138. ['menu_customRules', '自定义翻页规则', '自定义翻页规则', {}]
  139. ], menuId = [], webType = 0, curSite = {SiteTypeID: 0}, DBSite, DBSite2, DBSiteNow, pausePage = true, pageNum = {now: 1, _now: 1}, urlC = false, nowLocation = '', lp = location.pathname, scriptHandler;
  140. urlArr.push(...urlArr2); // 合并数组
  141. window.autoPage = {lp: ()=>location.pathname, indexOF: indexOF, isMobile: isMobile, isUrlC: isUrlC, isPager: isPager, isTitle: isTitle, blank: forceTarget, getAll: getAll, getOne: getOne, getAllXpath: getAllXpath, getXpath: getXpath, getAllCSS: getAllCSS, getCSS: getCSS, getNextE: getNextE, getNextEP: getNextEP, getNextSP: getNextSP, getNextEPN: getNextEPN, getNextUPN: getNextUPN, getNextUP: getNextUP, getNextF: getNextF, getSearch: getSearch, getCookie: getCookie, insStyle: insStyle, insScript: insScript, cleanuEvent: cleanuEvent, src_bF: src_bF, xs_bF: xs_bF, pageNumIncrement: pageNumIncrement}
  142. if (typeof GM_info != 'undefined') {scriptHandler = GM_info.scriptHandler;} else if (typeof GM != 'undefined' && typeof GM.info != 'undefined') {scriptHandler = GM.info.scriptHandler;} else {scriptHandler = '';}
  143. for (let i=0;i<menuAll.length;i++){ // 如果读取到的值为 null 就写入默认值
  144. if (GM_getValue(menuAll[i][0]) == null){GM_setValue(menuAll[i][0], menuAll[i][3])};
  145. }
  146. // 兼容不支持 GM_openInTab 的油猴脚本管理器
  147. if (typeof GM_openInTab !== 'function') {GM_openInTab = openInTab}
  148. // 如果浏览器不支持 structuredClone(Chromium 98 才完全支持),则使用 JSON 方法代替
  149. if (typeof window.structuredClone !== 'function') {window.structuredClone = function(value) {return JSON.parse(JSON.stringify(value));}}
  150.  
  151. getRulesUrl();
  152. registerMenuCommand();
  153. if (menuId.length < 4) {return}
  154. // 注册(不可用)脚本菜单
  155. function registerMenuCommand() {
  156. if (menuId.length != []){
  157. for (let i=0;i<menuId.length;i++){
  158. GM_unregisterMenuCommand(menuId[i]);
  159. }
  160. }
  161. for (let i=0;i<menuAll.length;i++) { // 循环注册(不可用)脚本菜单
  162. menuAll[i][3] = GM_getValue(menuAll[i][0]);
  163.  
  164. if (menuAll[i][0] === 'menu_disable') { // 启用/禁用
  165.  
  166. if (menu_disable('check')) { // 当前网站在禁用列表中
  167. menuId[i] = GM_registerMenuCommand(`${menuAll[i][2]}`, function(){menu_disable('del')});
  168. return
  169. } else { // 不在禁用列表中
  170. webType = doesItSupport(); // 判断网站类型(即是否支持),顺便直接赋值
  171. if (webType === 0) {
  172. menuId[0] = GM_registerMenuCommand('❌ 当前网页暂不支持 [点击申请] (或无需翻页)', function(){GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});GM_openInTab('https://gf.qytechs.cn/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});});
  173. menuId[1] = GM_registerMenuCommand('🔄 更新外置翻页规则 (定期自动)', function(){getRulesUrl(true)});
  174. menuId[2] = GM_registerMenuCommand('#️⃣ 自定义翻页规则', function(){customRules()});
  175. //console.info('[自动无缝翻页] - 暂不支持当前网页 [ ' + location.href + ' ],申请支持: https://github.com/XIU2/UserScript / https://gf.qytechs.cn/zh-CN/scripts/419215/feedback');
  176. return
  177. } else if (webType === -1) {
  178. return
  179. }
  180. menuId[i] = GM_registerMenuCommand(`${menuAll[i][1]}`, function(){menu_disable('add')});
  181. }
  182.  
  183. } else if (menuAll[i][0] === 'menu_rules') {
  184. menuId[i] = GM_registerMenuCommand(`🔄 ${menuAll[i][1]}`, function(){getRulesUrl(true)});
  185.  
  186. } else if (menuAll[i][0] === 'menu_customRules') {
  187. menuId[i] = GM_registerMenuCommand(`#️⃣ ${menuAll[i][1]}`, function(){customRules()});
  188.  
  189. } else {
  190. menuId[i] = GM_registerMenuCommand(`${menuAll[i][3]?'✅':'❌'} ${menuAll[i][1]}`, function(){menu_switch(menuAll[i][3], menuAll[i][0], menuAll[i][2])});
  191. }
  192. }
  193. menuId[menuId.length] = GM_registerMenuCommand('💬 反馈失效 / 申请支持', function () {GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});GM_openInTab('https://gf.qytechs.cn/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});});
  194. }
  195.  
  196.  
  197. // --------------------------------------------------------
  198.  
  199.  
  200. // 判断是支持
  201. function doesItSupport() {
  202. setDBSite(); // 配置 DBSite 变量对象
  203.  
  204. // 遍历判断是否是某个已支持的网站,顺便直接赋值
  205. let support = false;
  206. end:
  207. for (let now in DBSite) { // 遍历 对象
  208. if (DBSite[now].ignore) continue; // 如果是特殊的内置规则(如通用规则)则跳过直接继续下一个循环
  209.  
  210. // 供其他函数在 域名/URL 判断阶段使用
  211. if (typeof DBSite[now].url == 'function'){
  212. DBSiteNow = DBSite[now] // 如果是脚本内置规则就没必要深度克隆了(用不上 rule 对象变量,毕竟是可以直接操作自身的)
  213. } else {
  214. DBSiteNow = structuredClone(DBSite[now]) //深度克隆是为了在后续 url 规则中通过操作 rule 对象变量来修改当前网页规则时,不会间接影响到 DBSite[now] 本身
  215. }
  216.  
  217. // 如果是 数组
  218. if (Array.isArray(DBSite[now].host)) {
  219.  
  220. for (let i of DBSite[now].host) { // 遍历 数组
  221.  
  222. // 针对自定义翻页规则中的正则
  223. if (typeof i === 'string' && i.slice(0,1) === '/') i = new RegExp(i.slice(1,i.length-1))
  224. if ((i instanceof RegExp && i.test(location.hostname)) || (typeof i === 'string' && i === location.hostname)) {
  225.  
  226. if (self != top) {if (!DBSite[now].iframe) continue end;} // 如果当前位于 iframe 框架下,就需要判断是否需要继续执行
  227. if (DBSite[now].url) {
  228. if (typeof DBSite[now].url == 'function') {
  229. DBSite[now].url();
  230. } else { // 自定义翻页规则时,因为同域名不同页面 url 分开写,所以如果没找到就需要跳出当前数组循环,继续规则循环
  231. try {
  232. if (DBSite[now].url.slice(0,1) === '/') { // 如果是正则,则对 URL 路径进行匹配
  233. if (new RegExp(DBSite[now].url.slice(1,DBSite[now].url.length-1), 'i').test(location.pathname + location.search) === true) {curSite = DBSite[now];} else {if (urlC === true) {support = true;}; break;}
  234. } else { // 如果是函数,那就执行代码(url 规则中可通过操作 rule 这个对象变量来修改当前网页实际应用的规则)
  235. if (new Function('fun','rule', DBSite[now].url)(window.autoPage,DBSiteNow)) {curSite = DBSiteNow;} else {if (urlC === true) {support = true;}; break;}
  236. }
  237. } catch (e) {
  238. console.error('[自动无缝翻页] - 当前网页规则 "url" 匹配出错,请检查:\n', DBSite[now].url + '\n\n', e);
  239. }
  240. }
  241. } else {
  242. curSite = DBSite[now];
  243. }
  244. support = true; break end; // 如果找到了就退出所有循环
  245. }
  246. }
  247.  
  248. // 如果是 正则/字符串
  249. } else {
  250. // 针对自定义翻页规则中的正则
  251. if (typeof DBSite[now].host === 'string' && DBSite[now].host.slice(0,1) === '/') DBSite[now].host = new RegExp(DBSite[now].host.slice(1,DBSite[now].host.length-1))
  252. if ((DBSite[now].host === undefined) || (DBSite[now].host instanceof RegExp && DBSite[now].host.test(location.hostname)) || (typeof DBSite[now].host === 'string' && DBSite[now].host === location.hostname)) {
  253. // 如果没有指定 host 规则,那么默认匹配所有域名(会对所有域名匹配 url 规则判断),可以当成一个简单的外置(自定义)通用规则方案
  254.  
  255. if (self != top) {if (!DBSite[now].iframe) continue;} // 如果当前位于 iframe 框架下,就需要判断是否需要继续执行
  256. if (DBSite[now].url) {
  257. if (typeof DBSite[now].url == 'function') {
  258. DBSite[now].url();
  259. } else { // 自定义翻页规则时,因为同域名不同页面 url 分开写,所以如果没找到就需要继续规则循环
  260. try {
  261. if (DBSite[now].url.slice(0,1) === '/') { // 如果是正则,则对 URL 路径进行匹配
  262. if (new RegExp(DBSite[now].url.slice(1,DBSite[now].url.length-1), 'i').test(location.pathname + location.search) === true) {curSite = DBSite[now];} else {if (urlC === true) {support = true;}; continue;}
  263. } else { // 如果是函数,那就执行代码(url 规则中可通过操作 rule 这个对象变量来修改当前网页实际应用的规则)
  264. if (new Function('fun','rule', DBSite[now].url)(window.autoPage,DBSiteNow)) {curSite = DBSiteNow;} else {if (urlC === true) {support = true;}; continue;}
  265.  
  266. }
  267. } catch (e) {
  268. console.error('[自动无缝翻页] - 当前网页规则 "url" 匹配出错,请检查:\n', DBSite[now].url + '\n\n', e);
  269. }
  270. }
  271. } else {
  272. curSite = DBSite[now];
  273. }
  274. support = true; break; // 如果找到了就退出循环
  275. }
  276. }
  277. }
  278.  
  279. DBSiteNow = undefined // 仅限判断阶段使用,判断完成就需要置空
  280.  
  281. if (support) {
  282. console.info('[自动无缝翻页] - 独立规则 网站'); return 1;
  283. } else if (self != top) {
  284. return -1;
  285. } else if (typeof discuz_uid != 'undefined' || getCSS('meta[name="author" i][content*="Discuz!" i], meta[name="generator" i][content*="Discuz!" i], body[id="nv_forum" i][class^="pg_" i][onkeydown*="27"], body[id="nv_search" i][onkeydown*="27"]') || getXpath('id("ft")[contains(string(),"Discuz!")]')) {
  286. console.info(`[自动无缝翻页] - <Discuz!> 论坛`); return 2;
  287.  
  288. } else if (typeof flarum != 'undefined' || getCSS('#flarum-loading')) {
  289. console.info(`[自动无缝翻页] - <Flarum> 论坛`); return 3;
  290.  
  291. } else if (typeof phpbb != 'undefined' || getCSS('body#phpbb')) {
  292. console.info(`[自动无缝翻页] - <phpBB> 论坛`); return 4;
  293.  
  294. } else if (typeof xn != 'undefined' && getXpath('//footer//a[contains(string(), "Xiuno")] | //link[contains(@href, "xiuno")] | //script[contains(@src, "xiuno")]')) {
  295. console.info(`[自动无缝翻页] - <Xiuno> 论坛`); return 5;
  296.  
  297. } else if (typeof XF != 'undefined') {
  298. console.info(`[自动无缝翻页] - <XenForo> 论坛`); return 6;
  299.  
  300. } else if (typeof MyBB != 'undefined') {
  301. console.info(`[自动无缝翻页] - <MyBB> 论坛`); return 14;
  302.  
  303. } else if (getCSS('head meta[name="generator" i][content="nexusphp" i]') || getXpath('id("footer")[contains(string(), "NexusPHP")]')) {
  304. console.info(`[自动无缝翻页] - <NexusPHP> 论坛`); return 7;
  305.  
  306. } else if (unsafeWindow.config && ((unsafeWindow.config.assetVersionEncoded && unsafeWindow.config.assetVersionEncoded.indexOf('gitea') !== -1) || (unsafeWindow.config.customEmojis && unsafeWindow.config.customEmojis.gitea))) {
  307. console.info(`[自动无缝翻页] - <Forgejo/Gitea> git 托管系统`); return 15;
  308.  
  309. } else if (loadMoreExclude(loadMoreExclude1) && getAllCSS('.load-more, .load_more, .loadmore, #load-more, #load_more, #loadmore, [id^="loadmore"], .show-more:not([data-gps-track]), .show_more, .ajax-more').length === 1) {
  310. console.info(`[自动无缝翻页] - 部分自带 自动无缝翻页 的网站 1`); return 8;
  311.  
  312. } else if (loadMoreExclude(loadMoreExclude2) && getAllXpath('//*[self::a or self::span or self::button or self::div][text()="加载更多"][not(@href) or @href="#" or starts-with(@href, "javascript")]').length === 1) {
  313. console.info(`[自动无缝翻页] - 部分自带 自动无缝翻页 的网站 2`); return 9;
  314.  
  315. } else if (getCSS('link[href*="/wp-content/" i], script[src*="/wp-content/" i], link[href*="/wp-includes/" i], script[src*="/wp-includes/" i], head>meta[name=generator][content*="WordPress" i]')) {
  316.  
  317. //if (getAllCSS('article[class], div[id^="post-"], ul[class*="post"]>li.item, .post').length < 4 || getCSS('#nav-below, nav.navigation, nav.paging-navigation, .pagination, .wp-pagenavi, .pagenavi')) return 0;
  318.  
  319. if (getXpath('(//*[contains(@class, "post-page-numbers") and contains(@class, "current")])[last()]/following-sibling::a[1]')) {
  320. DBSite.wp_article_post.pager.nextL = '(//*[contains(@class, "post-page-numbers") and contains(@class, "current")])[last()]/following-sibling::a[1]'; DBSite.wp_article_post.pager.replaceE = '//a[contains(@class,"post-page-numbers")]/..';
  321. } else if (getXpath('(//div[contains(@class,"fenye")])[last()]//a[string()="下一页"]')) {
  322. DBSite.wp_article_post.pager.nextL = '(//div[contains(@class,"fenye")])[last()]//a[string()="下一页"]'; DBSite.wp_article_post.pager.replaceE = '.fenye';
  323. }
  324. if (DBSite.wp_article_post.pager.nextL != undefined) {
  325. if (getAllCSS('#entry-content>#content-innerText, .entry-content>#content-innerText').length == 1) {
  326. DBSite.wp_article_post.pager.pageE = '#entry-content>#content-innerText, .entry-content>#content-innerText'
  327. } else if (getAllCSS('.entry-content .single-content img').length > 3) {
  328. DBSite.wp_article_post.pager.pageE = '.entry-content .single-content'
  329. } else if (getAllCSS('.entry-content').length == 1) {
  330. DBSite.wp_article_post.pager.pageE = '.entry-content>*:not(.wbp-cbm):not(.page-links):not(.post-links):not(.article-paging):not(.entry-pagination):not(.pagination):not(.fenye):not(.open-message):not(#social):not(.article-social):not(.single-cat-tag):not(.single-meta):not(#fontsize):not(.clear):not(.tg-m):not(.tg-site):not(footer)'
  331. } else if (getAllCSS('.article-content').length == 1) {
  332. DBSite.wp_article_post.pager.pageE = '.article-content>*:not(.page-links):not(.post-links):not(.article-paging):not(.entry-pagination):not(.pagination):not(.fenye):not(.open-message):not(#social):not(.article-social):not(.single-cat-tag):not(.single-meta):not(#fontsize):not(.clear):not(.tg-m):not(.tg-site):not(footer)'
  333. } else if (getAllCSS('article').length == 1) {
  334. DBSite.wp_article_post.pager.pageE = 'article>*:not(.page-links):not(.post-links):not(.article-paging):not(.entry-pagination):not(.pagination):not(.fenye):not(.open-message):not(#social):not(.article-social):not(.single-cat-tag):not(.single-meta):not(#fontsize):not(.clear):not(.tg-m):not(.tg-site):not(footer)'
  335. }
  336. if (DBSite.wp_article_post.pager.pageE != undefined) console.info(`[自动无缝翻页] - 部分使用 WordPress 的网站 - 文章内`); return 11;
  337. }
  338.  
  339.  
  340. if (getCSS('a.next, a.next-page')) {
  341. DBSite.wp_article.pager.nextL = 'a.next, a.next-page'
  342. } else if (getCSS('a[rel="next" i], a[aria-label="next" i], a[aria-label="下一个"].page-link, a[aria-label="Next Page" i], a[aria-label="下一页"], a[rel="下一页"], a[title="下一页"], a[aria-label="下一頁"], a[rel="下一頁"], a[title="下一頁"]')) {
  343. DBSite.wp_article.pager.nextL = 'a[rel="next" i], a[aria-label="next" i], a[aria-label="下一个"].page-link, a[aria-label="Next Page" i], a[aria-label="下一页"], a[rel="下一页"], a[title="下一页"], a[aria-label="下一頁"], a[rel="下一頁"], a[title="下一頁"]'
  344. } else if (getCSS('li.next-page > a, li.next > a, li.pagination-next>a')) {
  345. DBSite.wp_article.pager.nextL = 'li.next-page > a, li.next > a, li.pagination-next>a'
  346. } else if (getCSS('span.current+a')) {
  347. DBSite.wp_article.pager.nextL = 'span.current+a'
  348. } else if (getCSS('.nav-previous a, a.nav-previous')) {
  349. DBSite.wp_article.pager.nextL = '.nav-previous a, a.nav-previous'
  350. } else if (getCSS('.pagination>.page-item.active+li.page-item>a')) {
  351. DBSite.wp_article.pager.nextL = '.pagination>.page-item.active+li.page-item>a'
  352. } else {
  353. const temp_page = getCSS('#nav-below, nav.navigation, nav.paging-navigation, #pagination:not([class*="entry"]), .pagination:not([class*="entry"]), .wp-pagenavi, .pagenavi, nav[role="navigation"]')
  354. if (temp_page && getXpath('//a[contains(text(), "下一页") or contains(text(), "下一頁") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")]', temp_page)) {
  355. DBSite.wp_article.pager.nextL = '//*[self::ul or self::nav or self::div][@id="nav-below" or @id="pagination" or contains(@class, "navigation") or contains(@class, "pagination") or contains(@class, "pagenavi") or @role="navigation"]//a[contains(text(), "下一页") or contains(text(), "下一頁") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")]'
  356. }
  357. }
  358.  
  359. if (DBSite.wp_article.pager.nextL != undefined) {
  360. if (DBSite.wp_article.pager.nextL.indexOf('//') !== 0) DBSite.wp_article.pager.replaceE += ',' + DBSite.wp_article.pager.nextL
  361. if (getAllCSS('main').length == 1) {
  362. if (getAllCSS('main .posts-wrapper.row>div>article').length > 3) {
  363. DBSite.wp_article.pager.pageE = 'main .posts-wrapper.row>div'
  364. } else if (getAllXpath('//main//div[contains(@class,"row")]/div/article').length > 3) {
  365. DBSite.wp_article.pager.pageE = '//main//div[contains(@class,"row")]/div/article/parent::div'
  366. } else if (getAllCSS('main article[id^="post-"]').length > 3) {
  367. DBSite.wp_article.pager.pageE = 'main article[id^="post-"]'
  368. } else if (getAllCSS('main article[class]').length > 3) {
  369. DBSite.wp_article.pager.pageE = 'main article[class]'
  370. } else if (getAllCSS('main div[id^="post-"]').length > 3) {
  371. DBSite.wp_article.pager.pageE = 'main div[id^="post-"]'
  372. } else if (getAllCSS('main .post').length > 3) {
  373. DBSite.wp_article.pager.pageE = 'main .post'
  374. }
  375. if (DBSite.wp_article.pager.pageE != undefined) {console.info(`[自动无缝翻页] - 部分使用 WordPress 的网站`); return 10;}
  376. }
  377.  
  378. if (getAllCSS('.posts-wrapper.row>div>article').length > 3) {
  379. DBSite.wp_article.pager.pageE = '.posts-wrapper.row>div'
  380. } else if (getAllXpath('//div[contains(@class,"row")]/div/article').length > 3) {
  381. DBSite.wp_article.pager.pageE = '//div[contains(@class,"row")]/div/article/parent::div'
  382. } else if (getAllCSS('article[id^="post-"]').length > 3) {
  383. DBSite.wp_article.pager.pageE = 'article[id^="post-"]'
  384. } else if (getAllCSS('article[class]').length > 3) {
  385. DBSite.wp_article.pager.pageE = 'article[class]'
  386. } else if (getAllCSS('div[id^="post-"]').length > 3) {
  387. DBSite.wp_article.pager.pageE = 'div[id^="post-"]'
  388. } else if (getAllCSS('ul[class*="post"]>li.item').length > 3) {
  389. DBSite.wp_article.pager.pageE = 'ul[class*="post"]>li.item'
  390. } else if (getAllCSS('.post').length > 3) {
  391. DBSite.wp_article.pager.pageE = '.post'
  392. } else if (getAllCSS('.posts-row>posts[class*="post"]').length > 3) {
  393. DBSite.wp_article.pager.pageE = '.posts-row>posts[class*="post"]'
  394. } else if (getAllCSS('#posts, .posts').length == 1) {
  395. DBSite.wp_article.pager.pageE = '#posts, .posts'
  396. } else if (getAllCSS('#content .container>.row').length == 1 && getAllCSS('#content .container>.row+.nav-pagination').length == 1) {
  397. DBSite.wp_article.pager.pageE = '#content .container>.row'
  398. }
  399. if (DBSite.wp_article.pager.pageE != undefined) {console.info(`[自动无缝翻页] - 部分使用 WordPress 的网站`); return 10;}
  400. }
  401. } else if (getCSS('meta[name="template" i][content="handsome" i]') && getCSS('.page-navigator')) {
  402. console.info(`[自动无缝翻页] - 部分使用 Typecho 的网站 (handsome)`); return 12;
  403. } else if (getCSS('meta[name="template" i][content="Mirages" i]') && getCSS('.page-navigator')) {
  404. console.info(`[自动无缝翻页] - 部分使用 Typecho 的网站 (Mirages)`); return 13;
  405.  
  406. } else if (getCSS('.stui-page, .stui-page__item, #long-page, .myui-page, .myui-page__item')) {
  407. console.info(`[自动无缝翻页] - 部分影视网站`); return 300;
  408. } else if (getCSS('#page') && getCSS('.module-items,a.module-poster-item')) {
  409. console.info(`[自动无缝翻页] - 部分影视网站 2`); return 301;
  410.  
  411. } else if (getCSS('.ArticleImageBox, .PictureList') && getCSS('.article_page') && getXpath('//div[contains(@class,"article_page")]//a[text()="下一页"]')) {
  412. console.info(`[自动无缝翻页] - 部分美图网站 - 手机版`); return 302;
  413. } else if (getCSS('meta[content^=SearXNG i], link[href*=SearXNG i], script[src*=SearXNG i]')) {
  414. console.info(`[自动无缝翻页] - <SearXNG> 元搜索引擎`); return 303;
  415.  
  416. } else if (getCSS('.content > #content') && getXpath('//div[contains(@class,"page_chapter")]//a[text()="下一章"]')) {
  417. console.info(`[自动无缝翻页] - <笔趣阁 1> 模板的小说网站`); return 200;
  418. } else if (getCSS('#nr1, #chaptercontent, .Readarea, .ReadAjax_content') && getCSS('#pb_next, #linkNext')) {
  419. console.info(`[自动无缝翻页] - <笔趣阁 1 - 手机版> 模板的小说网站`); return 201;
  420. } else if (getCSS('#txt, .txt') && getCSS('#pb_next, .url_next') && getCSS('.chapter-control, .chapter-page-btn')) {
  421. console.info(`[自动无缝翻页] - <笔趣阁 2> 模板的小说网站`); return 202;
  422. } else if ((getCSS('meta[name="description" i][content*="小说"], meta[name="description" i][content*="章节"], meta[name="description" i][content*="阅读"], meta[name="keywords" i][content*="笔趣"]') || location.hostname.indexOf('biqu')!=-1 || document.title.match(/笔趣阁|小说|章/)!=null) && getXpath('//a[contains(text(), "下一章") or contains(text(), "下一页") or contains(text(), "下一节")]')) {
  423. let biquge3_pageE= ['[id="chapter_content" i]','[class~="chapter_content" i]','[id="chaptercontent" i]','[class~="chaptercontent" i]','[class~="read_chapterdetail" i]','[id="booktext" i]','[class~="booktext" i]','[id="txtcontent" i]','[class~="txtcontent" i]','[id="textcontent" i]','[class~="textcontent" i]','[id="read-content" i]','[class~="read-content" i]','[id="txtnav" i]','[class~="txtnav" i]','[id="txt" i][class~="txt" i]','[id="contents" i]','[class~="contents" i]','[id="content" i]','[class~="content" i]','[id="contentbox" i]']
  424. for(let biquge3_pageE_ of biquge3_pageE) {if (getAllCSS(biquge3_pageE_).length === 1) {DBSite.biquge3.pager.pageE = biquge3_pageE_;DBSite.biquge3.pager.insertP = [biquge3_pageE_,6];DBSite.biquge3.style = biquge3_pageE_+'>.readinline, ' + DBSite.biquge3.style;break;}}
  425. if (DBSite.biquge3.pager.pageE != undefined) {console.info(`[自动无缝翻页] - <笔趣阁 3> 模板的小说网站`); return 203;}
  426. }
  427. return 0;
  428. }
  429. // 判断网站类型
  430. function webTypeIf() {
  431. if (webType != 1) {
  432. switch (webType) {
  433. case 2: // < 所有 Discuz!论坛 >
  434. discuz_(); break;
  435. case 3: // < 所有 Flarum 论坛 >
  436. DBSite.flarum.url(); break;
  437. case 4: // < 所有 phpBB 论坛 >
  438. DBSite.phpbb.url(); break;
  439. case 5: // < 所有 Xiuno 论坛 >
  440. DBSite.xiuno.url(); break;
  441. case 6: // < 所有 XenForo 论坛 >
  442. DBSite.xenforo.url(); break;
  443. case 14: // < 所有 MyBB 论坛 >
  444. DBSite.mybb.url(); break;
  445. case 7: // < 所有 NexusPHP 论坛 >
  446. DBSite.nexusphp.url(); break;
  447. case 15: // < 所有 Forgejo/Gitea> git 托管系统 >
  448. DBSite.forgejoGitea.url(); break;
  449. case 8: // < 部分自带 自动无缝翻页 的网站 1 >
  450. DBSite.loadmore.url('.load-more, .load_more, .loadmore, #load-more, #load_more, #loadmore, [id^="loadmore"], .show-more, .show_more, .ajax-more'); break;
  451. case 9: // < 部分自带 自动无缝翻页 的网站 2 >
  452. DBSite.loadmore.url('//*[self::a or self::span or self::button or self::div][text()="加载更多"][not(@href) or @href="#" or starts-with(@href, "javascript")]'); break;
  453. case 10: // < 部分使用 WordPress 的网站 >
  454. DBSite.wp_article.url(); break;
  455. case 11: // < 部分使用 WordPress 的网站 - 文章内 >
  456. curSite = DBSite.wp_article_post; break;
  457. case 12: // < 部分使用 Typecho 的网站 (handsome) >
  458. DBSite.typecho_handsome.url(); break;
  459. case 13: // < 部分使用 Typecho 的网站 (Mirages) >
  460. DBSite.typecho_mirages.url(); break;
  461. case 200: // < 所有使用 笔趣阁 1 模板的小说网站 >
  462. DBSite.biquge1.url(); break;
  463. case 201: // < 所有使用 笔趣阁 1 - 手机版 模板的小说网站 >
  464. curSite = DBSite.biquge1_m; break;
  465. case 202: // < 所有使用 笔趣阁 2 模板的小说网站 >
  466. DBSite.biquge2.url(); break;
  467. case 203: // < 所有使用 笔趣阁 3 模板的小说网站 >
  468. curSite = DBSite.biquge3; break;
  469. case 300: // < 部分影视网站 >
  470. curSite = DBSite.yingshi; break;
  471. case 301: // < 部分影视网站 2 >
  472. curSite = DBSite.yingshi2; break;
  473. case 302: // < 部分美图网站 - 手机版 >
  474. curSite = DBSite.meinvtu_m; break;
  475. case 303: // < SearXNG 元搜索引擎 >
  476. document.cookie='infinite_scroll=1; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/';
  477. document.cookie='results_on_new_tab=1; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/';
  478. break;
  479. }
  480. }
  481. }
  482. // 内置翻页规则
  483. function setDBSite() {
  484. /*
  485. inherits: 继承标识,仅用于自定义规则,用于增删改某个外置规则的部分规则时,可使用该标识来省略不需要修改的规则,只写有变化的规则
  486.  
  487. url: 匹配到该域名后要执行的函数/正则(一般用于根据 URL 分配相应翻页规则)
  488. urlC: 对于使用 pjax 技术的网站,需要监听 URL 变化来重新判断翻页规则(需要放在 url: 中,自定义规则的话需要使用 fun.isUrlC())
  489.  
  490. noReferer: 获取下一页内容时,不携带 Referer(部分网站携带与不携带可能不一样)
  491. hiddenPN: 不显示脚本左下角的页码
  492. history: 添加历史记录 并 修改当前 URL(默认开启,对于不支持的网站要设置为 false)
  493. thread: 对于社区类网站,要在 帖子内 的规则中加入这个,用于脚本的 [帖子内自动翻页] 功能(即用户可以选择开启/关闭所有社区类网站帖子内的自动翻页)
  494. style: 要插入网页的 CSS Style 样式,当只需要单纯屏蔽部分网页元素时,可以只写 CSS 选择器省略掉 {display: none !important;}
  495. retry: 允许获取失败后重试
  496. blank: 强制新标签页打开链接
  497. 1 = 网页 <head> 添加 <base target="_blank"> 来让所有链接默认新标签页打开(对已单独指定 target 或已监听点击事件的元素无效)
  498. 2 = 对 <body> 委托点击事件
  499. 3 = 对 pageE 的父元素 委托点击事件(也会阻止冒泡,但因为距离 <a> 标签较远,因此只有在委托点击事件的元素是 pageE 的父元素的父元素时,才有意义)
  500. 4 = 对 pageE 的子元素 <a> 标签 添加 target="_blank"
  501. 5 = 对 pageE 的子元素 <a> 标签 清理事件后 再添加 target="_blank"
  502. 6 = 对 pageE 的子元素 <a> 标签 清理事件后 再添加 target="_blank" 并阻止冒泡(避免父元素事件委托捕获该元素的点击事件)
  503.  
  504. pager: {
  505. type: 翻页模式
  506. 1 = 由脚本实现自动无缝翻页,可省略(适用于:静态加载内容网站,常规模式)
  507.  
  508. 2 = 只需要点击下一页按钮(适用于:网站自带了 自动无缝翻页 功能)
  509. nextText: 按钮文本,当按钮文本 = 该文本时,才会点击按钮加载下一页(避免一瞬间加载太多次下一页,下同)
  510. nextTextOf: 按钮文本的一部分,当按钮文本包含该文本时,才会点击按钮加载下一页
  511. nextHTML: 按钮内元素,当按钮内元素 = 该元素内容时,才会点击按钮加载下一页
  512. interval: 点击间隔时间,对于没有按钮文字变化的按钮,可以手动指定间隔时间(省略后默认 500ms,当指定上面三个时,会忽略 interval)
  513. isHidden: 只有下一页按钮可见时(没有被隐藏),才会点击
  514.  
  515. 3 = 依靠 [基准元素] 与 [浏览器可视区域底部] 之间的距离缩小来触发翻页(适用于:主体元素下方内容太多 且 高度不固定时)
  516. scrollE: 作为基准线的元素(一般为底部页码元素),省略后默认等同 replaceE(如果这个也未指定则改用 nextL)
  517. scrollD: 当 [基准元素] 与 [可视区域底部] 之间的距离 等于或小于该值时,将触发翻页,省略后默认 2000
  518.  
  519. 4 = 动态加载类网站(适用于:简单的动态加载内容网站)
  520. insertE: 用来插入元素的函数
  521.  
  522. 5 = 插入 iframe 方式来加载下一页,无限套娃(适用于:部分动态加载内容的网站,需要允许 iframe 且支持通过 GET/POST 直接打开下一页)
  523. style: 加载 iframe 前要插入的 CSS Style 样式(比如为了悬浮的样式与下一页的重叠,隐藏网页底部间距提高阅读连续性)
  524. iframe: 这个必须加到 pager{} 外面(这样才会在该域名的 iframe 框架下运行脚本)
  525.  
  526. 6 = 通过 iframe 获取下一页动态加载内容插入本页,只有一个娃(适用于:部分动态加载内容的网站,与上面不同的是,该模式适合简单的网页,没有复杂事件什么的)
  527. loadTime: 预留的网页加载时间,确保网页内容加载完成(省略后默认为 300ms)
  528.  
  529. nextL: 下一页链接所在元素
  530. pageE: 要从下一页获取的元素
  531. insertP: 下一页元素插入本页的位置(数组第一个是基准元素,第二个是基准元素的前后具体位置)
  532. 1 = 插入基准元素自身的前面
  533. 2 = 插入基准元素内,第一个子元素前面
  534. 3 = 插入基准元素内,最后一个子元素后面
  535. 4 = 插入基准元素自身的后面
  536. 5 = 插入 pageE 列表最后一个元素的后面(该 insertP 可以直接省略不写,等同于 ['pageE', 5] )
  537. 6 = 插入该元素自身内部末尾(针对小说网站等文本类的),附带参数 insertP6Br: true, 用来中间插入换行
  538. // 小技巧:当基准元素是下一页主体元素的父元素时(或者说要将下一页元素插入到本页同元素最后一个后面时)是可以省略不写 insertP
  539. 例如:当 pageE: 'ul>li' 且 insertP: ['ul', 3] 时,实际等同于 ['ul>li', 5]
  540. 当 pageE: '.item' 且 insertP: ['.item', 4] 时,实际等同于 ['.item', 5]
  541. 当 pageE: '.item' 且 insertP: ['.page', 1] 时,实际等同于 ['.item', 5]
  542. 注意:如 pageE 中选择了多类元素,则不能省略 insertP(比如包含 `,` 与 `|` 符号),除非另外的选择器是 <script> <style> <link> 标签
  543.  
  544. replaceE: 要替换为下一页内容的元素(比如页码),省略后将会自动判断是替换 nextL 元素还是 nextL 的父元素(当 nextL 元素后面或前面有 <a> 的相邻兄弟元素时替换其父元素,反之替换其自身,仅限模式1/3/6,且 js 代码除外),值为空 "" 时则完全不替换
  545. scrollD: 当 [滚动条] 与 [网页底部] 之间的距离 等于或小于该值时,将触发翻页,因此值越大就越早触发翻页,访问速度慢的网站需要调大,可省略(记得移除上一行末尾逗号),省略后默认 2000
  546.  
  547. scriptT: 单独插入 <script> 标签
  548. 0 = 下一页的所有 <script> 标签
  549. 1 = 下一页的所有 <script> 标签(不包括 src 链接)
  550. 2 = 下一页主体元素 (pageE) 的同级 <script> 标签
  551. 3 = 下一页主体元素 (pageE) 的子元素 <script> 标签
  552.  
  553. interval: 翻页后间隔时间(省略后默认 500ms)
  554. forceHTTPS: 下一页链接强制 HTTPS
  555. },
  556. function: {
  557. bF = 插入前执行函数
  558. bFp = 参数
  559. aF = 插入后执行函数
  560. aFp = 参数
  561. }
  562. */ //<<< 规则简单说明 >>>
  563. DBSite = {
  564. loadmore: {
  565. ignore: true,
  566. url: function(nextL) {curSite = DBSite.loadmore; curSite.pager.nextL = nextL;},
  567. pager: {
  568. type: 2,
  569. isHidden: true,
  570. interval: 1000
  571. }
  572. }, // 部分自带 自动无缝翻页 的网站
  573. wp_article: {
  574. ignore: true,
  575. url: ()=> {
  576. if (!indexOF('/post/') && !getCSS('#comments, .comments-area, #disqus_thread')) {
  577. curSite = DBSite.wp_article;
  578. // 自适应瀑布流样式
  579. setTimeout(()=>{if (getOne(curSite.pager.pageE).style.cssText.indexOf('position: absolute') != -1){insStyle(curSite.pager.pageE + '{position: static !important; float: left !important; height: '+ parseInt(getCSS(curSite.pager.pageE).offsetHeight * 1.1) + 'px !important;}');}}, 1500);
  580. }
  581. },
  582. style: 'img[data-src], img[data-original] {opacity: 1 !important;}',
  583. blank: 3,
  584. pager: {
  585. replaceE: '#nav-below, nav.navigation, nav.paging-navigation, #pagination:not([class*="entry"]), .pagination:not([class*="entry"]), .wp-pagenavi, .pagenavi, nav[role="navigation"], ul[class*="-pagination"]',
  586. forceHTTPS: true,
  587. scrollD: 3000
  588. },
  589. function: {
  590. bF: src_bF
  591. }
  592. }, // 部分使用 WordPress 的网站
  593. wp_article_post: {
  594. ignore: true,
  595. pager: {
  596. type: 3,
  597. scrollD: 3000
  598. },
  599. function: {
  600. bF: src_bF
  601. }
  602. }, // 部分使用 WordPress 的网站 - 文章内
  603. typecho_handsome: {
  604. ignore: true,
  605. url: ()=> {if (getCSS('nav:not([id=comment-navigation]) .page-navigator')) {curSite = DBSite.typecho_handsome;}},
  606. blank: 3,
  607. pager: {
  608. nextL: '.page-navigator li.next>a',
  609. pageE: '.blog-post, .post-list',
  610. replaceE: '.page-navigator'
  611. }
  612. }, // 部分使用 Typecho 的网站 (handsome)
  613. typecho_mirages: {
  614. ignore: true,
  615. url: ()=> {if (getAllCSS('#index>article, #archive>article').length > 3 && getCSS('li.next')) {curSite = DBSite.typecho_mirages;}},
  616. blank: 3,
  617. pager: {
  618. nextL: 'li.next>a',
  619. pageE: '#index>article, #archive>article',
  620. scriptT: 3,
  621. replaceE: '.page-navigator'
  622. }
  623. }, // 部分使用 Typecho 的网站 (Mirages)
  624. biquge1: {
  625. ignore: true,
  626. url: ()=> {curSite = DBSite.biquge1;xs_bF(getAllCSS('.content > #content'),[/<br>.{0,10}秒记住.+$/, '']);},
  627. style: 'img, .posterror, a[href*="posterror()"], [style*="background"][style*="url("]:not(html):not(body), #content > *:not(br):not(p), #content>.readinline {display: none !important;}',
  628. history: true,
  629. retry: 3000,
  630. pager: {
  631. nextL: '//div[@class="page_chapter"]//a[text()="下一章"]',
  632. pageE: '.content > #content',
  633. insertP: ['.content > #content', 6],
  634. replaceE: '.page_chapter'
  635. },
  636. function: {
  637. bF: xs_bF,
  638. bFp: [/<br>.{0,10}秒记住.+$/, '']
  639. }
  640. }, // 笔趣阁 1 模板的小说网站
  641. biquge1_m: {
  642. ignore: true,
  643. style: 'img, .posterror, .show-app2, a[href*="posterror()"], [onclick*="location.href"], [style*="background"][style*="url("]:not(html):not(body), #nr1>*:not(br):not(p), #chaptercontent>*:not(br):not(p), .Readarea>*:not(br):not(p), .ReadAjax_content>*:not(br):not(p), #nr1>.readinline, #chaptercontent>.readinline, .Readarea>.readinline, .ReadAjax_content>.readinline {display: none !important;}',
  644. history: true,
  645. retry: 3000,
  646. pager: {
  647. nextL: '#pb_next, #linkNext',
  648. pageE: '#nr1, #chaptercontent, .Readarea, .ReadAjax_content',
  649. insertP: ['#nr1, #chaptercontent, .Readarea, .ReadAjax_content', 6],
  650. replaceE: '//a[@id="pb_next" or @id="linkNext"]/parent::*'
  651. }
  652. }, // 笔趣阁 1 - 手机版 模板的小说网站
  653. biquge2: {
  654. ignore: true,
  655. url: ()=> {if (isMobile() || getCSS('.chapter-page-btn') != null) {curSite = DBSite.biquge2_m;} else {curSite = DBSite.biquge2;}},
  656. style: 'img, .posterror, a[href*="posterror()"], [style*="background"][style*="url("]:not(html):not(body), #txt > *:not(br):not(p), #txt>.readinline, .txt>.readinline {display: none !important;}',
  657. history: true,
  658. retry: 3000,
  659. pager: {
  660. type: 6,
  661. nextL: '#pb_next, .url_next',
  662. pageE: '#txt, .txt',
  663. insertP: ['#txt, .txt', 6],
  664. replaceE: '.chapter-control, .chapter-page-btn',
  665. loadTime: 1500,
  666. scrollD: 3500
  667. }
  668. }, // 笔趣阁 2 模板的小说网站
  669. biquge2_m: {
  670. ignore: true,
  671. style: 'img, .posterror, a[href*="posterror()"], [style*="background"][style*="url("]:not(html):not(body), #txt > *:not(br):not(p), #txt>.readinline, .txt>.readinline {display: none !important;}',
  672. history: true,
  673. retry: 3000,
  674. pager: {
  675. nextL: '#pb_next, .url_next',
  676. pageE: '#txt, .txt',
  677. insertP: ['#txt, .txt', 6],
  678. replaceE: '.chapter-control, .chapter-page-btn'
  679. }
  680. }, // 笔趣阁 2 - 手机版 模板的小说网站
  681. biquge3: {
  682. ignore: true,
  683. style: 'img, .posterror, a[href*="posterror()"], [style*="background"][style*="url("]:not(html):not(body), script+div[style="padding:15px;"], p[style*="font-weight:"] {display: none !important;}',
  684. history: true,
  685. retry: 3000,
  686. pager: {
  687. nextL: 'js; const a=[fun.getNextE(\'(//a[contains(text(), "下一页")])[last()]\'),fun.getNextE(\'(//a[contains(text(), "下一章")])[last()]\'),fun.getNextE(\'(//a[contains(text(), "下一节")])[last()]\')];return a.find(i => i)',
  688. insertP6Br: false,
  689. replaceE: '//a[contains(text(), "下一章") or contains(text(), "下一页") or contains(text(), "下一节")]/parent::*'
  690. },
  691. function: {
  692. bF: xs_bF,
  693. bFp: [/<br>.{0,10}秒记住.+$/, '']
  694. }
  695. }, // 笔趣阁 3 模板的小说网站
  696. yingshi: {
  697. ignore: true,
  698. style: 'div.stui-page__all, div.myui-page__all {display: none !important;}',
  699. blank: 3,
  700. pager: {
  701. nextL: '.stui-page li.active+li>a, .stui-page__item li.active+li>a, #long-page .active+li>a, .myui-page .visible-xs+li>a',
  702. pageE: '.stui-vodlist, .myui-vodlist>li, #content, #searchList',
  703. replaceE: '.stui-page, .stui-page__item, #long-page, .myui-page, .myui-page__item'
  704. },
  705. function: {
  706. bF: src_bF,
  707. bFp: [1, '[data-original]', 'data-original']
  708. }
  709. }, // 部分影视网站
  710. yingshi2: {
  711. ignore: true,
  712. blank: 3,
  713. style: '.module-poster-item, .module-items>* {display: inline-block !important;}',
  714. pager: {
  715. nextL: '#page a[title="下一页"], a.page-next',
  716. pageE: '.module-items>*, a.module-poster-item',
  717. replaceE: '#page'
  718. },
  719. function: {
  720. bF: src_bF
  721. }
  722. }, // 部分影视网站 2
  723. meinvtu_m: {
  724. ignore: true,
  725. history: true,
  726. blank: 3,
  727. pager: {
  728. type: 3,
  729. nextL: '//div[contains(@class,"article_page")]//a[text()="下一页"]',
  730. pageE: '.ArticleImageBox, .PictureList',
  731. replaceE: '.article_page',
  732. scrollD: 500
  733. }
  734. }, // 部分美图网站 - 手机版
  735. discuz_forum: {
  736. ignore: true,
  737. pager: {
  738. type: 2,
  739. nextL: '#autopbn',
  740. interval: 800
  741. }
  742. }, // Discuz! 论坛 - 帖子列表(自带无缝加载下一页按钮的)
  743. discuz_guide: {
  744. ignore: true,
  745. pager: {
  746. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  747. pageE: 'tbody[id^="normalthread_"],tbody[id^="stickthread_"]',
  748. replaceE: '.pg, .pages',
  749. forceHTTPS: true
  750. }
  751. }, // Discuz! 论坛 - 导读页 及 帖子列表(不带无缝加载下一页按钮的,或存在按钮但只是单纯跳转下一页链接的)
  752. discuz_waterfall: {
  753. ignore: true,
  754. style: '.pgbtn',
  755. pager: {
  756. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  757. pageE: '#waterfall > li, #waterfall > dl',
  758. replaceE: '.pg, .pages',
  759. forceHTTPS: true
  760. }
  761. }, // Discuz! 论坛 - 图片模式的帖子列表(不带无缝加载下一页按钮的,或存在按钮但只是单纯跳转下一页链接的)
  762. discuz_thread: {
  763. ignore: true,
  764. thread: true,
  765. style: '.pgbtn, .viewthread:not(:first-of-type)>h1, .viewthread:not(:first-of-type)>ins, .viewthread:not(:first-of-type)>.headactions {display: none;}',
  766. pager: {
  767. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  768. pageE: '#postlist > div[id^="post_"], form>.viewthread',
  769. 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"))]]',
  770. forceHTTPS: true
  771. },
  772. function: {
  773. bF: src_bF,
  774. bFp: [0, 'img[file]', 'file']
  775. }
  776. }, // Discuz! 论坛 - 帖子内
  777. discuz_search: {
  778. ignore: true,
  779. pager: {
  780. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  781. pageE: '#threadlist > ul',
  782. replaceE: '.pg, .pages',
  783. forceHTTPS: true
  784. }
  785. }, // Discuz! 论坛 - 搜索页
  786. discuz_youspace: {
  787. ignore: true,
  788. pager: {
  789. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  790. pageE: 'form:not([action^="search.php?"]) tbody > tr:not(.th)',
  791. replaceE: '.pg, .pages',
  792. forceHTTPS: true
  793. }
  794. }, // Discuz! 论坛 - 回复页、主题页(别人的)
  795. discuz_collection: {
  796. ignore: true,
  797. pager: {
  798. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  799. pageE: '#ct .bm_c table > tbody',
  800. replaceE: '.pg, .pages',
  801. forceHTTPS: true
  802. }
  803. }, // Discuz! 论坛 - 淘帖页
  804. discuz_archiver: {
  805. ignore: true,
  806. pager: {
  807. nextL: '//div[@id="content"][last()]//div[@class="page"]/strong/following-sibling::a[1]',
  808. pageE: '#content'
  809. }
  810. }, // Discuz! 论坛 - 归档页
  811. discuz_m: {
  812. ignore: true,
  813. thread: true,
  814. pager: {
  815. nextL: '//a[@class="nxt" or @class="next"] | //div[@class="page"]/a[text()="下一页" or contains(text(), ">")]',
  816. replaceE: '.pg, .page',
  817. forceHTTPS: true,
  818. scrollD: 1000
  819. }
  820. }, // Discuz! 论坛 - 触屏手机版 - 帖子内
  821. discuz_m_forum: {
  822. ignore: true,
  823. pager: {
  824. type: 2,
  825. nextL: 'a.loadmore',
  826. interval: 500,
  827. scrollD: 1000
  828. }
  829. }, // Discuz! 论坛 - 触屏手机版 - 帖子列表(自带无缝加载下一页按钮的)
  830. flarum: {
  831. ignore: true,
  832. url: ()=> {urlC = true;if (!indexOF('/d/')) {if(getCSS('.DiscussionList-loadMore')){curSite = DBSite.flarum;}else if(getCSS('a.Button--primary')){curSite = DBSite.flarum2;}}},
  833. pager: {
  834. type: 2,
  835. nextL: '.DiscussionList-loadMore > button',
  836. isHidden: true
  837. }
  838. }, // Flarum 论坛
  839. flarum2: {
  840. ignore: true,
  841. blank: 4,
  842. pager: {
  843. type: 6,
  844. nextL: 'a.Button--primary+a:not(.disabled)',
  845. pageE: '.DiscussionList-discussions>li',
  846. replaceE: '.Orion-DiscussionListPagination'
  847. }
  848. }, // Flarum 论坛 - 带页码的
  849. phpbb: {
  850. ignore: true,
  851. url: ()=> {if (indexOF('/viewforum.php')) {
  852. curSite = DBSite.phpbb;
  853. } else if (indexOF('/viewtopic.php')) {
  854. curSite = DBSite.phpbb_post;
  855. } else if (indexOF('/search.php')) {
  856. curSite = DBSite.phpbb_search;
  857. }},
  858. pager: {
  859. nextL: '.pagination li.next a[rel="next"], .topic-actions .pagination strong~a',
  860. pageE: '.forumbg:not(.announcement) ul.topiclist.topics > li',
  861. replaceE: '.action-bar .pagination, .topic-actions .pagination'
  862. }
  863. }, // phpBB 论坛 - 帖子列表
  864. phpbb_post: {
  865. ignore: true,
  866. thread: true,
  867. pager: {
  868. nextL: '.pagination li.next a[rel="next"], .topic-actions .pagination strong~a',
  869. pageE: 'div.post[id], div.post[id]+hr',
  870. replaceE: '.action-bar .pagination, .topic-actions .pagination'
  871. }
  872. }, // phpBB 论坛 - 帖子内
  873. phpbb_search: {
  874. ignore: true,
  875. pager: {
  876. nextL: '.pagination li.next a[rel="next"], .topic-actions .pagination strong~a',
  877. pageE: 'div.search.post',
  878. replaceE: '.action-bar .pagination, .pagination'
  879. }
  880. }, // phpBB 论坛 - 搜索页
  881. xenforo: {
  882. ignore: true,
  883. url: ()=> {if (indexOF(/\/(forums|f)\//) || (getCSS(DBSite.xenforo.pager.nextL) && getCSS(DBSite.xenforo.pager.pageE))) {
  884. curSite = DBSite.xenforo;
  885. } else if (indexOF(/\/(threads|t)\//) || (getCSS(DBSite.xenforo.pager.nextL) && getCSS(DBSite.xenforo_post.pager.pageE))) {
  886. curSite = DBSite.xenforo_post;
  887. } else if (indexOF('/search/') || (getCSS(DBSite.xenforo.pager.nextL) && getCSS(DBSite.xenforo_search.pager.pageE))) {
  888. curSite = DBSite.xenforo_search;
  889. }},
  890. blank: 3,
  891. pager: {
  892. nextL: 'a.pageNav-jump--next',
  893. pageE: '.structItemContainer > div',
  894. replaceE: 'nav.pageNavWrapper',
  895. scrollD: 2500
  896. }
  897. }, // XenForo 论坛 - 帖子列表
  898. xenforo_post: {
  899. ignore: true,
  900. thread: true,
  901. pager: {
  902. nextL: 'a.pageNav-jump--next',
  903. pageE: '.block-body.js-replyNewMessageContainer > article',
  904. replaceE: 'nav.pageNavWrapper',
  905. scrollD: 2500
  906. }
  907. }, // XenForo 论坛 - 帖子内
  908. xenforo_search: {
  909. ignore: true,
  910. blank: 3,
  911. pager: {
  912. nextL: 'a.pageNav-jump--next',
  913. pageE: 'ol.block-body > li',
  914. replaceE: 'nav.pageNavWrapper',
  915. scrollD: 2500
  916. }
  917. }, // XenForo 论坛 - 搜索页
  918. mybb: {
  919. ignore: true,
  920. url: ()=> {if (location.pathname.toLowerCase().indexOf('/forum') == 0 || location.pathname.toLowerCase().indexOf('/search') == 0 || (getCSS(DBSite.mybb.pager.nextL)&&getCSS(DBSite.mybb.pager.pageE))) {
  921. curSite = DBSite.mybb;
  922. } else if (location.pathname.toLowerCase().indexOf('thread') !== -1 || (getCSS(DBSite.mybb.pager.nextL)&&getCSS(DBSite.mybb_post.pager.pageE))) {
  923. curSite = DBSite.mybb_post; curSite.pager = Object.assign({}, DBSite.mybb.pager,DBSite.mybb_post.pager);
  924. }},
  925. blank: 3,
  926. pager: {
  927. nextL: 'div:not([id=breadcrumb_multipage_popup])>a.pagination_next, div:not([id=breadcrumb_multipage_popup])>.pagination_current+a.pagination_page',
  928. pageE: 'tr.inline_row',
  929. replaceE: '.pagination',
  930. scrollD: 2500
  931. }
  932. }, // MyBB 论坛 - 帖子列表
  933. mybb_post: {
  934. ignore: true,
  935. thread: true,
  936. pager: {
  937. pageE: '#posts>*',
  938. scrollD: 2500
  939. }
  940. }, // MyBB 论坛 - 帖子内
  941. xiuno: {
  942. ignore: true,
  943. url: ()=> {if (lp == '/' || indexOF(/\/(index|forum)/)) {curSite = DBSite.xiuno;} else if (indexOF('/thread')) {curSite = DBSite.xiuno_post;}},
  944. pager: {
  945. nextL: '//li[@class="page-item"]/a[text()="▶" or text()="»" or contains(text(),">") or contains(text(),"下一页")]',
  946. pageE: 'ul.threadlist > li',
  947. replaceE: 'ul.pagination'
  948. }
  949. }, // Xiuno 论坛 - 帖子列表
  950. xiuno_post: {
  951. ignore: true,
  952. thread: true,
  953. pager: {
  954. nextL: '//li[@class="page-item"]/a[text()="▶" or text()="»" or contains(text(),">") or contains(text(),"下一页")]',
  955. pageE: 'li.post[data-pid]:not(.newpost)',
  956. replaceE: 'ul.pagination'
  957. }
  958. }, // Xiuno 论坛 - 帖子内
  959. forgejoGitea: {
  960. ignore: true,
  961. url: ()=> {if (indexOF(/^\/explore\/.+/) || indexOF(/\/(issues|pulls|releases|tags)$/) || indexOF(/\/commits\/branch\/.+/) || (getCSS('.pagination>.active+.item') && getCSS('.flex-list>.flex-item'))) {curSite = DBSite.forgejoGitea;}},
  962. pager: {
  963. nextL: '.pagination>.active+.item',
  964. pageE: '.flex-list>.flex-item, #issue-list>div, #release-list>li, tbody.tag-list>tr, tbody.commit-list>tr',
  965. replaceE: '.pagination'
  966. }
  967. }, // Forgejo/Gitea git 托管系统 - explore/issues/releases/tag/commit
  968. nexusphp: {
  969. ignore: true,
  970. url: ()=> {
  971. if (lp == '/torrents.php' || getCSS('table.torrents')) {
  972. curSite = DBSite.nexusphp;
  973. } else if (lp == '/subtitles.php') {
  974. curSite = DBSite.nexusphp;
  975. curSite.pager.pageE = '#outer > table.main~table > tbody > tr:not(:first-of-type)'
  976. } else if (lp == '/forums.php' && indexOF('action=viewforum', 's')) {
  977. curSite = DBSite.nexusphp;
  978. curSite.pager.pageE = '#outer > table.main+table > tbody > tr:not(:first-of-type):not(:last-of-type)'
  979. } else if (lp == '/forums.php' && indexOF('action=viewtopic', 's')) {
  980. curSite = DBSite.nexusphp;
  981. curSite.thread = true;
  982. curSite.pager.pageE = 'td.text > div, td.text > div+table.main';
  983. }},
  984. pager: {
  985. nextL: '//a[./b[contains(text(), "下一页") or contains(text(), ">>")]]',
  986. pageE: 'table.torrents > tbody > tr:not(:first-of-type)',
  987. replaceE: '//p[@align][./font[@class="gray"]]'
  988. }
  989. }, // NexusPHP 论坛
  990. nexusmods: {
  991. host: 'www.nexusmods.com',
  992. url: ()=> {urlC = true; if (indexOF(/\/(mods|users)\/\d+/)) {if (indexOF('tab=posts','s')){curSite = DBSite.nexusmods_posts;} else if (indexOF('tab=user+files','s')){curSite = DBSite.nexusmods;}} else if (lp !== '/' && getCSS('.pagination a.page-selected')) {curSite = DBSite.nexusmods;}},
  993. blank: 1,
  994. history: false,
  995. xRequestedWith: true,
  996. pager: {
  997. nextL: nexusmods_nextL,
  998. pageE: 'ul.tiles>li',
  999. replaceE: '.pagination',
  1000. scrollD: 3500
  1001. },
  1002. function: {
  1003. bF: nexusmods_bF
  1004. }
  1005. }, // NexusMods
  1006. nexusmods_posts: {
  1007. ignore: true,
  1008. history: false,
  1009. xRequestedWith: true,
  1010. pager: {
  1011. nextL: nexusmods_nextL,
  1012. pageE: '#comment-container>ol>li.comment:not(.comment-sticky)',
  1013. replaceE: '.pagination',
  1014. scrollD: 3500
  1015. }
  1016. }, // NexusMods posts
  1017. mangabz: {
  1018. host: ['mangabz.com', 'www.mangabz.com'],
  1019. url: ()=> {if (indexOF(/\/m\d+/)) {
  1020. setTimeout(mangabz_init, 1500);
  1021. curSite = DBSite.mangabz;
  1022. } else if (indexOF(/\/\d+bz\//)) {
  1023. if (getCSS('.detail-list-form-more')) getCSS('.detail-list-form-more').click();
  1024. } else if (indexOF('/manga-list') || lp == '/search') {
  1025. curSite = DBSite.mangabz_list;
  1026. }},
  1027. style: 'body > .container > div:not([id]) {display: none !important;} .top-bar {opacity: 0.3 !important;} #cp_img > img{display: block !important;margin: 0 auto !important; max-width: 99% !important; width: auto !important; height: auto !important;}',
  1028. pager: {
  1029. type: 4,
  1030. nextL: mangabz_nextL,
  1031. insertP: ['#cp_img', 3],
  1032. insertE: mangabz_insertE,
  1033. replaceE: 'p.top-title, body > .container > div:not([id])',
  1034. interval: 500
  1035. }
  1036. }, // Mangabz 漫画
  1037. mangabz_list: {
  1038. ignore: true,
  1039. blank: 4,
  1040. pager: {
  1041. nextL: '//div[contains(@class,"page-pagination")]//a[contains(text(), ">")]',
  1042. pageE: 'ul.mh-list > li',
  1043. replaceE: '.page-pagination',
  1044. scrollD: 800
  1045. }
  1046. }, // Mangabz 漫画 - 分类/搜索页
  1047. dm5: {
  1048. host: 'www.dm5.com',
  1049. url: ()=> {if (indexOF(/\/m\d+/)) {
  1050. setTimeout(mangabz_init, 1500);
  1051. curSite = DBSite.dm5;
  1052. } else if (indexOF('/manga-list') || lp == '/search' || getCSS('.box-body > ul.mh-list > li')) {
  1053. curSite = DBSite.mangabz_list;
  1054. } else if (getCSS('.detail-more')) {
  1055. getCSS('.detail-more').click();
  1056. }},
  1057. style: '.view-paging > .container, .view-comment {display: none !important;} .rightToolBar {opacity: 0.3 !important;} #cp_img > img, #barChapter > img{display: block !important;margin: 0 auto !important; max-width: 99% !important; width: auto !important; height: auto !important;} body {overflow: auto !important;}',
  1058. pager: {
  1059. type: 4,
  1060. nextL: dm5_nextL,
  1061. insertP: ['#barChapter,#cp_img', 3],
  1062. insertE: dm5_insertE,
  1063. replaceE: '.view-paging > .container, .rightToolBar',
  1064. interval: 500
  1065. }
  1066. }, // 动漫屋
  1067. xmanhua: {
  1068. host: ['xmanhua.com', 'www.xmanhua.com','yymanhua.com','www.yymanhua.com'],
  1069. url: ()=> {if (indexOF(/\/m\d+/)) {
  1070. setTimeout(mangabz_init, 1500);
  1071. if (location.hostname.indexOf('xmanhua') != -1){unsafeWindow.MH_PREFIX23 = 'XMANHUA_'}else{unsafeWindow.MH_PREFIX23 = 'YYMANHUA_'}
  1072. curSite = DBSite.xmanhua;
  1073. } else if (indexOF(/\/\d+xm\//)) {
  1074. if (getCSS('.detail-list-form-more')) getCSS('.detail-list-form-more').click();
  1075. } else if (indexOF('/manga-list') || lp == '/search') {
  1076. curSite = DBSite.xmanhua_list;
  1077. }},
  1078. style: 'a.reader-bottom-page {display: none !important;} .header, .reader-bottom {opacity: 0.3 !important;} #cp_img > img{display: block !important;margin: 0 auto !important; max-width: 99% !important; width: auto !important; height: auto !important;}',
  1079. hiddenPN: true,
  1080. pager: {
  1081. type: 4,
  1082. nextL: xmanhua_nextL,
  1083. insertP: ['#cp_img', 3],
  1084. insertE: xmanhua_insertE,
  1085. replaceE: '.reader-title, body > .container > div:not([id])',
  1086. interval: 500,
  1087. scrollD: 2500
  1088. }
  1089. }, // Xmanhua 漫画
  1090. xmanhua_list: {
  1091. ignore: true,
  1092. blank: 4,
  1093. pager: {
  1094. nextL: '//div[@class="page-pagination"]//a[contains(text(), ">")]',
  1095. pageE: 'ul.mh-list > li',
  1096. replaceE: '.page-pagination',
  1097. scrollD: 1000
  1098. }
  1099. } // Xmanhua 漫画 - 分类/搜索页
  1100. };
  1101. let _customRules = GM_getValue('menu_customRules', {}),
  1102. _rules = GM_getValue('menu_rules', {})
  1103. if (Object.prototype.toString.call(_customRules) !== '[object Object]') {_customRules={};}
  1104. if (Object.prototype.toString.call(_rules) !== '[object Object]') {_rules={};}
  1105. let _customRulesKeys = Object.keys(_customRules),
  1106. _rulesKeys = Object.keys(_rules)
  1107. // 合并 自定义规则、外置规则、内置规则(注:Object.assign 合并对象时,同名会后者覆盖前者)
  1108. if (_customRulesKeys.length === 0) { // 如果自定义规则为空,则直接合并 外置规则、内置规则
  1109. DBSite = Object.assign({}, _rules, DBSite);
  1110. DBSite2 = structuredClone(_rules); // DBSite2 是提供给 自定义翻页规则界面 - 所有规则 显示用的
  1111. } else { // 如果有自定义规则,为避免外置规则覆盖同名的自定义规则,要先判断并移除同名的外置规则
  1112. for (let i = 0; i < _customRulesKeys.length; i++) { // 循环 [自定义规则-对象名] 数组
  1113. if (_rulesKeys.indexOf(_customRulesKeys[i]) != -1) { // 在 [外置规则-对象名] 数组中,寻找是否有同名的 [自定义规则-对象名]
  1114. if (_customRules[_customRulesKeys[i]].inherits === true){ // 如果该同名的自定义规则对象含有 inherits 继承标识,则将同名的两者合并(自定义 覆盖 外置)
  1115. // 如果自定义规则中包含 "pager":{} 规则,则需要先合并 pager 后再去合并整体规则(否则 pager 会被自定义规则完整覆盖)
  1116. if (_customRules[_customRulesKeys[i]].pager != undefined && _rules[_customRulesKeys[i]].pager != undefined) {_customRules[_customRulesKeys[i]].pager = Object.assign({}, _rules[_customRulesKeys[i]].pager, _customRules[_customRulesKeys[i]].pager)}
  1117. _customRules[_customRulesKeys[i]] = Object.assign({}, _rules[_customRulesKeys[i]], _customRules[_customRulesKeys[i]]);
  1118. }
  1119. delete _rules[_customRulesKeys[i]] // 删除外置规则中的同名,这样后续合并时,外置规则才不会覆盖自定义规则的同名规则
  1120. };
  1121. }
  1122. DBSite = Object.assign({}, _customRules, _rules, DBSite);
  1123. DBSite2 = Object.assign({}, structuredClone(_customRules), structuredClone(_rules)); // 为了避免对象的后续变化影响 DBSite2 内容(如 SiteTypeID 等),需要对JSON对象变量进行深拷贝,使其完全独立
  1124. }
  1125.  
  1126. // 生成 SiteTypeID
  1127. setSiteTypeID();
  1128. //console.log(DBSite)
  1129. }
  1130. // 更新外置翻页规则
  1131. function getRulesUrl(update = false) {
  1132. // 如果是 旧版本的字符串时间格式(当前为数字格式)或 刚安装脚本(取不到值会返回字符串 '' 空),则需要立即更新
  1133. if (typeof(GM_getValue('menu_ruleUpdateTime', '')) == 'string') {update = true; if (scriptHandler != 'AdGuard') {alert('请点击【确定】开始首次获取【外置翻页规则】(大概几秒\n\n在此期间请不要 操作/跳转/关闭 当前网页~\n\n如果不小心没获取成功也没事,可以去脚本菜单中手动【更新外置翻页规则】即可(浏览器右上角 Tampermonkey 扩展图标内的脚本菜单\n\n\n另外,想要【临时暂停翻页】请点击左下角悬浮的【页码】按钮\n\n如果每次打开网页都会看到该提示,说明你的 油猴脚本管理器与本脚本之间 存在兼容性问题,请更换其他试试!');} else {urlArr2 = urlArr}}
  1134.  
  1135. if (update) { // 手动更新(或安装后首次更新)
  1136. GM_notification({text: '🔄 更新外置翻页规则中,请勿操作网页...', timeout: 5000});
  1137. getRulesUrl_(true);
  1138. } else if (parseInt(+new Date()/1000) - GM_getValue('menu_ruleUpdateTime', 0) > 5184000) {
  1139. getRulesUrl_();
  1140. }
  1141.  
  1142. function getRulesUrl_(n = false, url) {
  1143. if (n) {url = urlArr2[Math.floor(Math.random()*urlArr2.length)];} else {url = urlArr[Math.floor(Math.random()*urlArr.length)];}
  1144. if (url === undefined) {GM_notification({text: '❌ 所有更新地址均以试过,已无可用地址,请联系作者解决...', timeout: 5000}); return}
  1145. //console.log(url); return
  1146. GM_xmlhttpRequest({
  1147. url: url,
  1148. method: 'GET',
  1149. responseType: 'json',
  1150. overrideMimeType: 'application/json; charset=utf-8',
  1151. timeout: 4000,
  1152. onload: function (response) {
  1153. try {
  1154. //console.log('最终 URL:' + response.finalUrl, '返回内容:',response.status,response.response,response.responseText, response.responseHeaders)
  1155. if (response.status === 200 && response.response && Object.prototype.toString.call(response.response) === '[object Object]' && Object.keys(response.response).length > 100) {
  1156. GM_setValue('menu_rules', response.response); // 写入最新规则
  1157. GM_setValue('menu_ruleUpdateTime', parseInt(+new Date()/1000)); // 写入当前时间戳
  1158.  
  1159. curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码
  1160. registerMenuCommand(); // 重新判断规则
  1161.  
  1162. webTypeIf(); // 判断网站类型
  1163. if (!GM_getValue('menu_thread')) {if (curSite.thread) {curSite = {SiteTypeID: 0}; pageNum.now = 1;}} // 帖子内自动翻页判断
  1164. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码
  1165. if (curSite.blank != undefined) setTimeout(forceTarget, 1000); // 强制新标签页打开链接
  1166. if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式
  1167. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1168. pageLoading(); // 自动无缝翻页
  1169.  
  1170. if (n) GM_notification({text: '✅ 已更新外置翻页规则!\n如果依然无法翻页,说明还不支持当前网页,点击此处提交申请~', timeout: 5000, onclick: function(){GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});GM_openInTab('https://gf.qytechs.cn/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});}});
  1171. } else {
  1172. console.log('URL:' + url, response);
  1173. GM_notification({text: '❌ 为空!更新失败,请再试几次...\n如果依然更新失败,请联系作者解决...', timeout: 5000});
  1174. if (n) {urlArr2.splice(urlArr2.indexOf(url), 1)} else {urlArr.splice(urlArr.indexOf(url), 1)}
  1175. }
  1176. } catch (e) {
  1177. console.log('URL:' + url, e);
  1178. GM_notification({text: '❌ 报错!更新失败,请再试几次...\n如果依然更新失败,请联系作者解决...', timeout: 5000});
  1179. if (n) {urlArr2.splice(urlArr2.indexOf(url), 1)} else {urlArr.splice(urlArr.indexOf(url), 1)}
  1180. }
  1181. },
  1182. onerror: function (response) {
  1183. console.log('URL:' + url, response)
  1184. GM_notification({text: '❌ 错误!更新失败,请再试几次...\n如果依然更新失败,请联系作者解决...', timeout: 5000});
  1185. if (n) {urlArr2.splice(urlArr2.indexOf(url), 1)} else {urlArr.splice(urlArr.indexOf(url), 1)}
  1186. },
  1187. ontimeout: function (response) {
  1188. console.log('URL:' + url, response)
  1189. GM_notification({text: '❌ 超时!更新失败,请再试几次...\n如果依然更新失败,请联系作者解决...', timeout: 5000});
  1190. if (n) {urlArr2.splice(urlArr2.indexOf(url), 1)} else {urlArr.splice(urlArr.indexOf(url), 1)}
  1191. }
  1192. })
  1193. }
  1194. }
  1195.  
  1196.  
  1197. // --------------------------------------------------------
  1198.  
  1199.  
  1200. // 判断网站类型
  1201. webTypeIf();
  1202.  
  1203. // 帖子内自动翻页判断
  1204. if (!GM_getValue('menu_thread')) {if (curSite.thread) {curSite = {SiteTypeID: 0}; pageNum.now = 1;}}
  1205.  
  1206. //console.log(curSite)
  1207. // 显示页码
  1208. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');}
  1209. // 左键双击网页空白处暂停翻页
  1210. pausePageEvent();
  1211. // 强制新标签页打开链接
  1212. if (curSite.blank != undefined) setTimeout(forceTarget, 1000);
  1213. // 初始化事件
  1214. //if (curSite.initE != undefined) initEvent();
  1215.  
  1216. // 对于使用 pjax 技术的网站,需要监听 URL 变化来重新判断翻页规则
  1217. if (urlC) {
  1218. nowLocation = location.href
  1219. if (window.onurlchange === undefined) {addUrlChangeEvent();} // Tampermonkey v4.11 版本添加的 onurlchange 事件 grant,可以监控 pjax 等网页的 URL 变化
  1220. if (webType === 1) {
  1221. window.addEventListener('urlchange', function(){
  1222. lp = location.pathname;
  1223. //console.log(nowLocation, location.href)
  1224. if (curSite.history !== false && window.top.document.Autopage_nowUrl === location.href) {nowLocation = location.href; return}
  1225. if (nowLocation == location.href) return
  1226. if (curSite.pager && curSite.pager.type == 5) {
  1227. if (self != top) {window.top.location.href = location.href;} else {if (getCSS('iframe#Autopage_iframe')) {getCSS('iframe#Autopage_iframe').remove();}}
  1228. pausePage = true;
  1229. } // 对于翻页模式 5,如果是 iframe 框架内 URL 变动,则升级为顶级页面,如果是顶级页面的 URL 变动,则清理 iframe 框架
  1230. nowLocation = location.href; curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码
  1231. registerMenuCommand(); // 重新判断规则
  1232.  
  1233. //console.log(curSite);
  1234. if (curSite.blank != undefined) setTimeout(forceTarget, 1000); // 强制新标签页打开链接
  1235. //if (curSite.initE != undefined) initEvent(); // 初始化事件
  1236. if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式
  1237. if (!GM_getValue('menu_thread')) {if (curSite.thread) {curSite = {SiteTypeID: 0}; pageNum.now = 1;}} // 帖子内自动翻页判断
  1238. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码
  1239. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1240.  
  1241. pageLoading();
  1242. })
  1243. } else if (webType === 2) {
  1244. window.addEventListener('urlchange', function(){
  1245. lp = location.pathname;
  1246. //console.log(nowLocation, location.href)
  1247. if (nowLocation == location.href) return
  1248. setTimeout(function(){
  1249. nowLocation = location.href; curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码
  1250. discuz_(); // 重新判断规则
  1251.  
  1252. if (!GM_getValue('menu_thread')) {if (curSite.thread) {curSite = {SiteTypeID: 0}; pageNum.now = 1;}} // 帖子内自动翻页判断
  1253. if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式
  1254. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码
  1255. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1256.  
  1257. pageLoading();
  1258. }, 500)
  1259. })
  1260. } else if (webType === 3) {
  1261. window.addEventListener('urlchange', function(){
  1262. lp = location.pathname;
  1263. if (nowLocation == location.href) return
  1264. nowLocation = location.href; curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码
  1265. DBSite.flarum.url(); // 重新判断规则
  1266.  
  1267. if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式
  1268. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码
  1269. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1270.  
  1271. pageLoading();
  1272. })
  1273. }
  1274. }
  1275. // 插入 Style CSS 样式
  1276. if (curSite.style) insStyle(curSite.style)
  1277.  
  1278. // 自动无缝翻页
  1279. pageLoading();
  1280.  
  1281.  
  1282. // --------------------------------------------------------
  1283.  
  1284.  
  1285. // [Discuz! 论坛] 判断各版块帖子列表类型
  1286. function discuzForum(m) {
  1287. if (m == 'm') { // 手机版页面
  1288. if (getCSS('a.loadmore')) {
  1289. curSite = DBSite.discuz_m_forum;
  1290. } else if (getCSS('.threadlist')) {
  1291. curSite = DBSite.discuz_m; curSite.pager.pageE = '.threadlist > ul > li';
  1292. } else if (getCSS('[id^="normalthread_"]')) {
  1293. curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="normalthread_"]:not(.ZDlist)';
  1294. }
  1295. if (curSite.SiteTypeID !== 0 && location.hostname === 'keylol.com') {curSite.history = false; urlC = true;}
  1296. } else {
  1297. if (getCSS('#autopbn')) { // 判断是否有 [下一页] 按钮
  1298. curSite = DBSite.discuz_forum;
  1299. } else if (getCSS('#waterfall')) { // 判断是否为图片模式
  1300. if (!getCSS('#pgbtn.pgbtn>a[href^=javascript]')) { // 如果各版块帖子列表已存在这个元素,说明自带了无缝翻页
  1301. curSite = DBSite.discuz_waterfall; waterfallStyle(); // 图片模式列表样式预处理
  1302. }
  1303. } else {
  1304. curSite = DBSite.discuz_guide;
  1305. }
  1306. }
  1307. }
  1308. // [Discuz! 论坛] 判断手机版帖子内
  1309. function discuzThreadM() {
  1310. if (getCSS('[id^="pid"]')) {
  1311. curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="pid"], [id^="pid"]+div:not([id="post_new"])'
  1312. } else if (getCSS('[id^="post_"]')) {
  1313. curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="post_"]';
  1314. }
  1315. if (curSite.SiteTypeID !== 0 && location.hostname === 'keylol.com') {curSite.history = false; urlC = true;}
  1316. }
  1317. function discuz_() {
  1318. if (getCSS('body[id="nv_forum"][class^="pg_"][onkeydown*="27"]')) {
  1319. switch (getCSS('body[id="nv_forum"][class^="pg_"][onkeydown*="27"]').className) {
  1320. case 'pg_forumdisplay': // < 各版块帖子列表 >
  1321. discuzForum(); break;
  1322. case 'pg_viewthread': // < 帖子内 >
  1323. curSite = DBSite.discuz_thread; break;
  1324. case 'pg_guide': // < 导读帖子列表等 >
  1325. curSite = DBSite.discuz_guide; break;
  1326. case 'pg_collection': // < 淘贴列表 >
  1327. curSite = DBSite.discuz_collection; break;
  1328. }
  1329. }
  1330. // 如果上面没有匹配的则继续 < 搜索结果 >
  1331. if (curSite.SiteTypeID === 0) {
  1332. if (indexOF('search') || getCSS('body[id="nv_search"][onkeydown*="27"]')) {
  1333. if (indexOF('mobile=2', 's')) { // 手机版页面
  1334. curSite = DBSite.discuz_m; curSite.pager.pageE = '.threadlist > ul > li'; urlC = true;
  1335. } else {
  1336. curSite = DBSite.discuz_search;
  1337. }
  1338. }
  1339. }
  1340. // 如果上面没有匹配的则继续
  1341. if (curSite.SiteTypeID === 0) {
  1342. if (indexOF('.html')) { // 判断是不是静态网页(.html 结尾)
  1343. if (indexOF('/forum-')) { // < 各版块帖子列表 >
  1344. if (getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面
  1345. discuzForum('m');
  1346. } else {
  1347. discuzForum();
  1348. }
  1349. } else if (indexOF('/thread-')) { // < 帖子内 >
  1350. if (getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面
  1351. discuzThreadM();
  1352. } else {
  1353. curSite = DBSite.discuz_thread;
  1354. }
  1355. }
  1356. }
  1357. if (indexOF('/archiver/')) { // < 归档页 >
  1358. curSite = DBSite.discuz_archiver;
  1359. }
  1360. }
  1361. // 如果上面没有匹配的则继续
  1362. if (curSite.SiteTypeID === 0) {
  1363. if (indexOF('mod=forumdisplay', 's') || indexOF('forumdisplay.php')) { // < 各版块帖子列表 >
  1364. if (indexOF('mobile=2', 's') || indexOF('mobile=yes', 's') || getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面
  1365. discuzForum('m');
  1366. } else {
  1367. discuzForum();
  1368. }
  1369. } else if (indexOF('mod=viewthread', 's') || indexOF('viewthread.php')) { // < 帖子内 >
  1370. if (indexOF('mobile=2', 's') || getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面
  1371. discuzThreadM();
  1372. } else {
  1373. curSite = DBSite.discuz_thread;
  1374. }
  1375. } else if (indexOF('mod=guide', 's')) { // < 导读帖子列表 >
  1376. curSite = DBSite.discuz_guide;
  1377. } else if(indexOF('mod=space', 's') && indexOF('do=thread', 's')) { // 别人的主题/回复
  1378. curSite = DBSite.discuz_youspace;
  1379. } else if (indexOF('mod=collection', 's')) { // < 淘贴列表 >
  1380. curSite = DBSite.discuz_collection;
  1381. } else if (getCSS('#threadlist, tbody[id^="normalthread_"]')) { // < 部分论坛的各板块 URL 是自定义的 >
  1382. discuzForum();
  1383. } else if (getCSS('#postlist, form>.viewthread')) { // < 部分论坛的帖子内 URL 是自定义的 >
  1384. curSite = DBSite.discuz_thread;
  1385. } else if (isMobile()) { // 手机版判断
  1386. discuzForum('m');
  1387. if (curSite.SiteTypeID === 0) discuzThreadM();
  1388. }
  1389. }
  1390. }
  1391. // [Discuz! 论坛] 图片模式列表样式预处理
  1392. function waterfallStyle() {
  1393. let waterfall_ = getCSS('#waterfall > li:first-child');
  1394. if (waterfall_ && waterfall_.style && waterfall_.style.width) {
  1395. insStyle(`#waterfall {height: auto !important; width: 100% !important;} #waterfall > li {width: ${waterfall_.style.width} !important; float: left !important; position: inherit !important; left: auto !important; top: auto !important;}`);
  1396. } else {
  1397. waterfall_ = getAllCSS('#waterfall > dl');
  1398. if (waterfall_ && waterfall_.length > 5) {
  1399. insStyle(`#waterfall > dl {display: unset !important;}`);
  1400. }
  1401. }
  1402. }
  1403.  
  1404.  
  1405. // [NexusMods] 获取下一页地址
  1406. function nexusmods_nextL() {
  1407. if (getCSS('.nexus-ui-blocker') || !getCSS('.pagination a.page-selected')) return
  1408. let modList;
  1409. if (indexOF('/news')) {modList = RH_NewsTabContent;} else if (indexOF('/users/') && indexOF('tab=user+files','s')) {modList = RH_UserModsTab;} else if (indexOF('/mods/') && indexOF('tab=posts','s')) {modList = RH_CommentContainer;} else {modList = RH_ModList;}
  1410. if (!modList) return
  1411. let out_items = JSON.stringify(modList.out_items).replace(/{|}|"/g,''),
  1412. nextNum = getXpath('//div[contains(@class, "pagination")][1]//a[contains(@class, "page-selected")]/../following-sibling::li[1]/a');
  1413. var url = '';
  1414. if (nextNum && nextNum.innerText) {
  1415. nextNum = nextNum.innerText;
  1416. if (out_items.indexOf('page:') > -1) {out_items = out_items.replace(/page:\d+/, `page:${nextNum}`);} else {out_items += `,page:${nextNum}`;}
  1417. if (!indexOF(/\/(mods|users)\/\d+/)) { // MOD 页/用户页 不需要这些
  1418. let categories = modList.out_items.categories, tags_yes = modList.out_items.tags_yes, search = modList.out_items.search, out_items_sub = '';
  1419. if (categories && categories != []) { // 分类页
  1420. if (modList.out_items.categories instanceof Array) {// 单独使用时为数组
  1421. for (let i = 0; i < categories.length; i++) {out_items_sub += `categories[]:${categories[i]},`;}
  1422. } else {
  1423. for (let key in modList.out_items.categories) {out_items_sub += `categories[${key}]:${modList.out_items.categories[key]},`;}
  1424. }
  1425. if (out_items.indexOf('categories:') > -1) out_items = out_items.replace('categories:', out_items_sub)
  1426. }; out_items_sub='';
  1427. if (tags_yes && tags_yes != []) { // 标签页
  1428. if (modList.out_items.tags_yes instanceof Array) {// 单独使用时为数组
  1429. for (let i = 0; i < tags_yes.length; i++) {out_items_sub += `tags_yes[]:${tags_yes[i]},`;}
  1430. } else {
  1431. for (let key in modList.out_items.tags_yes) {out_items_sub += `tags_yes[${key}]:${modList.out_items.tags_yes[key]},`;}
  1432. }
  1433. if (out_items.indexOf('tags_yes:') > -1) out_items = out_items.replace('tags_yes:', out_items_sub)
  1434. }; out_items_sub='';
  1435. if (search && search.length != 0) { // 搜索页
  1436. for (let key in modList.out_items.search) {out_items_sub += `search[${key}]:${modList.out_items.search[key]},`;}
  1437. if (out_items.indexOf('search:') > -1) out_items = out_items.replace('search:',out_items_sub)
  1438. }; out_items_sub='';
  1439. }
  1440. //console.log(`https://www.nexusmods.com${modList.uri}?RH_${modList.id}=${out_items}`)
  1441. return `https://www.nexusmods.com${modList.uri}?RH_${modList.id}=${out_items}`
  1442. }
  1443. return ''
  1444. }
  1445. // [NexusMods] 的插入前函数(隐藏底部元素)
  1446. function nexusmods_bF(pageE) {
  1447. pageE.forEach(function (one) {
  1448. let now = one.querySelector('.mod-tile-left');
  1449. if (now) {
  1450. let downloadCount = now.querySelector('.downloadcount > span.flex-label');
  1451. if (downloadCount) {
  1452. if (GlobalModStats[now.dataset.gameId] && GlobalModStats[now.dataset.gameId][now.dataset.modId]) {
  1453. downloadCount.textContent = shortFormat(parseInt(GlobalModStats[now.dataset.gameId][now.dataset.modId].total));
  1454. }
  1455. }
  1456. }
  1457. });
  1458. return pageE
  1459. }
  1460.  
  1461.  
  1462. // [Mangabz 漫画] 初始化(调整本话图片)
  1463. function mangabz_init() {
  1464. if (getCSS('#showimage')) getCSS('#showimage').removeAttribute('oncontextmenu');
  1465. if (getCSS('#cp_img')) getCSS('#cp_img').removeAttribute('oncontextmenu');
  1466. if (getCSS('#barChapter')) getCSS('#barChapter').removeAttribute('oncontextmenu');
  1467. if (getCSS('#cp_image')) {
  1468. getCSS('#cp_image').removeAttribute('oncontextmenu');
  1469. getCSS('#cp_image').removeAttribute('style');
  1470. getCSS('#cp_image').removeAttribute('id');
  1471. }
  1472. }
  1473. // [Mangabz 漫画] 获取下一页地址
  1474. function mangabz_nextL() {
  1475. var url = '';
  1476. if (MANGABZ_PAGE === MANGABZ_IMAGE_COUNT) { // 下一话
  1477. if (getNextE_('//a[./img[contains(@src, "icon_xiayizhang")]]')) getPageE_(curSite.pageUrl); // 访问下一话 URL 获取
  1478. } else { // 下一页
  1479. if (!mkey) var mkey = '';
  1480. url = location.origin + location.pathname + 'chapterimage.ashx' + `?cid=${MANGABZ_CID}&page=${MANGABZ_PAGE + 1}&key=${(mkey)}&_cid=${MANGABZ_CID}&_mid=${MANGABZ_MID}&_dt=${MANGABZ_VIEWSIGN_DT}&_sign=${MANGABZ_VIEWSIGN}`
  1481. if (url === curSite.pageUrl) return
  1482. curSite.pageUrl = url
  1483. //console.log(curSite.pageUrl)
  1484. getPageE_(curSite.pageUrl, 'text', 'GET', '', 'Next'); // 访问下一页 URL 获取
  1485. }
  1486. }
  1487. // [Mangabz 漫画] 插入数据
  1488. function mangabz_insertE(pageE, type) {
  1489. if (pageE) {
  1490. if (type === 'Next') { // 下一页
  1491. let imgArr = eval(pageE),
  1492. _img = '';
  1493. for (let now of imgArr) {_img += `<img src="${now}">`;}
  1494. if (_img) {
  1495. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  1496. MANGABZ_PAGE += imgArr.length;
  1497. addHistory(pageE, document.title, location.origin + MANGABZ_CURL.substring(0, MANGABZ_CURL.length - 1) + '-p' + MANGABZ_PAGE + '/');
  1498. }
  1499. } else { // 下一话
  1500. // 插入 <script> 标签
  1501. insScript('html:not([dir]) > head > script:not([src])', pageE);
  1502. addHistory(pageE);
  1503. pageNumIncrement()
  1504. replaceElems(pageE)
  1505. MANGABZ_PAGE = 0;
  1506. mangabz_nextL();
  1507. }
  1508. }
  1509. }
  1510.  
  1511.  
  1512. // [动漫屋] 获取下一页地址
  1513. function dm5_nextL() {
  1514. var url = '';
  1515. if (DM5_PAGE === DM5_IMAGE_COUNT) { // 下一话
  1516. if (getNextE_('//div[@class="view-paging"]//a[text()="下一章"]')) getPageE_(curSite.pageUrl); // 访问下一话 URL 获取
  1517. } else { // 下一页
  1518. if (!mkey) var mkey = '';
  1519. url = location.origin + location.pathname + 'chapterfun.ashx' + `?cid=${DM5_CID}&page=${DM5_PAGE + 1}&key=${(mkey)}&language=1&gtk=6&_cid=${DM5_CID}&_mid=${DM5_MID}&_dt=${DM5_VIEWSIGN_DT}&_sign=${DM5_VIEWSIGN}`
  1520. if (url === curSite.pageUrl) return
  1521. curSite.pageUrl = url
  1522. //console.log(curSite.pageUrl)
  1523. getPageE_(curSite.pageUrl, 'text', 'GET', '', 'Next'); // 访问下一页 URL 获取
  1524. }
  1525. }
  1526. // [动漫屋] 插入数据
  1527. function dm5_insertE(pageE, type) {
  1528. if (pageE) {
  1529. if (type === 'Next') { // 下一页
  1530. let imgArr = eval(pageE),
  1531. _img = '';
  1532. for (let now of imgArr) {_img += `<img src="${now}">`;}
  1533. if (_img) {
  1534. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  1535. DM5_PAGE += imgArr.length;
  1536. addHistory(pageE, document.title, location.origin + DM5_CURL.substring(0, DM5_CURL.length - 1) + '-p' + DM5_PAGE + '/');
  1537. }
  1538. } else { // 下一话
  1539. // 插入 <script> 标签
  1540. insScript('html:not([dir])>head>script:not([src])', pageE);
  1541. addHistory(pageE);
  1542. pageNumIncrement()
  1543. replaceElems(pageE)
  1544. DM5_PAGE = 0;
  1545. dm5_nextL();
  1546. }
  1547. }
  1548. }
  1549.  
  1550.  
  1551. // [Xmanhua 漫画] 获取下一页地址
  1552. function xmanhua_nextL() {
  1553. var url = '';
  1554. if (unsafeWindow[unsafeWindow.MH_PREFIX23+'PAGE'] === unsafeWindow[unsafeWindow.MH_PREFIX23+'IMAGE_COUNT']) { // 下一话
  1555. if (getNextE_('//a[./img[contains(@src, "reader-bottom-right-2.png")]]')) getPageE_(curSite.pageUrl); // 访问下一话 URL 获取
  1556. } else { // 下一页
  1557. if (!mkey) var mkey = '';
  1558. url = location.origin + location.pathname + 'chapterimage.ashx' + `?cid=${unsafeWindow[unsafeWindow.MH_PREFIX23+'CID']}&page=${unsafeWindow[unsafeWindow.MH_PREFIX23+'PAGE'] + 1}&key=${(mkey)}&_cid=${unsafeWindow[unsafeWindow.MH_PREFIX23+'_CID']}&_mid=${unsafeWindow[unsafeWindow.MH_PREFIX23+'MID']}&_dt=${unsafeWindow[unsafeWindow.MH_PREFIX23+'VIEWSIGN_DT']}&_sign=${unsafeWindow[unsafeWindow.MH_PREFIX23+'VIEWSIGN']}`
  1559. if (url === curSite.pageUrl) return
  1560. curSite.pageUrl = url
  1561. //console.log(curSite.pageUrl)
  1562. getPageE_(curSite.pageUrl, 'text', 'GET', '', 'Next'); // 访问下一页 URL 获取
  1563. }
  1564. }
  1565. // [Xmanhua 漫画] 插入数据
  1566. function xmanhua_insertE(pageE, type) {
  1567. if (pageE) {
  1568. if (type === 'Next') { // 下一页
  1569. let imgArr = eval(pageE),
  1570. _img = '';
  1571. for (let now of imgArr) {_img += `<img src="${now}">`;}
  1572. if (_img) {
  1573. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  1574. unsafeWindow[unsafeWindow.MH_PREFIX23+'PAGE'] += imgArr.length;
  1575. addHistory(pageE, document.title, location.origin + unsafeWindow[unsafeWindow.MH_PREFIX23+'CURL'].substring(0, unsafeWindow[unsafeWindow.MH_PREFIX23+'CURL'].length - 1) + '-p' + unsafeWindow[unsafeWindow.MH_PREFIX23+'PAGE'] + '/');
  1576. }
  1577. } else { // 下一话
  1578. // 插入 <script> 标签
  1579. insScript('html:not([dir]) > head > script:not([src])', pageE);
  1580. addHistory(pageE);
  1581. pageNumIncrement()
  1582. replaceElems(pageE)
  1583. unsafeWindow[unsafeWindow.MH_PREFIX23+'PAGE'] = 0;
  1584. xmanhua_nextL();
  1585. }
  1586. }
  1587. }
  1588.  
  1589.  
  1590. // --------------------------------------------------------
  1591.  
  1592.  
  1593. // 自动无缝翻页
  1594. function pageLoading() {
  1595. if (curSite.SiteTypeID === 0 || !curSite.pager) return
  1596. if (curSite.pager.type === undefined) curSite.pager.type = 1; // 默认翻页模式 1
  1597. if (curSite.pager.scrollD === undefined) curSite.pager.scrollD = 2000; // 默认翻页触发线 2000
  1598. if (curSite.pager.interval === undefined) curSite.pager.interval = 500; // 默认间隔时间 500ms
  1599. /*if (curSite.pager.replaceE === undefined) { // 如果 replaceE 不存在,则默认替换 nextL
  1600. if ((curSite.pager.type === 1 || curSite.pager.type === 3 || curSite.pager.type === 6) && curSite.pager.nextL && typeof curSite.pager.nextL !== 'function' && curSite.pager.nextL.search(/^js;/i) !== 0) {
  1601. curSite.pager.replaceE = curSite.pager.nextL
  1602. }
  1603. }*/
  1604. //console.log(curSite)
  1605. curSite.pageUrl = ''; // 下一页URL
  1606. windowScroll(function (direction, e) {
  1607. // 下滑 且 未暂停翻页 且 SiteTypeID > 0 时,才准备翻页
  1608. if (direction != 'down' || !pausePage || curSite.SiteTypeID == 0) return
  1609.  
  1610. // 翻页模式 5 且为框架内时,要判断顶层是否通过页码暂停翻页了
  1611. if (curSite.pager.type == 5 && self != top && window.top.document.xiu_pausePage == false) return
  1612.  
  1613. let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop,
  1614. scrollHeight = window.innerHeight || document.documentElement.clientHeight,
  1615. scrollD = curSite.pager.scrollD;
  1616. // <<<<< 翻页类型 3(依靠 [基准元素] 与 [浏览器可视区域底部] 之间的距离缩小来触发翻页)>>>>>
  1617. if (curSite.pager.type === 3) {
  1618. if (!curSite.pager.scrollE) { // 当 scrollE 未指定时
  1619. if(curSite.pager.replaceE) { // 如果指定了 replaceE,则默认 scrollE 为 replaceE
  1620. curSite.pager.scrollE = curSite.pager.replaceE;
  1621. } else { // 如果 replaceE 也未指定,则默认 scrollE 为 nextL
  1622. curSite.pager.scrollE = curSite.pager.nextL;
  1623. }
  1624. }
  1625. let scrollE = getOne(curSite.pager.scrollE);
  1626. //console.log(scrollE.offsetTop, scrollE.offsetTop - (scrollTop + scrollHeight), scrollD, scrollTop + scrollHeight, curSite.SiteTypeID)
  1627. if (scrollE.offsetTop - (scrollTop + scrollHeight) <= scrollD) {intervalPause(); checkURL(getPageE);}
  1628.  
  1629. } else if (document.documentElement.scrollHeight <= scrollHeight + scrollTop + scrollD) {
  1630. // <<<<< 翻页类型 1(由脚本实现自动无缝翻页)>>>>>
  1631. if (curSite.pager.type === 1) {
  1632. intervalPause(); checkURL(getPageE);
  1633.  
  1634. // <<<<< 翻页类型 2(网站自带了自动无缝翻页功能,只需要点击下一页按钮即可)>>>>>
  1635. } else if (curSite.pager.type === 2) {
  1636. let autopbn = getOne(curSite.pager.nextL);
  1637. if (!autopbn) return
  1638. if (curSite.pager.isHidden && isHidden(autopbn)) return // 如果 isHidden = true,那么需要判断元素是否隐藏
  1639. if (curSite.pager.nextText) {
  1640. //console.log(curSite.pager.nextText, autopbn.innerText, autopbn)
  1641. // 按钮文本,当按钮文本 = 该文本时,才会点击按钮加载下一页
  1642. if (autopbn.innerText === curSite.pager.nextText) {autopbn.click(); pageNumIncrement();}
  1643. } else if (curSite.pager.nextTextOf) {
  1644. // 按钮文本的一部分,当按钮文本包含该文本时,才会点击按钮加载下一页
  1645. if (autopbn.innerText.indexOf(curSite.pager.nextTextOf) > -1) {autopbn.click(); pageNumIncrement();}
  1646. } else if (curSite.pager.nextHTML) {
  1647. // 按钮内元素,当按钮内元素 = 该元素内容时,才会点击按钮加载下一页
  1648. if (autopbn.innerHTML === curSite.pager.nextHTML) {autopbn.click(); pageNumIncrement();}
  1649. } else {
  1650. intervalPause();
  1651. // 如果没有指定按钮文字就直接点击
  1652. autopbn.click(); pageNumIncrement();
  1653. }
  1654.  
  1655. // <<<<< 翻页类型 4(部分简单的动态加载类网站)>>>>>
  1656. } else if (curSite.pager.type === 4) {
  1657. intervalPause(); if (typeof curSite.pager.nextL == 'function') {curSite.pager.nextL();} else if (getNextE_(curSite.pager.nextL)) {getPageE_(curSite.pageUrl);}
  1658.  
  1659. // <<<<< 翻页类型 5(插入 iframe 方式来加载下一页)>>>>>
  1660. } else if (curSite.pager.type === 5) {
  1661. checkURL(insIframe);
  1662.  
  1663. // <<<<< 翻页类型 6(通过 iframe 获取下一页动态加载内容)>>>>>
  1664. } else if (curSite.pager.type === 6) {checkURL(insIframe_);}
  1665. }
  1666. });
  1667.  
  1668. function intervalPause() {
  1669. if (curSite.pager.interval) {
  1670. pausePage = false
  1671. setTimeout(function(){pausePage = true;}, curSite.pager.interval)
  1672. }
  1673. }
  1674. }
  1675.  
  1676. // 翻页类型 1/3
  1677. function getPageE(url) {
  1678. if (!curSite.gmxhr) {
  1679. // 依靠原生 XMLHttpRequest 尝试解决因缺失跨域 cookie 导致的问题(比如一些使用 Cloudflare CDN 人机验证的网站,会出现脚本后台获取到人机验证页面)
  1680. const xhr = new XMLHttpRequest();
  1681. xhr.open('GET', url, true);
  1682. xhr.overrideMimeType('text/html; charset=' + (document.characterSet||document.charset||document.inputEncoding));
  1683.  
  1684. if (curSite.xRequestedWith === true) {xhr.setRequestHeader('x-requested-with', 'XMLHttpRequest')}
  1685. //(curSite.noReferer === true) ? xhr.setRequestHeader('Referer', ''):xhr.setRequestHeader('Referer', location.href)
  1686. xhr.setRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml')
  1687.  
  1688. xhr.timeout = 5000;
  1689. xhr.onload = function() {
  1690. try {
  1691. //console.log('URL:' + url, '最终 URL:' + xhr.responseURL, '返回内容:' + xhr.responseText)
  1692. processElems(createDocumentByString(xhr.responseText));
  1693. } catch (e) {
  1694. console.error('[自动无缝翻页] - 处理获取到的下一页内容时出现问题,请检查!\n', e, '\nURL:' + url, '\n最终 URL:' + xhr.responseURL, '\n返回状态:' + xhr.statusText, '\n返回内容:' + xhr.responseText);
  1695. }
  1696. };
  1697. xhr.onerror = function() {
  1698. console.log('URL:' + url, xhr.statusText)
  1699. GM_notification({text: '❌ 获取下一页失败...', timeout: 5000});
  1700. };
  1701. xhr.ontimeout = function() {
  1702. setTimeout(function(){curSite.pageUrl = '';}, 3000)
  1703. console.log('URL:' + url, xhr.statusText)
  1704. GM_notification({text: '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...', timeout: 5000});
  1705. };
  1706. xhr.send();
  1707. } else {
  1708. GM_xmlhttpRequest({
  1709. url: url,
  1710. method: 'GET',
  1711. overrideMimeType: 'text/html; charset=' + (document.characterSet||document.charset||document.inputEncoding),
  1712. headers: {
  1713. 'x-requested-with': (curSite.xRequestedWith === true) ? 'XMLHttpRequest':null,
  1714. 'Referer': (curSite.noReferer === true) ? null:location.href,
  1715. 'Accept': 'text/html,application/xhtml+xml,application/xml'
  1716. },
  1717. timeout: 5000,
  1718. onload: function (response) {
  1719. try {
  1720. //console.log('URL:' + url, '最终 URL:' + response.finalUrl, '返回内容:' + response.responseText)
  1721. processElems(createDocumentByString(response.responseText));
  1722. } catch (e) {
  1723. console.error('[自动无缝翻页] - 处理获取到的下一页内容时出现问题,请检查!\n', e, '\nURL:' + url, '\n最终 URL:' + response.finalUrl, '\n返回状态:' + response.statusText, '\n返回内容:' + response.responseText);
  1724. }
  1725. },
  1726. onerror: function (response) {
  1727. console.log('URL:' + url, response)
  1728. GM_notification({text: '❌ 获取下一页失败...', timeout: 5000});
  1729. },
  1730. ontimeout: function (response) {
  1731. setTimeout(function(){curSite.pageUrl = '';}, 3000)
  1732. console.log('URL:' + url, response)
  1733. GM_notification({text: '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...', timeout: 5000});
  1734. }
  1735. });
  1736. }
  1737. }
  1738. // 翻页类型 4
  1739. function getPageE_(url, type = '', method = 'GET', data = '', type2) {
  1740. let mimeType,accept;
  1741. switch (type) {
  1742. case 'json':
  1743. accept = 'application/json'; mimeType = 'application/json; charset=' + (document.characterSet||document.charset||document.inputEncoding); break;
  1744. case 'text':
  1745. accept = 'text/plain'; mimeType = 'text/plain; charset=' + (document.characterSet||document.charset||document.inputEncoding); break;
  1746. default:
  1747. accept = 'text/html,application/xhtml+xml,application/xml'; mimeType = 'text/html; charset=' + (document.characterSet||document.charset||document.inputEncoding);
  1748. }
  1749.  
  1750. GM_xmlhttpRequest({
  1751. url: url,
  1752. method: method,
  1753. data: data,
  1754. responseType: type,
  1755. overrideMimeType: mimeType,
  1756. headers: {
  1757. 'Referer': (curSite.noReferer === true) ? null:location.href,
  1758. 'Content-Type': (method === 'POST') ? 'application/x-www-form-urlencoded':'',
  1759. 'Accept': accept
  1760. },
  1761. timeout: 5000,
  1762. onload: function (response) {
  1763. try {
  1764. //console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText)
  1765. switch (type) {
  1766. case 'json':
  1767. curSite.pager.insertE(response.response, type2);
  1768. break;
  1769. case 'text':
  1770. curSite.pager.insertE(response.responseText, type2)
  1771. break;
  1772. default:
  1773. curSite.pager.insertE(createDocumentByString(response.responseText), type2)
  1774. }
  1775. } catch (e) {
  1776. console.log(e);
  1777. }
  1778. },
  1779. onerror: function (response) {
  1780. setTimeout(function(){curSite.pageUrl = '';}, 3000)
  1781. console.log('URL:' + url, response)
  1782. GM_notification({text: '❌ 获取下一页失败,可 3 秒后再次滚动网页重试(或尝试刷新网页)...', timeout: 5000});
  1783. },
  1784. ontimeout: function (response) {
  1785. setTimeout(function(){curSite.pageUrl = '';}, 3000)
  1786. console.log('URL:' + url, response)
  1787. GM_notification({text: '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...', timeout: 5000});
  1788. }
  1789. });
  1790. }
  1791. // 翻页类型 5(插入 iframe 方式加载下一页,无限套娃)
  1792. function insIframe(src) {
  1793. // 停用当前页面翻页
  1794. if (curSite.SiteTypeID == 0) return
  1795. curSite.SiteTypeID = 0;
  1796.  
  1797. // 创建 iframe
  1798. let iframe = document.createElement('iframe');
  1799. iframe.id = 'Autopage_iframe';
  1800. iframe.src = src.replace(/#.+$/,'');
  1801.  
  1802. document.documentElement.appendChild(document.createElement('style')).textContent = 'iframe#Autopage_iframe {position: absolute !important; width: 100% !important; height: 100% !important; border: none !important;}';
  1803.  
  1804. var beforeScrollTop = document.documentElement.scrollTop || document.body.scrollTop
  1805. // 当滚动条到底部时(即完全显示 iframe 框架),隐藏当前页面的滚动条
  1806. window.addEventListener('scroll', function () {
  1807. let scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  1808. clientHeight = document.documentElement.clientHeight || document.body.clientHeight,
  1809. scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight,
  1810. afterScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  1811. delta = afterScrollTop - beforeScrollTop;
  1812. if (delta == 0) return false;
  1813. beforeScrollTop = afterScrollTop;
  1814.  
  1815. //console.log(delta, (scrollTop + clientHeight + 10), scrollHeight, '1111')
  1816. if (delta > 0 && scrollTop + clientHeight + 10 >= scrollHeight && !getCSS('#Autopage_iframe-scroll')) {
  1817. let newStyle = document.createElement('style'); newStyle.id = 'Autopage_iframe-scroll';
  1818. newStyle.textContent = 'html::-webkit-scrollbar, body::-webkit-scrollbar {width: 0 !important;height: 0 !important;} html, body {scrollbar-width: none !important;}';
  1819. if (curSite.pager.style) newStyle.textContent += curSite.pager.style;
  1820. document.documentElement.appendChild(newStyle);
  1821.  
  1822. // 恢复 iframe 的滚动条
  1823. if (iframe.contentWindow.document.querySelectorAll('#Autopage_iframe-scroll-hidden')) iframe.contentWindow.document.querySelectorAll('#Autopage_iframe-scroll-hidden').forEach((o)=>{o.remove();});
  1824.  
  1825. // 给予 iframe 焦点
  1826. iframe.focus();
  1827. if (iframe.contentWindow.document.body) {iframe.contentWindow.document.body.focus(); iframe.contentWindow.document.body.click();}
  1828. } else if (delta < 0 && scrollTop + clientHeight + 10 <= scrollHeight && getCSS('#Autopage_iframe-scroll')) {
  1829. getCSS('#Autopage_iframe-scroll').remove();
  1830. // 再次禁用 iframe 的滚动条
  1831. if (!iframe.contentWindow.document.getElementById('Autopage_iframe-scroll-hidden')) {
  1832. let newStyle = document.createElement('style'); newStyle.id = 'Autopage_iframe-scroll-hidden';
  1833. newStyle.textContent = 'html, body {overflow: hidden !important;}';
  1834. iframe.contentWindow.document.documentElement.appendChild(newStyle);
  1835. }
  1836. }
  1837. }, false);
  1838.  
  1839. // 加载完成后才继续
  1840. iframe.onload = function() {
  1841. // 暂时禁用 iframe 的滚动条
  1842. if (!getCSS('#Autopage_iframe-scroll') && !iframe.contentWindow.document.getElementById('Autopage_iframe-scroll-hidden')) {
  1843.  
  1844. let newStyle = document.createElement('style'); newStyle.id = 'Autopage_iframe-scroll-hidden';
  1845. newStyle.textContent = 'html, body {overflow: hidden !important;}';
  1846. iframe.contentWindow.document.documentElement.appendChild(newStyle);
  1847. }
  1848.  
  1849. // 添加历史记录
  1850. if (curSite.history === undefined) {
  1851. if (GM_getValue('menu_history', true)) addHistory(iframe.contentWindow.document, iframe.contentWindow.document.title);
  1852. } else {
  1853. if (curSite.history) addHistory(iframe.contentWindow.document, iframe.contentWindow.document.title);
  1854. }
  1855. // 当前页码 + 1
  1856. if (!curSite.hiddenPN) {
  1857. let autopageNumber = getCSS('#Autopage_number', window.top.document)
  1858. if (autopageNumber) pageNumIncrement()
  1859. }
  1860. }
  1861.  
  1862. // 插入 iframe
  1863. if (location.hostname == 'www.cocomanga.com') {
  1864. document.body.appendChild(iframe);
  1865. } else {
  1866. document.documentElement.appendChild(iframe);
  1867. }
  1868. }
  1869. // 翻页类型 6(通过 iframe 获取下一页动态加载内容,只有一个娃)
  1870. function insIframe_(src) {
  1871. // 暂停翻页
  1872. if (!pausePage) return
  1873. pausePage = false
  1874.  
  1875. //console.log('000',src)
  1876. // 如果不存在,则创建一个 iframe
  1877. let iframe = document.getElementById('Autopage_iframe');
  1878. if (!iframe) {
  1879. iframe = document.createElement('iframe');
  1880. //iframe.sandbox = 'allow-same-origin allow-scripts allow-popups allow-forms';
  1881. iframe.id = 'Autopage_iframe';
  1882. iframe.src = src.replace(/#.+$/,'');
  1883.  
  1884. document.documentElement.appendChild(document.createElement('style')).textContent = 'iframe#Autopage_iframe {position: absolute !important; top: -9999px !important; left: -9999px !important; width: 100% !important; height: 100% !important; border: none !important; z-index: -999 !important;}';
  1885. }
  1886.  
  1887. // 加载完成后才继续
  1888. iframe.onload = function() {
  1889. if (!curSite.pager.loadTime) curSite.pager.loadTime = 300; // 默认 300ms
  1890. let time1 = 0 ,time2 = setInterval(function(){
  1891. let scrollHeight = (iframe.contentWindow.document.documentElement.scrollHeight || iframe.contentWindow.document.body.scrollHeight)/10
  1892. iframe.contentWindow.scrollTo(0, 999999);
  1893. iframe.contentWindow.scrollTo(0, scrollHeight*time1);
  1894. if (++time1 == 10) {
  1895. clearInterval(time2);
  1896. processElems(iframe.contentWindow.document); // 插入/替换元素等
  1897. pausePage = true; // 恢复翻页
  1898. }
  1899. }, curSite.pager.loadTime/10)
  1900. }
  1901.  
  1902. // 插入 iframe(如果已存在则直接改 src)
  1903. if (document.getElementById('Autopage_iframe')) {
  1904. iframe.src = src.replace(/#.+$/,'');
  1905. } else {
  1906. document.documentElement.appendChild(iframe);
  1907. }
  1908. }
  1909.  
  1910.  
  1911. // XHR 后处理结果,插入、替换元素等(适用于翻页类型 1/3/6)
  1912. function processElems(response) {
  1913. if (!curSite.pager.insertP) {curSite.pager.insertP = [curSite.pager.pageE, 5]}
  1914. let pageE = getAll(curSite.pager.pageE, response, response), toE;
  1915. if (curSite.pager.insertP[1] === 5) { // 插入 pageE 列表最后一个元素的后面
  1916. toE = toE5pop(getAll(curSite.pager.insertP[0]));
  1917. } else {
  1918. toE = getOne(curSite.pager.insertP[0]);
  1919. }
  1920. //console.log(curSite.pager.pageE, pageE, curSite.pager.insertP, toE)
  1921.  
  1922. if (pageE.length > 0 && toE) {
  1923. // 如果有插入前函数就执行函数
  1924. if (curSite.function && curSite.function.bF) {
  1925. if (curSite.function.bFp) { // 如果指定了参数
  1926. if (typeof(curSite.function.bF) == 'string') { // 如果是字符串,说明是自定义规则
  1927. pageE = new Function('pageE', 'bFp', 'fun', curSite.function.bF)(pageE, curSite.function.bFp, window.autoPage)
  1928. } else {
  1929. pageE = curSite.function.bF(pageE, curSite.function.bFp);
  1930. }
  1931. } else {
  1932. if (typeof(curSite.function.bF) == 'string') { // 如果是字符串,说明是自定义规则
  1933. pageE = new Function('pageE', 'fun', curSite.function.bF)(pageE, window.autoPage)
  1934. } else {
  1935. pageE = curSite.function.bF(pageE);
  1936. }
  1937. }
  1938. }
  1939.  
  1940. // 强制新标签页打开链接
  1941. if (curSite.blank === 4 || curSite.blank === 5 || curSite.blank === 6) {pageE = forceTarget(pageE);}
  1942.  
  1943. // 插入位置
  1944. let addTo = getAddTo(curSite.pager.insertP[1]);
  1945.  
  1946. // 插入新页面元素
  1947. if (curSite.pager.insertP[1] === 6) { // 插入到目标内部末尾(针对文本,比如小说网页)
  1948. let afterend = '';
  1949. if (curSite.pager.insertP6Br === false) { // 这个基本上只有脚本内置的通用规则会用上,因为该通用规则匹配到的网站正文 <br> 是未知的,所以需要判断一下数量
  1950. if (unsafeWindow.insertP6Br === true) {
  1951. afterend += '<br/><br/>'
  1952. } else if (unsafeWindow.insertP6Br === undefined) {
  1953. if (getAll('br', getOne(curSite.pager.pageE)).length > 10) {
  1954.  
  1955. function checklastElementsBr(e) {
  1956. const children = Array.from(e.childNodes).filter(node => {return node.nodeType === Node.ELEMENT_NODE || (node.nodeType === Node.TEXT_NODE && node.textContent.trim() !== '');}), lastElement = children[children.length - 1];
  1957. if (lastElement.tagName === 'BR') { // 判断最后一个元素
  1958. return true; // 最后一个元素是 <br>
  1959. } else if (lastElement.tagName === 'P' && lastElement.classList.contains('readinline')) { // 判断倒数第二个元素
  1960. return children[children.length - 2].tagName === 'BR'; // 倒数第二个元素是 <br>
  1961. }
  1962. return false; // 其他情况
  1963. };
  1964. // 如果正文末尾最后一个元素不是 <br> 且 倒数第二个元素也不是 <br> 时,才添加 <br/><br/>
  1965. if (!checklastElementsBr(getOne(curSite.pager.pageE))) {
  1966. unsafeWindow.insertP6Br = true;
  1967. afterend += '<br/><br/>'
  1968. } else {unsafeWindow.insertP6Br = false;}
  1969. }
  1970. }
  1971. } else if (curSite.pager.insertP6Br) { // 对于其他 insertP6Br: true 的规则,则依然直接添加 <br>
  1972. afterend += '<br/><br/>'
  1973. }
  1974. pageE.forEach(function (one) {afterend += one.innerHTML;});
  1975. toE.insertAdjacentHTML(addTo, afterend);
  1976. } else {
  1977. if (curSite.pager.insertP[1] === 2 || curSite.pager.insertP[1] === 4 || curSite.pager.insertP[1] === 5) pageE.reverse(); // 插入到 [元素内头部]、[目标本身后面] 时,需要反转顺序
  1978. pageE.forEach(function (one) {toE.insertAdjacentElement(addTo, one);});
  1979. }
  1980.  
  1981. // 当前页码 + 1
  1982. pageNumIncrement()
  1983.  
  1984. // 添加历史记录
  1985. if (curSite.history === undefined) {
  1986. if (GM_getValue('menu_history', true)) addHistory(response);
  1987. } else {
  1988. if (curSite.history) addHistory(response);
  1989. }
  1990.  
  1991. // 替换待替换元素
  1992. if (curSite.pager.replaceE !== "") replaceElems(response);
  1993.  
  1994. // 插入 <script> 标签
  1995. if (curSite.pager.scriptT || curSite.pager.scriptT == 0) {
  1996. switch (curSite.pager.scriptT) {
  1997. case 0: // 下一页的所有 <script> 标签
  1998. insScript('script', response); break;
  1999. case 1: // 下一页的所有 <script> 标签(不包括 src 链接)
  2000. insScript('script:not([src])', response); break;
  2001. case 2: // 下一页主体元素 (pageE) 的同级 <script> 标签
  2002. if (curSite.pager.insertP[1] === 2 || curSite.pager.insertP[1] === 4 || curSite.pager.insertP[1] === 5) pageE.reverse(); // 为了避免 JS 执行顺序反了,还需要再给反转回去
  2003. insScript(null, pageE); break;
  2004. case 3: // 下一页主体元素 (pageE) 的子元素 <script> 标签
  2005. if (curSite.pager.insertP[1] === 2 || curSite.pager.insertP[1] === 4 || curSite.pager.insertP[1] === 5) pageE.reverse(); // 为了避免 JS 执行顺序反了,还需要再给反转回去
  2006. insScript('script:not([src])', pageE); break;
  2007. }
  2008. }
  2009.  
  2010. // 如果有插入后函数就执行函数
  2011. if (curSite.function && curSite.function.aF) {
  2012. if (curSite.function.aFp) { // 如果指定了参数
  2013. if (typeof(curSite.function.aF) == 'string') { // 如果是字符串,说明是自定义规则
  2014. new Function('aFp', 'fun', curSite.function.aF)(curSite.function.aFp, window.autoPage)
  2015. } else {
  2016. curSite.function.aF(curSite.function.aFp);
  2017. }
  2018. } else {
  2019. if (typeof(curSite.function.aF) == 'string') { // 如果是字符串,说明是自定义规则
  2020. new Function('fun', curSite.function.aF)(window.autoPage);
  2021. } else {
  2022. curSite.function.aF();
  2023. }
  2024. }
  2025. }
  2026. } else { // 获取主体元素失败后,尝试重新获取
  2027. console.log(curSite.pager.pageE, pageE, curSite.pager.insertP, toE, response)
  2028. if (curSite.retry) {
  2029. console.warn('[自动无缝翻页] 获取主体元素失败,' + curSite.retry + '毫秒 后可向下翻网页来触发脚本尝试重新获取...')
  2030. setTimeout(function(){curSite.pageUrl = '';}, curSite.retry)
  2031. } else {
  2032. console.error('[自动无缝翻页] 获取主体元素失败...')
  2033. // 尝试替换元素看能不能继续翻页下去
  2034. /*if (curSite.pager.replaceE !== "") {
  2035. if (replaceElems(response)) { // 如果替换成功
  2036. console.log('[自动无缝翻页] 获取主体元素失败,尝试替换元素成功!')
  2037. // 当前页码 + 1
  2038. pageNumIncrement();
  2039. // 添加历史记录
  2040. if (curSite.history === undefined) {
  2041. if (GM_getValue('menu_history', true)) addHistory(response);
  2042. } else {
  2043. if (curSite.history) addHistory(response);
  2044. }
  2045. } else {console.error('[自动无缝翻页] 获取主体元素失败,尝试替换元素失败...')}
  2046. }*/
  2047. }
  2048. }
  2049. }
  2050. // 通用型插入前函数(加载图片)
  2051. function src_bF(pageE, css = [0, 'img[data-original], img[data-src]', 'data-original']) {
  2052. if (css[2] === undefined) css[2] = 'data-original'
  2053. pageE.forEach(function (one) {
  2054. if (css[0] == 0) { // src 图片
  2055. if (one.tagName === 'IMG') {
  2056. if (one.getAttribute(css[2])){one.src = one.getAttribute(css[2]);}else if (one.dataset.src){one.src = one.dataset.src;}
  2057. } else {
  2058. one.querySelectorAll(css[1]).forEach(function (now) {if (now.getAttribute(css[2])){now.src = now.getAttribute(css[2]);}else if (now.dataset.src){now.src = now.dataset.src;};});
  2059. }
  2060. } else if (css[0] == 1) { // 背景图片
  2061. if (one.tagName === 'IMG') {
  2062. if (one.getAttribute(css[2])){one.style.backgroundImage = 'url("' + one.getAttribute(css[2]) + '")';}else if (one.dataset.src){one.style.backgroundImage = 'url("' + one.dataset.src + '")';}
  2063. } else {
  2064. one.querySelectorAll(css[1]).forEach(function (now) {if (now.getAttribute(css[2])){now.style.backgroundImage = 'url("' + now.getAttribute(css[2]) + '")';}else if (now.dataset.src){now.style.backgroundImage = 'url("' + now.dataset.src + '")';};});
  2065. }
  2066. }
  2067. });
  2068. return pageE
  2069. }
  2070. // 文字型插入前函数(正则过滤)
  2071. function xs_bF(pageE, reg) {
  2072. pageE.forEach(function (one) {one.innerHTML = one.innerHTML.replace(reg[0], reg[1])});
  2073. return pageE
  2074. }
  2075.  
  2076. // 通用型获取下一页地址(从 元素 中获取页码)该函数仅供脚本内部调用
  2077. function getNextE_(css) {
  2078. if (!css) css = curSite.pager.nextL; // 如果没有指定 css 参数,那么就使用规则中的 nextL
  2079. let next = getOne(css); // 获取含有下一页地址的元素
  2080. if (next && next.nodeType === 1 && next.href && next.href.slice(0,4) === 'http' && next.getAttribute('href').slice(0,1) !== '#') { // 确定元素存在且 href 是正常链接
  2081. if (next.href != curSite.pageUrl) { // 如果取到的下一页 URL 和上一次取到的 URL(也就是当前 URL)不一样
  2082. if (curSite.pager.forceHTTPS && location.protocol === 'https:') { // 如果规则要求强制 HTTPS,且当前网页的协议也是 HTTPS,那么就需要修改 URL 为 HTTPS
  2083. if (next.href.replace(/^http:/,'https:') === curSite.pageUrl) {return false;} // 如果修改为 HTTPS 后和上一次取到的 URL(也就是当前 URL)一样,就返回 false
  2084. curSite.pageUrl = next.href.replace(/^http:/,'https:'); // 反之返回修改 HTTPS 后的 URL
  2085. } else {
  2086. curSite.pageUrl = next.href;
  2087. }
  2088. } else { // 如果取到的下一页 URL 和上一次取到的 URL(也就是当前 URL)一样,那么代表没有下一页了,就返回 false
  2089. return false;
  2090. }
  2091. //console.log(curSite.pageUrl)
  2092. return true;
  2093. }
  2094. return false; // 如果元素不存在 或 href 非正常链接,就返回false
  2095. }
  2096. // 通用型获取下一页地址(从 元素 中获取页码)该函数用于规则中调用(fun.getNextE() 这样)
  2097. function getNextE(css) {
  2098. if (!css) { // 考虑到可能被非 nextL 规则内调用,所以还是需要做一个判断
  2099. if (typeof curSite.pager.nextL == 'string' && curSite.pager.nextL.match(/^js;/i) === null) {css = curSite.pager.nextL;} else {return '';}
  2100. }
  2101. let next = getOne(css); // 获取含有下一页地址的元素
  2102. if (next && next.nodeType === 1 && next.href && next.href.slice(0,4) === 'http' && next.getAttribute('href').slice(0,1) !== '#') { // 确定元素存在且 href 是正常链接
  2103. if (next.href != curSite.pageUrl) { // 如果取到的下一页 URL 和上一次取到的 URL(也就是当前 URL)不一样
  2104. if (curSite.pager.forceHTTPS && location.protocol === 'https:') { // 如果规则要求强制 HTTPS,且当前网页的协议也是 HTTPS,那么就需要修改 URL 为 HTTPS
  2105. if (next.href.replace(/^http:/,'https:') === curSite.pageUrl) {return '';} // 如果修改为 HTTPS 后和上一次取到的 URL(也就是当前 URL)一样,就返回空
  2106. return next.href.replace(/^http:/,'https:'); // 反之返回修改 HTTPS 后的 URL
  2107. } else {
  2108. return next.href;
  2109. }
  2110. } else { // 如果取到的下一页 URL 和上一次取到的 URL(也就是当前 URL)一样,那么代表没有下一页了,就返回空
  2111. return '';
  2112. }
  2113. }
  2114. return ''; // 如果元素不存在 或 href 非正常链接,就返回空
  2115. }
  2116. // 通用型获取下一页地址(从 元素 中获取页码,URL 替换 page= 参数)
  2117. function getNextEP(css, pf, reg) {
  2118. let nextNum = getOne(css), url = '';
  2119. if (nextNum && nextNum.textContent) {
  2120. nextNum = nextNum.textContent.replaceAll(' ','');
  2121. if (location.search) {
  2122. if (indexOF(pf, 's')) {
  2123. url = location.search.replace(reg, pf + nextNum);
  2124. } else {
  2125. url = location.search + '&' + pf + nextNum;
  2126. }
  2127. } else {
  2128. url = '?' + pf + nextNum;
  2129. }
  2130. url = location.origin + location.pathname + url;
  2131. }
  2132. //console.log('111', url)
  2133. return url
  2134. }
  2135. // 通用型获取下一页地址(直接给定页码,URL 替换 page= 参数)
  2136. function getNextSP(page, pf, reg) {
  2137. let url = '';
  2138. if (!page) return url
  2139. if (typeof page === 'number') page = page.toString()
  2140. if (location.search) {
  2141. if (indexOF(pf, 's')) {
  2142. url = location.search.replace(reg, pf + page);
  2143. } else {
  2144. url = location.search + '&' + pf + page;
  2145. }
  2146. } else {
  2147. url = '?' + pf + page;
  2148. }
  2149. return (location.origin + location.pathname + url)
  2150. }
  2151. // 通用型获取下一页地址(从 元素 中获取页码,URL 替换 pathname 路径)
  2152. function getNextEPN(css, reg, a, b = '') {
  2153. let nextNum = getOne(css), url = '';
  2154. if (nextNum && nextNum.textContent) {
  2155. nextNum = nextNum.textContent.replaceAll(' ','');
  2156. if (location.pathname) {
  2157. if (indexOF(reg)) {
  2158. url = location.pathname.replace(reg, a + nextNum + b);
  2159. } else {
  2160. url = location.pathname + a + nextNum + b;
  2161. }
  2162. } else {
  2163. url = location.pathname + a + nextNum + b;
  2164. }
  2165. url = location.origin + url + location.search;
  2166. }
  2167. return url
  2168. }
  2169. // 通用型获取下一页地址(从 URL 中获取页码,并页码+1,URL 替换 pathname 路径,后三个参数可以省略)
  2170. function getNextUPN(urlReg, reg, a, b = '', initP = '2', endP) {
  2171. let nextNum = urlReg.exec(location.pathname);
  2172. if (nextNum) {
  2173. if (nextNum.length > 1){ // 如果正则捕获到分组(也就是正则表达式中用英文括号括起来的),那么就改为使用第一个分组(也就是正则常说的 $1)作为当前页码数字
  2174. nextNum = String(parseInt(nextNum[1])+1);
  2175. } else {
  2176. nextNum = String(parseInt(nextNum[0])+1);
  2177. }
  2178. if (endP && (parseInt(nextNum) > parseInt(endP))) return ''
  2179. } else {
  2180. nextNum = initP;
  2181. if (endP && (parseInt(nextNum) >= parseInt(endP))) return ''
  2182. }
  2183. let url = '';
  2184. if (location.pathname) {
  2185. if (indexOF(reg)) {
  2186. url = location.pathname.replace(reg, a + nextNum + b);
  2187. } else {
  2188. url = location.pathname + a + nextNum + b;
  2189. }
  2190. } else {
  2191. url = location.pathname + a + nextNum + b;
  2192. }
  2193. url = location.origin + url + location.search;
  2194. return url
  2195. }
  2196. // 通用型获取下一页地址(从 URL 中获取页码,并页码+1,URL 替换 page= 参数,后三个参数可以省略)
  2197. function getNextUP(pf, reg, lp = location.pathname, initP = '2', endP) {
  2198. let nextNum = getSearch(pf.replace('=',''));
  2199. if (nextNum) {
  2200. nextNum = String(parseInt(nextNum)+1);
  2201. if (endP && (parseInt(nextNum) > parseInt(endP))) return ''
  2202. } else {
  2203. nextNum = initP;
  2204. if (endP && (parseInt(nextNum) >= parseInt(endP))) return ''
  2205. }
  2206. let url = '';
  2207. if (location.search) {
  2208. if (indexOF(pf, 's')) {
  2209. url = location.search.replace(reg, pf + nextNum);
  2210. } else {
  2211. url = location.search + '&' + pf + nextNum;
  2212. }
  2213. } else {
  2214. url = '?' + pf + nextNum;
  2215. }
  2216. url = location.origin + lp + url;
  2217. return url
  2218. }
  2219. // 通用型获取下一页地址(从 form input 中获取,返回 GET URL)
  2220. function getNextF(css) {
  2221. let form = getOne(css), value = '';
  2222. if (form) {
  2223. form.querySelectorAll('input[name]').forEach(function(input) {value += input.name + '=' + input.value + '&';}) // 生成表单参数
  2224. value = encodeURI(value.replace(/&$/,'')); // 清理最后一个 & 符号
  2225. if (form.action && value) return (form.action + '?' + value)
  2226. }
  2227. return '';
  2228. }
  2229.  
  2230.  
  2231. // 检查 URL
  2232. function checkURL(func) {
  2233. if (!curSite.pager.nextL) return
  2234. if (typeof curSite.pager.nextL == 'function') {
  2235. let tempUrl = curSite.pager.nextL();
  2236. if (!tempUrl || tempUrl === curSite.pageUrl || tempUrl.slice(0,4) !== 'http') return
  2237. curSite.pageUrl = tempUrl;
  2238. func(curSite.pageUrl);
  2239. } else if (curSite.pager.nextL.search(/^js;/i) === 0) { // 自定义翻页规则中执行 JavaScript 代码的
  2240. try {
  2241. let tempUrl = new Function('fun', curSite.pager.nextL.slice(3))(window.autoPage);
  2242. if (!tempUrl || tempUrl === curSite.pageUrl || tempUrl.slice(0,4) !== 'http') return
  2243. curSite.pageUrl = tempUrl;
  2244. func(curSite.pageUrl);
  2245. } catch (e) {
  2246. console.error('[自动无缝翻页] - 当前网页规则 "nextL" 内 JS 代码有误,请检查:\n', curSite.pager.nextL + '\n\n', e);
  2247. }
  2248. } else if (getNextE_()) {
  2249. func(curSite.pageUrl);
  2250. }
  2251. //console.log(curSite.pageUrl);
  2252. }
  2253. // 替换元素
  2254. function replaceElems(pageE, o = curSite.pager.replaceE, r = curSite.pager.replaceE) {
  2255. let oE,rE;
  2256.  
  2257. if (curSite.pager.replaceE === undefined && curSite.pager.nextL && curSite.pager.nextL.search(/^js;/i) !== 0) { // 如果 replaceE 不存在,且 nextL 存在,且不是 js 代码
  2258. let a = getOne(curSite.pager.nextL) // 获取 nextL 元素,并判断该元素后面或前面是否有同类型的相邻兄弟元素
  2259. if ((a.nextElementSibling && a.nextElementSibling.tagName === a.tagName) || (a.previousElementSibling && a.previousElementSibling.tagName === a.tagName)) {
  2260. // nextL 元素后面或前面有同类型的相邻兄弟元素,则可以替换 nextL 的父元素
  2261. // 当 nextL 选择器为 xpath 时,直接末尾追加 /.. 即可选择其父元素
  2262. if (curSite.pager.nextL.slice(0,1) === '/' || curSite.pager.nextL.slice(0,2) === './' || curSite.pager.nextL.slice(0,2) === '(/' || curSite.pager.nextL.slice(0,3) === 'id(') {
  2263. o = r = curSite.pager.nextL + '/..'
  2264. } else { // 当 nextL 选择器为 css 时,则需要寻找所有 nextL 元素的父元素
  2265. oE = getAllParentElement(curSite.pager.nextL)
  2266. rE = getAllParentElement(curSite.pager.nextL, pageE, pageE)
  2267. }
  2268. } else { // 如果 nextL 元素后面或前面没有同类型的相邻兄弟元素,那么就只替换 nextL 元素
  2269. o = r = curSite.pager.nextL
  2270. }
  2271. }
  2272.  
  2273. if (!oE && !rE && o && r) {
  2274. oE = getAll(o)
  2275. rE = getAll(r, pageE, pageE)
  2276. }
  2277.  
  2278. if (oE && rE && oE.length != 0 && rE.length != 0 && oE.length === rE.length) {
  2279. for (let i = 0; i < oE.length; i++) {
  2280. oE[i].outerHTML = rE[i].outerHTML;
  2281. }
  2282. return true
  2283. } else if (curSite.pager.replaceE !== undefined) {console.log(pageE,oE,rE)}
  2284. return false
  2285. }
  2286. // 添加历史记录
  2287. function addHistory(pageE, title, url) {
  2288. if (!curSite.pageUrl) return
  2289. // 对于自带类似功能 或者 覆盖了 history 原生函数的网站,则跳过不再添加历史记录
  2290. if (window.top.history.toString() !== '[object History]') return
  2291. title = title || ((pageE.querySelector('title')) ? pageE.querySelector('title').textContent : window.top.document.title);
  2292. url = url || curSite.pageUrl;
  2293. window.top.document.Autopage_nowUrl = curSite.pageUrl;
  2294. // 对于下一页 URL 和当前网页 URL 的协议不同时,以当前网页 URL 协议为准
  2295. if (url.indexOf(window.top.location.protocol) === -1) url = url.replace(/^https?:/,window.top.location.protocol)
  2296. window.top.history.pushState('Autopage_history', title, url);
  2297. window.top.document.title = title;
  2298. }
  2299. // 插入 <Script>
  2300. function insScript(selector, contextNode = document, toE = document.body) {
  2301. let scriptElems = contextNode;
  2302. if (selector) {
  2303. if (contextNode instanceof Array) {
  2304. scriptElems = []; contextNode.forEach(function (one) {scriptElems = scriptElems.concat(getAll(selector, one, one));})
  2305. } else {
  2306. scriptElems = getAll(selector, contextNode, contextNode);
  2307. }
  2308. }
  2309.  
  2310. scriptElems.forEach(function (one) {
  2311. if (one.tagName === 'SCRIPT') {
  2312. if (one.src) {
  2313. toE.appendChild(document.createElement('script')).src = one.src;
  2314. } else {
  2315. toE.appendChild(document.createElement('script')).textContent = one.textContent;//.replaceAll('document.write', '');
  2316. }
  2317. }
  2318. });
  2319. }
  2320. // 插入 <Style>
  2321. function insStyle(style) {
  2322. if (style.indexOf('{') === -1){style += '{display: none !important;}'}
  2323. document.documentElement.appendChild(document.createElement('style')).textContent = style;
  2324. }
  2325.  
  2326.  
  2327. // 获取元素(CSS/Xpath)来自:https://github.com/machsix/Super-preloader
  2328. function getCSS(css, contextNode = document) {
  2329. return contextNode.querySelector(css);
  2330. }
  2331. function getAllCSS(css, contextNode = document) {
  2332. return [].slice.call(contextNode.querySelectorAll(css));
  2333. }
  2334. function getXpath(xpath, contextNode, doc = document) {
  2335. contextNode = contextNode || doc;
  2336. try {
  2337. const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  2338. // 应该总是返回一个元素节点
  2339. return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue;
  2340. } catch (err) {
  2341. throw new Error(`无效 Xpath: ${xpath}`);
  2342. }
  2343. }
  2344. function getAllXpath(xpath, contextNode, doc = document) {
  2345. contextNode = contextNode || doc;
  2346. const result = [];
  2347. try {
  2348. const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2349. for (let i = 0; i < query.snapshotLength; i++) {
  2350. const node = query.snapshotItem(i);
  2351. // 如果是 Element 节点
  2352. if (node.nodeType === 1) result.push(node);
  2353. }
  2354. } catch (err) {
  2355. throw new Error(`无效 Xpath: ${xpath}`);
  2356. }
  2357. return result;
  2358. }
  2359. function getOne(selector, contextNode = undefined, doc = document) {
  2360. if (!selector) return;
  2361. contextNode = contextNode || doc;
  2362. if (selector.slice(0,1) === '/' || selector.slice(0,2) === './' || selector.slice(0,2) === '(/' || selector.slice(0,3) === 'id(') {
  2363. return getXpath(selector, contextNode, doc);
  2364. } else {
  2365. return getCSS(selector, contextNode);
  2366. }
  2367. }
  2368. function getAll(selector, contextNode = undefined, doc = document) {
  2369. if (!selector) return [];
  2370. contextNode = contextNode || doc;
  2371. if (selector.slice(0,1) === '/' || selector.slice(0,2) === './' || selector.slice(0,2) === '(/' || selector.slice(0,3) === 'id(') {
  2372. return getAllXpath(selector, contextNode, doc);
  2373. } else {
  2374. return getAllCSS(selector, contextNode);
  2375. }
  2376. }
  2377. // 获取所有父元素
  2378. function getAllParentElement(selector, contextNode = undefined, doc = document) {
  2379. contextNode = contextNode || doc;
  2380. const parents = [];
  2381. getAll(selector, contextNode, doc).forEach((next) => {
  2382. const parent = next.parentElement;
  2383. if (!parents.includes(parent)) {
  2384. parents.push(parent);
  2385. }
  2386. });
  2387. return parents
  2388. }
  2389. function createDocumentByString(e) {
  2390. if (e) {
  2391. if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml');
  2392. var t;
  2393. try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {}
  2394. if (t) return t;
  2395. if (document.implementation.createHTMLDocument) {
  2396. t = document.implementation.createHTMLDocument('ADocument');
  2397. } else {
  2398. 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) {}
  2399. }
  2400. if (t) {
  2401. var r = document.createRange(),
  2402. n = r.createContextualFragment(e);
  2403. r.selectNodeContents(document.body);
  2404. t.body.appendChild(n);
  2405. 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);
  2406. return t;
  2407. }
  2408. } else console.error('没有找到要转成 DOM 的字符串', e);
  2409. }
  2410.  
  2411.  
  2412. // 兼容不支持 GM_openInTab 的油猴脚本管理器
  2413. function openInTab(url, options) {
  2414. window.open(url);
  2415. }
  2416.  
  2417. // 强制新标签页打开链接
  2418. function forceTarget(pageE) {
  2419. if (curSite.blank === 1) {
  2420. document.head.appendChild(document.createElement('base')).target = '_blank';
  2421.  
  2422. } else if (curSite.blank === 5 || curSite.blank === 6) { // 清理 <a> 元素的点击事件
  2423. if (!pageE) pageE = getAll(curSite.pager.pageE)
  2424. pageE.forEach(function (dd) {
  2425. getAllCSS('a[href]:not([target="_blank"]):not([onclick]):not([href^="#"]):not([href^="javascript:"])',dd).forEach(function (a) {
  2426. if (a.href.slice(0,4) == 'http') {
  2427. const clonedLink = a.cloneNode(true); // 克隆原 a 元素
  2428. clonedLink.target = '_blank'; // 通过添加 target="_blank" 属性来新标签页打开,可以解决大部分情况
  2429. if (curSite.blank === 6) clonedLink.addEventListener('click', function(e) {e.stopPropagation();}); // 如果添加 target="_blank" 属性无效(依然在当前网页跳转打开),那么说明其父元素的事件委托中阻止了默认打开链接事件,因此对该 <a> 元素添加点击事件并阻止冒泡(避免父元素事件委托捕获该元素的点击事件)
  2430. a.insertAdjacentElement('afterend', clonedLink); // 把克隆的元素插入原 a 元素后面
  2431. a.remove(); // 删除原 a 元素
  2432. }
  2433. });
  2434. });
  2435. return pageE
  2436.  
  2437. } else if (curSite.blank === 4) {
  2438. if (!pageE) pageE = getAll(curSite.pager.pageE)
  2439. pageE.forEach(function (dd) {getAllCSS('a[href]:not([target="_blank"]):not([onclick]):not([href^="#"]):not([href^="javascript:"])',dd).forEach(function (a) {if (a.href.slice(0,4) == 'http') {a.target = '_blank';}});});
  2440. return pageE
  2441.  
  2442. } else {
  2443. let d;
  2444. if (curSite.blank === 2) {
  2445. d = document.body
  2446. } else if (curSite.blank === 3) {
  2447. let dd = toE5pop(getAll(curSite.pager.pageE));
  2448. if (dd && dd.parentElement != null) d = dd.parentElement
  2449. }
  2450. if (!d) return
  2451.  
  2452. function forceTarget_(target, e){
  2453. if (target.href && target.target != '_blank' && !(target.getAttribute('onclick')) && target.href.slice(0,4) == 'http' && target.getAttribute('href').slice(0,1) != '#') {
  2454. e.stopPropagation(); // 阻止冒泡(避免被父元素事件委托捕获)
  2455. e.preventDefault(); // 阻止默认打开链接事件
  2456. GM_openInTab(target.href, {active: true,insert: true,setParent: true});
  2457. }
  2458. }
  2459. d.addEventListener('click', function(e) {
  2460. //console.log(e.target.tagName, e.path)
  2461. if (e.target.tagName === 'A') {
  2462. forceTarget_(e.target, e);
  2463. } else {
  2464. let path = e.path || e.composedPath();
  2465. for (let i = 1; i < path.length - 4; i++) {if (path[i].tagName === 'A') {forceTarget_(path[i], e); break;}}
  2466. }
  2467. });
  2468. }
  2469. }
  2470.  
  2471. // 清理元素上绑定的事件(不包括父元素上监听的事件委托)
  2472. // css 为元素选择器(也支持 Xpath)
  2473. // delay 为延迟时间,确保其放在 url 规则中执行时网页已经加载完成
  2474. // mode 为 0 时清理全部,为 1 时额外清理 onclick 属性,为 2 时添加空点击事件并阻止冒泡
  2475. function cleanuEvent(css, delay = 0, mode = -1) {
  2476. setTimeout(()=>{
  2477. getAll(css).forEach(function (a) {
  2478. const clonedLink = a.cloneNode(true); // 克隆原元素
  2479. if (mode == 0 || mode == 1) {if (clonedLink.getAttribute('onclick') != undefined) {clonedLink.removeAttribute('onclick')}} // 清理 onclick 属性
  2480. if (mode == 0 || mode == 2) clonedLink.addEventListener('click', function(e) {e.stopPropagation();}); // 添加空点击事件并阻止冒泡(避免父元素事件委托捕获该元素的点击事件)
  2481. a.insertAdjacentElement('afterend', clonedLink); // 把克隆的元素插入原元素后面
  2482. a.remove(); // 删除原元素
  2483. }, delay);
  2484. })
  2485. }
  2486. // 初始化事件
  2487. /*function initEvent() {
  2488. if (curSite.initE[1] == undefined) curSite.initE[1] = 500;
  2489. setTimeout(function(){getAllCSS(curSite.initE[0]).forEach(function (o) {o.innerHTML = o.innerHTML;});}, curSite.initE[1])
  2490. }*/
  2491. // 判断元素是否隐藏(隐藏返回 true)
  2492. function isHidden(el){
  2493. return (el.offsetParent === null);
  2494. }
  2495. // 判断是否为手机版(是则返回 true)
  2496. function isMobile(){
  2497. return (/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|MicroMessenger|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent) || (window.screen.width < 500 && window.screen.height < 800));
  2498. }
  2499. // 用以自定义规则中设置 urlC = true
  2500. function isUrlC(){
  2501. urlC = true;
  2502. }
  2503. // 判断 URL 是否存在指定文本
  2504. function indexOF(e, l = 'p', low = true){
  2505. switch (l) {
  2506. case 'h':
  2507. l = location.href; break;
  2508. case 'p':
  2509. l = location.pathname; break;
  2510. case 's':
  2511. l = location.search; break;
  2512. }
  2513. //console.log(l,e,l.indexOf(e))
  2514. if (e instanceof RegExp) {
  2515. if (e.test(l)) return true
  2516. } else {
  2517. if (low) {e = e.toLowerCase(); l = l.toLowerCase();} // 全部转为小写(即不区分大小写)
  2518. if (l.indexOf(e) != -1) return true
  2519. }
  2520. return false
  2521. }
  2522. // 判断网站标题是否包含指定文字
  2523. function isTitle(title) {
  2524. return document.title.indexOf(title) > -1;
  2525. }
  2526. // 判断规则中的 nextL、pageE、insertP、replaceE 元素是否存在于当前网页
  2527. function isPager(type) {
  2528. if (!type) { // 如果没有指定要判断的元素类型参数,那么需要设置默认值
  2529. if (!DBSiteNow.pager) return false; // 如果连 pager 都没有,那么直接返回 false
  2530. if (DBSiteNow.pager.type === undefined || DBSiteNow.pager.type === 1 || DBSiteNow.pager.type === 3 || DBSiteNow.pager.type === 6) { // 如果是翻页模式 1 3 6,那么默认值可能是 n、p、n,p 三种
  2531. // 判断 nextL 是不是选择器(字符串 + 非 js; 开头)
  2532. if (typeof DBSiteNow.pager.nextL == 'string' && DBSiteNow.pager.nextL.match(/^js;/i) === null) {type = 'n';}
  2533. // 判断 pageE 是否不是空
  2534. if (DBSiteNow.pager.pageE) {
  2535. // 如果 type 是空的,说明上面 nextL 判断结果为否,那么就是 p,反之则就是 n,p
  2536. if (!type) {type = 'p';}else{type = 'n,p';}
  2537. }
  2538. } else if (DBSiteNow.pager.type === 2 || DBSiteNow.pager.type === 5) { // 如果是翻页模式 2 6,那么默认值只能是 n 一种
  2539. // 判断 nextL 是不是选择器(字符串 + 非 js; 开头)
  2540. if (typeof DBSiteNow.pager.nextL == 'string' && DBSiteNow.pager.nextL.match(/^js;/i) === null) {type = 'n';}
  2541. } else if (DBSiteNow.pager.type === 4) { // 如果是翻页模式 4,那么是不能使用 isPager 的(因为基本上都是脚本内的函数)
  2542. return false;
  2543. }
  2544. if (!type) return false; // 如果上面的判断中 nextL 和 pageE 都为否,那么 type 就还是空的,则直接返回 false
  2545. }
  2546. const typeArr = type.split(',');
  2547. for (let i = 0; i < typeArr.length; i++) {
  2548. switch (typeArr[i]) {
  2549. case 'n': // nextL
  2550. if (!getOne(DBSiteNow.pager.nextL)){return false;}; break;
  2551. case 'p': // pageE
  2552. if (!getOne(DBSiteNow.pager.pageE)){return false;}; break;
  2553. case 'i': // insertP
  2554. if (!getOne(DBSiteNow.pager.insertP[0])){return false;}; break;
  2555. case 'r': // replaceE
  2556. if (!getOne(DBSiteNow.pager.replaceE)){return false;}; break;
  2557. }
  2558. }
  2559. return true;
  2560. }
  2561. // 获取 Search 指定参数
  2562. function getSearch(variable) {
  2563. let query = window.location.search.substring(1),
  2564. vars = query.split('&');
  2565. for (var i=0;i<vars.length;i++) {
  2566. var pair = vars[i].split('=');
  2567. if(pair[0] == variable){return pair[1];}
  2568. }
  2569. return '';
  2570. }
  2571. // 启用/禁用 (当前网站)
  2572. function menu_disable(type) {
  2573. switch(type) {
  2574. case 'check':
  2575. return check(); break;
  2576. case 'add':
  2577. add(); break;
  2578. case 'del':
  2579. del(); break;
  2580. }
  2581.  
  2582. function check() { // 存在返回真,不存在返回假
  2583. if (GM_getValue('menu_disable').indexOf(location.hostname) == -1) return false // 不存在返回假
  2584. return true
  2585. }
  2586.  
  2587. function add() {
  2588. if (check()) return
  2589. let list = GM_getValue('menu_disable'); // 读取网站列表
  2590. list.push(location.hostname); // 追加网站域名
  2591. GM_setValue('menu_disable', list); // 写入配置
  2592. location.reload(); // 刷新网页
  2593. }
  2594.  
  2595. function del() {
  2596. if (!check()) return
  2597. let list = GM_getValue('menu_disable'), // 读取网站列表
  2598. index = list.indexOf(location.hostname);
  2599. list.splice(index, 1); // 删除网站域名
  2600. GM_setValue('menu_disable', list); // 写入配置
  2601. location.reload(); // 刷新网页
  2602. }
  2603. }
  2604. // 左键双击网页空白处暂停翻页
  2605. function pausePageEvent() {
  2606. if (!GM_getValue('menu_pause_page')) return
  2607. if (curSite.SiteTypeID === 0) return
  2608. if (curSite.pager && curSite.pager.type == 5) window.top.document.xiu_pausePage = pausePage
  2609. document.body.addEventListener('dblclick', function () {
  2610. if (pausePage) {GM_notification({text: `❌ 已暂停本页 [自动无缝翻页]\n (再次双击可恢复)`, timeout: 2000});} else {GM_notification({text: `✅ 已恢复本页 [自动无缝翻页]\n (再次双击可暂停)`, timeout: 2000});}
  2611. if (document.querySelector('#Autopage_number')) { // 如果同时开启了左下角页码功能,则模拟点击(为了数字变成红色+斜体)
  2612. document.querySelector('#Autopage_number').shadowRoot.querySelector('#Autopage_number_button').click();
  2613. } else {
  2614. pausePage = !pausePage;
  2615. if (curSite.pager && curSite.pager.type == 5) window.top.document.xiu_pausePage = pausePage
  2616. }
  2617. });
  2618. }
  2619. // 自定义翻页规则
  2620. function customRules() {
  2621. if (getCSS('#Autopage_customRules')) return
  2622.  
  2623. let customRules = customStringify(GM_getValue('menu_customRules', {}))
  2624. if (customRules == '{}') customRules = '{\n \n}'; // 引导用户插入规则的位置
  2625. let _html = `<style>* {font-family: system-ui !important;}</style><div style="left: 0; right: 0; top: 0; bottom: 0; width: 100%; height: 100%; margin: auto; padding: 25px 10px 10px 10px; position: fixed; opacity: 0.95; z-index: 9999999; background-color: #eee; color: #222; font-size: 14px; overflow: scroll; text-align: left;-webkit-touch-callout: text !important;-webkit-user-select: text !important;-khtml-user-select: text !important;-moz-user-select: text !important;-ms-user-select: text !important;user-select: text !important;">
  2626. <h3 style="font-size: 22px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"><strong># 自定义翻页规则(优先级最高,会覆盖同名的外置翻页规则)-【将规则插入默认的 <code>{ }</code> 中间】</strong></h3>
  2627. <details><summary style="cursor: pointer;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"><kbd><strong>「 点击展开 查看规则示例 」(为了避免需要的时候还要找,我干脆把常用规则都一股脑塞进去了)</strong></kbd></summary>
  2628. <ul style="list-style: disc; margin-left: 35px;">
  2629. <li>翻页规则为 JSON 格式,因此大家需要多少<strong>了解一点 JSON 的基本格式</strong>(主要就是末尾逗号、转义、双引号等)。</li>
  2630. <li>具体的翻页规则说明、示例,为了方便更新及补充,我都写到 <strong><a href="https://github.com/XIU2/UserScript/issues/176" target="_blank">Github Issues</a></strong> 里面了。</li>
  2631. <li>脚本会自动格式化规则,因此<strong>无需手动缩进、换行</strong>,只需把规则<strong>插入默认的 { } 中间</strong>即可。</li>
  2632. </ul>
  2633. <pre class="notranslate" style="white-space: pre-wrap;user-select: auto;">
  2634. // 下面示例是把所有规则都塞进去了,但实际上大部分都用不上,大多数网站只需要像第一个 "aaa" 这样的规则(下方 示例一 中 url、replaceE、scrollD 均可按需省略):
  2635.  
  2636. // "aaa" 是规则名,唯一,因为 自定义翻页规则 优先级最高,所以会覆盖同名的 外置翻页规则
  2637. // "host" 是域名,支持正则表达式(如 示例四),也可以像这样 示例三 那样写多个域名或正则表达式(当然也可以混用),如果省略,则默认匹配所有域名(会对所有域名匹配 url 规则判断,可以当成一个简单的外置/自定义通用规则的方案)
  2638. // "url" 是用来控制哪些网站中页面适用该规则,省略后代表该规则应用于全站(如果不知道写什么,那么就写 return fun.isPager() 这样脚本会默认自动匹配当前网站下存在 nextL 及 pageE 元素的网页,大部分网站是没问题的,如果改为匹配 replaceE 或者其他组合,那么请去上面的 Github Issues 里的 内置函数 中查看具体使用方法)
  2639.  
  2640. // "nextL" 是用来指定含有下一页地址的元素选择器(CSS 或 XPath 都行,一般都是 &lt;a&gt; 元素)
  2641. // "pageE" 是指定要从下一页获取的元素选择器(也就是网页主体内容),并将其插入当前网页中同样元素的末尾
  2642. // "replaceE" 用于将当前网页中的页码元素替换为下一页的页码元素选择器(这样才能无限翻页下去),省略后将会自动判断是替换 nextL 元素自身还是 nextL 元素的父元素(当 nextL 元素后面或前面有其自身 &lt;a&gt; 元素的相邻兄弟元素时脚本会替换其父元素,反之没有相邻兄弟元素则替换其自身,仅限模式1/3/6,且 "js;" 开头的 nextL 规则除外),值为空 "" 时则完全不替换
  2643. // "scrollD" 是用来指定触发翻页的滚动条与底部之间的距离,当滚动条底部距离网页底部之间的距离等于或小于该值时,将触发翻页,因此值越大就越早触发翻页,访问速度慢的网站需要调大,可省略(记得移除上一行末尾逗号),省略后默认 2000
  2644.  
  2645. // "inherits" 是继承标识,当你只需要对某个外置规则中 增删改 部分规则内容时(比如只是修改域名),那么就可以像下面第二个 "aaa" 规则一样写一个同名规则,规则内只需要有要修改的 host 内容,以及 inherits 标识,这样脚本就会将这个自定义翻页规则中的 host 覆盖掉外置翻页规则中的 host,而该翻页规则内的其他规则内容则不变。即更灵活了,无需每次为了修改部分规则而去复制全部规则了,也不用担心我后续更新这个外置规则后,你还需要再次复制一遍来修改。。。
  2646.  
  2647. {
  2648. "aaa": {
  2649. "host": "aaaa",
  2650. "url": "return fun.isPager()",
  2651. "pager": {
  2652. "nextL": "xxxx",
  2653. "pageE": "xxxx",
  2654. "replaceE": "xxxx",
  2655. "scrollD": 2000
  2656. }
  2657. },
  2658. "aaa": {
  2659. "host": "cccc",
  2660. "inherits": true
  2661. },
  2662. "bbb": {
  2663. "host": ["bbb1.com", "bbb2.com"],
  2664. "url": "/^\\\\/s$/",
  2665. "style": ".aaaa {xxx: xxx}(如果只是为了单纯屏蔽隐藏某些元素,那么这里只需要写 CSS 选择器即可,脚本会自动在末尾加上 {display: none !important;} 的)",
  2666. "blank": 3,
  2667. "hiddenPN": true,
  2668. "history": false,
  2669. "thread": true,
  2670. "iframe": true,
  2671. "pager": {
  2672. "type": 1,
  2673. "nextL": "id('page')//a[contains(text(),'下一页')] || id('page2')//a[text()='下一页']",
  2674. "pageE": "aaa",
  2675. "insertP": [".bbb",3],
  2676. "replaceE": ".page",
  2677. "scriptT": 1,
  2678. "forceHTTPS": true,
  2679. "interval": 500,
  2680. "scrollD": 2000
  2681. },
  2682. "function": {
  2683. "bF": "return fun.src_bF(pageE, [0,'img[data-src]','data-src'])",
  2684. "bFp": "关于上面这个解决图片懒加载的 bF,如果你要选择的图片是 img[data-original] 或 img[data-src],那么是可以直接省略为:return fun.src_bF(pageE)",
  2685. "aF": "document.body.appendChild(document.createElement('script')).textContent = 'xxx'"
  2686. }
  2687. },
  2688. "这里也可以用中文": {
  2689. "host": "/\\\\.ccc\\\\.com/",
  2690. "url": "fun.isUrlC(); return (fun.lp() == '/' || fun.indexOF('/s') || fun.isMobile())",
  2691. "pager": {
  2692. "type": 2,
  2693. "nextL": "#autopbn",
  2694. "nextText": "下一页",
  2695. "nextTextOf": "下一页",
  2696. "isHidden": true,
  2697. "interval": 1000,
  2698. "scrollD": 2000
  2699. }
  2700. }
  2701. }
  2702. </pre></details>
  2703. <details><summary style="cursor: pointer;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"><kbd><strong>「 点击展开 查看所有规则 」(可按 Ctrl+F 搜索规则,脚本内置的通用规则因格式限制无法列出)</strong></kbd></summary>
  2704. <pre id="Autopage_customRules_all" class="notranslate" style="overflow-y: scroll; overflow-x: hidden; height: 500px; word-break: break-all; white-space: pre-wrap;user-select: auto;"> </pre></details>
  2705.  
  2706. <textarea id="Autopage_customRules_textarea" style="min-width:95%; min-height:70%; display: block; margin: 10px 0 10px 0; white-space:pre; overflow:scroll; resize: revert; text-transform: initial;" placeholder="留空等于默认的 {},请把规则插入 {} 之间"></textarea>
  2707. <button id="Autopage_customRules_save" style="margin-right: 20px;">保存并刷新</button><button id="Autopage_customRules_cancel">取消修改</button>
  2708. </div>`
  2709. document.documentElement.insertAdjacentHTML('beforeend', `<div id="Autopage_customRules" style="display: initial !important;position: fixed !important;z-index: 9999999 !important;"></div>`);
  2710. let Autopage_customRules = getCSS('#Autopage_customRules'), shadowRoot = Autopage_customRules.attachShadow({ mode: 'open' }); // 创建一个 Shadow DOM 避免网页样式影响自定义翻页规则元素
  2711. shadowRoot.innerHTML = _html; // 插入元素
  2712. document.documentElement.style.overflow = document.body.style.overflow = 'hidden'; // 避免网页本身滚动
  2713. getCSS('#Autopage_customRules_textarea', shadowRoot).textContent = customRules; // 单独插入自定义规则,避免被 insertAdjacentHTML 语义化 HTML 标签
  2714. getCSS('#Autopage_customRules_all', shadowRoot).textContent = customStringify(DBSite2); // 单独插入全部规则列表,避免被 insertAdjacentHTML 语义化 HTML 标签
  2715. //let b=Object.entries(DBSite2)
  2716. //for (var i = 0; i < b.length; i++) {console.log(b[i][0], b[i][1].host);}
  2717. // 点击事件
  2718. getCSS('#Autopage_customRules_save', shadowRoot).onclick = function () {
  2719. let customRules_textarea = getCSS('#Autopage_customRules_textarea', shadowRoot)
  2720. customRules = customRules_textarea.value;
  2721. if (!customRules) customRules = '{}'
  2722. try {
  2723. customRules = JSON.parse(customRules)
  2724. GM_setValue('menu_customRules', customRules)
  2725. location.reload();
  2726. } catch (e) {
  2727. const match = e.message.match(/at position (\d+)/),position = parseInt(match[1]);
  2728. console.error('自定义规则存在格式错误:\n' + e.message + '\n错误位置为该区域中间:\n------\n' + customRules.slice((position<30)?0:position-30,position+29) + '\n------\n\n常见格式错误:\n1. 逗号:每组 { } 中的最后一个值末尾不能加逗号\n2. 转义:如果正则表达式中含有转义符 \\ 那就要对其再次转义为 \\\\\n3. 引号:规则中冒号左右的内容都需要加上双引号,如果内容中含有双引号则需要对双引号转义(即 \\" 这样),或改为单引号')
  2729. window.alert('自定义规则存在格式错误:\n' + e.message + '\n错误位置为该区域中间:\n------\n' + customRules.slice((position<30)?0:position-30,position+29) + '\n------\n点击【确定】后脚本会为你定位并选中编辑框中格式错误的文本(部分格式错误定位可能不太精确,但错误一定是在选中文本的附近,如果是选中了行首的空格,则说明格式错误来自上一行末尾逗号)\n\n常见格式错误:\n1. 逗号:每组 { } 中的最后一个值末尾不能加逗号\n2. 转义:如果正则表达式中含有转义符 \\ 那就要对其再次转义为 \\\\\n3. 引号:规则中冒号左右的内容都需要加上双引号,如果内容中含有双引号则需要对双引号转义(即 \\" 这样),或改为单引号');
  2730. customRules_textarea.selectionStart = position-1; // 选中开始位置
  2731. customRules_textarea.selectionEnd = position; // 选中结束位置
  2732. customRules_textarea.focus(); // 将焦点移动到 customRules_textarea
  2733. }
  2734. }
  2735. getCSS('#Autopage_customRules_cancel', shadowRoot).onclick = function () {document.documentElement.style.overflow = document.body.style.overflow = ''; getCSS('#Autopage_customRules').remove();}
  2736. }
  2737.  
  2738. // 自定义的 stringify 函数,将 [ ] 内的元素从默认的 换行显示 格式化为 一行显示,用于显示自定义翻页规则等给用户看的场景
  2739. function customStringify(obj) {
  2740. return JSON.stringify(obj, null, 4)
  2741. .replace(/(: \[)([\s\S]*?)(\],?\n)/g, (match, p1, p2, p3) => {
  2742. return p1 + p2.replace(/\n/g, '').replace(/\s{4}/g, '') + p3;
  2743. });
  2744. }
  2745.  
  2746. // 显示页码
  2747. function pageNumber(type) {
  2748. if (curSite.SiteTypeID === 0 || curSite.hiddenPN || (curSite.pager && curSite.pager.type == 5 && self != top)) {if (getCSS('#Autopage_number') && getCSS('#Autopage_number').shadowRoot) {getCSS('#Autopage_number_button', getCSS('#Autopage_number').shadowRoot).style.display = 'none';}; return}
  2749. let status
  2750. if (getCSS('#Autopage_number') && getCSS('#Autopage_number').shadowRoot) {status = getCSS('#Autopage_number_button', getCSS('#Autopage_number').shadowRoot);}
  2751. switch (type) {
  2752. case 'add':
  2753. add(); break;
  2754. case 'del':
  2755. del(); break;
  2756. case 'set':
  2757. set(); break;
  2758. }
  2759.  
  2760. function add(){
  2761. if (status) {
  2762. if (status.style.display === 'none') {status.style.display = 'flex';}
  2763. return
  2764. }
  2765. // 插入网页
  2766. let _style = `<style>#Autopage_number_button {top: calc(75vh);left: 0;width: 32px;height: 32px;padding: 6px;display: flex;position: fixed;opacity: 0.3;transition: .2s;z-index: 9999998;cursor: pointer;user-select: none;flex-direction: column;align-items: center;justify-content: center;box-sizing: content-box;border-radius: 0 50% 50% 0;transform-origin: center;transform: translateX(-8px);background-color: #eee;-webkit-tap-highlight-color: transparent;box-shadow: 1px 1px 3px 0px #aaa;color: #000;font-size: medium;font-family: system-ui;} @media (any-hover: none) {#Autopage_number_button:active {opacity: 0.8;transform: translateX(0);}}@media (any-hover: hover) {#Autopage_number_button:hover {opacity: 0.8;transform: translateX(0);}}</style>`,
  2767. _html = `<div id="Autopage_number_button" title="1. 此为【当前页码】(仅指脚本翻了多少页,并非实际页码,该页码可在脚本菜单中关闭)&#10;&#10;2. 鼠标【左键】点击此处可【临时暂停翻页】(再次点击可恢复)&#10;&#10;3. 鼠标【右键】点击此处可【回到顶部】">${pageNum._now}</div>`
  2768.  
  2769. document.documentElement.insertAdjacentHTML('beforeend', `<div id="Autopage_number" style="display: flex !important;position: fixed !important;z-index: 9999998 !important;"></div>`);
  2770. let Autopage_number = getCSS('#Autopage_number'), shadowRoot = Autopage_number.attachShadow({ mode: 'open' }); // 创建一个 Shadow DOM 避免网页样式影响页码元素
  2771. shadowRoot.innerHTML = _style + _html; // 插入元素
  2772.  
  2773. if (curSite.pager && curSite.pager.type == 5) window.top.document.xiu_pausePage = pausePage
  2774. status = getCSS('#Autopage_number_button', shadowRoot);
  2775. // 左键点击事件(临时暂停翻页)
  2776. status.onclick = function(e) {
  2777. if (pausePage) {this.style.color = '#FF5722'; this.style.fontStyle = 'italic';} else {this.style = '';}
  2778. pausePage = !pausePage;
  2779. if (curSite.pager && curSite.pager.type == 5) window.top.document.xiu_pausePage = pausePage
  2780. e.preventDefault();
  2781. e.stopPropagation();
  2782. return false
  2783. };
  2784. // 右键点击事件(回到顶部)
  2785. status.oncontextmenu = function(e) {
  2786. window.scrollTo(0,0);
  2787. e.preventDefault();
  2788. e.stopPropagation();
  2789. return false
  2790. };
  2791. set();
  2792. }
  2793. // 监听储存当前页码的对象值的变化
  2794. function set(){
  2795. Object.defineProperty(pageNum, 'now', {
  2796. set: function(value) {
  2797. this._now = value;
  2798. if (status) status.textContent = value;
  2799. }
  2800. });
  2801. }
  2802. function del(){
  2803. if (!status) return
  2804. status.style.display = 'none';
  2805. }
  2806. }
  2807.  
  2808. // 页码递增,省略参数默认 +1
  2809. function pageNumIncrement(num = 1) {
  2810. pageNum.now = pageNum._now + num
  2811. }
  2812.  
  2813. // 菜单开关
  2814. function menu_switch(menu_status, Name, Tips) {
  2815. if (menu_status === true){
  2816. GM_setValue(Name, false);
  2817. } else {
  2818. GM_setValue(Name, true);
  2819. }
  2820. if (Name === 'menu_page_number') {
  2821. if (menu_status === true){pageNumber('del');} else {pageNumber('add');}
  2822. registerMenuCommand(); // 重新注册(不可用)脚本菜单
  2823. if (curSite.SiteTypeID !== 0 && curSite.pager) { // 解决开关页码后 翻页失效的问题
  2824. if (curSite.pager.type === undefined) curSite.pager.type = 1; // 默认翻页模式 1
  2825. if (curSite.pager.scrollD === undefined) curSite.pager.scrollD = 2000; // 默认翻页触发线 2000
  2826. if (curSite.pager.interval === undefined) curSite.pager.interval = 500; // 默认间隔时间 500ms
  2827. }
  2828. } else {
  2829. location.reload();}
  2830. };
  2831. // 生成 SiteTypeID
  2832. function setSiteTypeID() {
  2833. let num = 0
  2834. for (let val in DBSite) {
  2835. DBSite[val].SiteTypeID = ++num;
  2836. }
  2837. }
  2838. // 遍历 loadMoreExclude 数组,判断是否包含域名
  2839. function loadMoreExclude(l) {
  2840. for (let i=0; i<l.length; i++) {
  2841. if (location.hostname.indexOf(l[i]) != -1) return false
  2842. }
  2843. return true
  2844. }
  2845. // 获取 Cookie
  2846. function getCookie(name) {
  2847. if (!name) return ''
  2848. let arr = document.cookie.split(';');
  2849. name += '='
  2850. for (let i=0; i<arr.length; i++) {
  2851. let now = arr[i].trim();
  2852. if (now.indexOf(name) == 0) return now.substring(name.length, now.length);
  2853. }
  2854. return '';
  2855. }
  2856. // 插入位置
  2857. function getAddTo(num) {
  2858. switch (num) {
  2859. case 1:
  2860. return 'beforebegin'; break;
  2861. case 2:
  2862. return 'afterbegin'; break;
  2863. case 3:
  2864. case 6:
  2865. return 'beforeend'; break;
  2866. case 4:
  2867. case 5:
  2868. return 'afterend'; break;
  2869. }
  2870. }
  2871. // 插入位置 5 时,排除 <script> <style> <link> 标签
  2872. function toE5pop(a) {
  2873. if (a.length === 0) return
  2874. let b = a.pop();
  2875. if (b.tagName === 'SCRIPT' || b.tagName === 'STYLE' || b.tagName === 'LINK') {
  2876. return toE5pop(a);
  2877. }
  2878. return b
  2879. }
  2880. // 滚动条事件
  2881. function windowScroll(fn1) {
  2882. var beforeScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  2883. fn = fn1 || function () {};
  2884. setTimeout(function () { // 延时 1 秒执行,避免刚载入到页面就触发翻页事件
  2885.  
  2886. // 避免网页内容太少,高度撑不起来,不显示滚动条而无法触发翻页事件
  2887. let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop,
  2888. scrollHeight = window.innerHeight || document.documentElement.clientHeight
  2889. if (scrollTop === 0 && document.documentElement.scrollHeight === scrollHeight) {
  2890. insStyle(`html, body {min-height: ${document.documentElement.scrollHeight+10}px;}`)
  2891. }
  2892.  
  2893. window.addEventListener('scroll', function (e) {
  2894. var afterScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  2895. delta = afterScrollTop - beforeScrollTop;
  2896. if (delta == 0) return false;
  2897. fn(delta > 0 ? 'down' : 'up', e);
  2898. beforeScrollTop = afterScrollTop;
  2899. }, false);
  2900. }, 1000)
  2901. }
  2902. // 自定义 urlchange 事件(用来监听 URL 变化)
  2903. function addUrlChangeEvent() {
  2904. history.pushState = ( f => function pushState(){
  2905. var ret = f.apply(this, arguments);
  2906. window.dispatchEvent(new Event('pushstate'));
  2907. window.dispatchEvent(new Event('urlchange'));
  2908. return ret;
  2909. })(history.pushState);
  2910.  
  2911. history.replaceState = ( f => function replaceState(){
  2912. var ret = f.apply(this, arguments);
  2913. window.dispatchEvent(new Event('replacestate'));
  2914. window.dispatchEvent(new Event('urlchange'));
  2915. return ret;
  2916. })(history.replaceState);
  2917.  
  2918. window.addEventListener('popstate',()=>{
  2919. window.dispatchEvent(new Event('urlchange'))
  2920. });
  2921. }
  2922. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址