自动无缝翻页

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

当前为 2023-03-13 提交的版本,查看 最新版本

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