自动无缝翻页

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

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