自动无缝翻页

⭐无缝加载 下一页内容 至网页底部(类似瀑布流)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、B 站(bilibili)、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(以上仅一小部分,更多的写不下了...

当前为 2023-01-17 提交的版本,查看 最新版本

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