自動無縫翻頁

⭐無縫加載 下一頁內容 至網頁底部(類似瀑布流)⭐,支持各論壇、社交、遊戲、漫畫、小說、學術、搜索引擎(Google、Bing、Yahoo...) 等網站~

目前為 2024-01-24 提交的版本,檢視 最新版本

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

QingJ © 2025

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