自动无缝翻页

⭐无缝加载 下一页内容 至网页底部(类似瀑布流)⭐,目前支持:【所有「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(以上仅一小部分,更多的写不下了...

当前为 2022-10-24 提交的版本,查看 最新版本

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