自动无缝翻页

⭐无缝加载 下一页内容 至网页底部(类似瀑布流,无限滚动,无需手动点击下一页)⭐,目前支持:【所有「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(以上仅一小部分常见网站,更多的写不下了...

当前为 2024-12-26 提交的版本,查看 最新版本

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