自动无缝翻页

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

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