自动无缝翻页

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

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