自动无缝翻页

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

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