自动无缝翻页

⭐无缝加载 下一页内容 至网页底部(类似瀑布流)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、B 站(bilibili)、NGA、V2EX、煎蛋网、龙的天空、起点中文、千图网、千库网、Pixabay、Pixiv、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、RuTracker、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE 动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、小众软件、【动漫狂、动漫屋、漫画猫、漫画屋、漫画 DB、动漫之家、拷贝漫画、HiComic、Mangabz、Xmanhua 等漫画网站...】、PubMed、Z-Library、GreasyFork、Github、StackOverflow(以上仅一小部分,更多的写不下了...

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

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