自动无缝翻页

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

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