自动无缝翻页

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