自动无缝翻页

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

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