自动无缝翻页

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

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址