自动无缝翻页

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

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