自动无缝翻页

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

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