自动无缝翻页

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

当前为 2022-04-15 提交的版本,查看 最新版本

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