自动无缝翻页

⭐无缝加载 下一页内容 至网页底部(类似瀑布流,无限滚动,无需手动点击下一页)⭐,目前支持:【所有「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-10-05 提交的版本,查看 最新版本

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