自动无缝翻页

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

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

  1. // ==UserScript==
  2. // @name 自动无缝翻页
  3. // @name:zh-CN 自动无缝翻页
  4. // @name:zh-TW 自動無縫翻頁
  5. // @name:en AutoPager
  6. // @version 5.6.7
  7. // @author X.I.U
  8. // @description ⭐无缝衔接下一页内容到网页底部(类似瀑布流)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、微博、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 github-do.panbaidu.cn
  15. // @connect github.do
  16. // @connect raw.iqiq.io
  17. // @connect hk1.monika.love
  18. // @connect raw.fastgit.org
  19. // @connect cdn.staticaly.com
  20. // @connect ghproxy.fsofso.com
  21. // @connect raw-gh.gcdn.mirr.one
  22. // @connect cdn.jsdelivr.net
  23. // @connect gcore.jsdelivr.net
  24. // @connect fastly.jsdelivr.net
  25. // @connect www.xuexiniu.com
  26. // @connect bbs.xuexiniu.com
  27. // @connect weili.ooopic.com
  28. // @connect www.ykmh.com
  29. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAALfElEQVRYhX2Xe3Bd1XXGf3vvc859X+nq6nUlW5Yly7JlI2xsYzAwtnk4ATpAxkNTHm0mnaTT/gHTTvrIBDLTpp1JUoZppqHQls5AKTR2INOWJJQSXF4x2BhsJCRZ8kuWZckPSVf3/Trn7N3RVTFpQrNn1l97n7O/vda31reWMKMPcmUJA9U8vrwHGdqCHn4HPzePaIxhVSoYbYRXrn7BeMVbCUduF6kVUXHwvQP+6amDaqDnoIompmQytaBnTmB8H5lowrjgFss48SBeI/hUEEZeudLi1ywhJEIJdL6Q8rzal/1a5SGC4XZrYBvWwEZobMdLdH6RH+z/Io1taEeh52fe8tOZbysl/ouWFvANYP7fSz4DgAEBBIL4xiS8ubmnVcTZK68aRK29Dtm8dgnZJydRW+/E2nrnp19nz+7U77+60zt0qMz07J/KxuQTwrIw4rMBCDP6wC+FIIcO34eudDdXf/7jD52Opi772lugY3AZr++hp06gz48j+waRqTWYmVHcS+chEMFeuw1hBzBzY7g/fQE9fmqBYPzBQKrpVa/R4OkCAnXlSvXnX9sIllk220BE4Z8OdHoj54YCK6Od1i2/iUmuRyDRk6NUn3+M0pv/hnf0AE40jEjEqP3oe6Rf/CGOWUTNjFKby2MP7EBtugURFWFxfOhB4+o4yfhrGAdZsxHaqZt6dNce9KXYFSPfGWS68JFqTXSqO7+MCaTqETGTwxSeeoRCOoPT2YUIhFC2jbQF/uwUatU6rPbVUM5T+OfHUO3dWKv6kSsGUIOD6PEPr+fswnanpecFZYVQhFAyjPS9Tj4xw2rcU+pJApEutWsvRjaBW8NUShilkE1JIqlUPfi6VMLNFTBVr+7KYKqJ8uEjlM+dJrR5K0L7eB+9hTd2CFrWYt33h0jH3O5Nj37TBGtgZUBkUN/6q4dQ7UmsnlW450//gU5PPRq460uQXAu+j//i99A/+UdUMoXqbMNkz2OnUkixlF4u9spe/HMTULyEaA7jXkoT2fEbQIXi838DJ4cRDXHkEjc2b0MPHdptZubGpBUbM0UfKQpBRDmKWRSD3tTMk87gddA2WGe4+dkzMD0CyQ5qP/4XVDCAvfkaLMvHamzEClpQzGDF46iuJOH1CaKr2tDZRfzhQ0Ru24NYsYrCM4/jDb+FiHdi3XU/0s3vr7WsGKxcfyPSy+bxi0UqJ8f/IriiE2vrnuWsLefQk8NoO4AMBBB9/XjDI6hQCjdTxq9WCaQ6ULaDFrIeKr3oIlv70Olz2K1xlAVaSUQojD786nKi9e5A3LBHMHn0W+LUUaS1FI9q+iZZWLhHdq/FxFbWSSfsIDIQwVw4g/GK2OuuhloNMzaCaF+DNBJtQfX8LFYigElX0OkQtZKHVy3jqwDlqWncCzPI3nU4t+2FWrH+OLHzHpRl3109memTOhqDi9NfkefHEKvWLTO+VKD68Qf4G27CueFWhJ/Df+0lVFcXJOJYnobm1ZjsJUxuFjyDjK/GNK2gND4ESuDPXcCOSaI7thPqX0ft8OtUn/oTKOQgkET39KJU4RbpZXOtNRW717p+FyRSdYT+v36H4u/fQXbfc3iRDkT3FsTGjWAWEU0OZKfAU9CyEdXVD2lQPduplmo4jkBEbMzK1VgDu5EVTe3gm1RHx6Bcxpz6YLkEO0lMYeFGi6z7eVMqhkT/ZrCb0LNT+NMTRH/nt/BLRdy3X8Nv68Lu6cZEHURjE6K3hirYeLRhDWyA4jxzH40RXJwkeuM29MpN+JcziEsz+Avz6GgcW1pYbUlEQCyHwYpSyxS7rGo+v8man4ZMATrAHf+QSt7FTkWR4QbsjlbIX8IMH0VuuAqj4piGAbhmEPPzI/injnNxMUPuwOtseOIxKKTJ7/8BTBxDdXcjO9sJdTeg01VqH4wg3CDB9bshHMKORbGolVOmeRW09dVdUxkbp3ruNM7GXnS1hK5OYSoSbBDZBcxCBtF3DcUzk6hkhGA0RmtHKx1rOkE04lbzWC1tqMRt1CZHUafPIs8H6/JsNTcgN+9YFq1qgbBUFUvnK9qrVghXCvWN8MBmivueJDtylqaeBKWJaXR4JZEtNyBWrkGt6AJboCZO4J49Rc64xGIhcgtZgm6egKhgtUQQto17WeHOLqCNj5Vowbr7q4j+Lcs1JhhEphcXLTebd0jPwpkx6Lwa++bbCR95ALecp5a6BrvrJoLdHajmMOTnKb3+BrVMntjARpzeFbz8jcfpa22gGm+kMJlm95Zu9M9+iI5G0G3d6EgIUSnjzs/gv/Icgd6rqcvz0IeYWnXc8pEtYnEe8gtXNL7xz74LehHSE3DqNP7EIdx3p5DSh7JNJePiBE/gN3Uz8NWHae5sRJYXqKQvU+raQPg7L6L3/QNMHcfp6EREGjC5LDp9GaOs5VQ/NQI93YctOxFPlwniDh/C3n47JHvrQPTBl3DHjiIDQUQ4jGhOYcqaQFuE0Nl53OnLRHfsZV33KsTxd6GlHeaP477zMl5uAWv7dkyLg6kZREsb+vgCcvPOuoaYuWNQWERs3jAuQ6nooXK6TH566cXnrjQK7uwFaoseWA3oJf2WEhEJUjm/gMgXCfdvQlFFv/R3uCND6FIRv7MfMnOIiaPoI/8NEb2kWAhfoLbdjLr2jmUv/8f+pVbkHRGNnZHum2/udxxtCn4j/vgEIjNTD4O9upfIprUYoxBKo9Z14jumTq7YYD9WayvuR++hs1lkshmha4iuNeDYiIAFMoCevIi+cJHaa29gmvsRTUn0R29g9u1D7bxxv+jrRnpD56cCkdjfV9NzpA+8A5VlLojWAczlGVTAYKXimIU8MlsjtKEXgiF0aRGdm8cEYnXm+O+/gdAGuWsP3shhTHoOEYqCCEF2DsrF5f+e/xiikUldrT6l3z+GevSaTahaZdRY6uFqxRXR1sRyzU/21Gu6OTOMfzmPd6kI8TgiX8B4imouj1QCKmVUNITJ59AnR1F77kH4ZaRnQFroMyeRW3egdt6DwIX391Gshv+4LK2jtcuLqK9t7ALjZXzH1uVM/mb/7BTRnjZEex+idQ2EAnjjR/BdF1PIoV2Bae/F/fh9dL5IYE0XUmpMNo+ev4AINSJWb0UPHa63Z7SvRN3/CHJpFHj2G4iZzAuBbTu+GWpIEGxrQ/3RnlvxG5M4kYa3Lc2u4uyFblnIE+xfAbF2RMtqZGsn/uTYUgHH+dz9eFMnqYx8gO+CEwkjhcDPF/DLHurSaeTm3RiWMsDHeuDrSFvBv3+bi08+N1Vwuj/vZWtu+dwclZlFrESoeZmZysJXoTsCjnVk8dDQBuN+n8RDD9fbcdG7leBX1iOkQjhBOHmQfKGAHW3CS6fR+QClmYuYMyPY265DtPVgtfctiw4V/GcfYfGNQzj3/u4DqlormUoZEQwuc0I//eSnY4G0wPJjmdGhw+mh0fWxNZ0037cXccPd1MXgk+GjNE/tR3+Le+YEyg5TnT6LXlwgcu1u7C99HZlsv3K2+vjvkTs2RvDe3747tm7Dy1SKvzSYPP/MLwxFAkIKEzEye2zswOXX395lJyK0fOFzRHfuglQfqPin59Nn0RNDuJk09vprkd0brmx5H7xCbfgQbrZ83OkfvN1pj0+ZmkBYNhjzCwCeffr/AsBDJyU6kqBwbPzRuTcP/GXV82lYlaJpfQ+BjVdhXX0tNKTAjvzKqKXPTeC++1NKY0c9kVz1SGzb9X8tjIdfzSFCDfUw/noA0scPuxBrwcvmmH3rQIvMm3/y0XdJS4JfIpiIUG9g+wcg6KDnZpGZNDQ0Ii5cSAtlPRHYct13axWvJNwadiiAli4iEP8VAJ89HQtR129TLiG1nos0Nt8dSOi12qi9lRq3utVqT/lirql24hW3vLBQi3d3XUqu73+PZOonBNR/WnbYSMeGTO5/Xf6ZtwDwPwtFRezQVs+sAAAAAElFTkSuQmCC
  30. // @grant GM_xmlhttpRequest
  31. // @grant GM_registerMenuCommand
  32. // @grant GM_unregisterMenuCommand
  33. // @grant GM_openInTab
  34. // @grant GM_getValue
  35. // @grant GM_setValue
  36. // @grant GM_notification
  37. // @grant window.onurlchange
  38. // @grant unsafeWindow
  39. // @license GPL-3.0 License
  40. // @run-at document-end
  41. // @namespace https://github.com/XIU2/UserScript
  42. // @supportURL https://github.com/XIU2/UserScript
  43. // @homepageURL https://github.com/XIU2/UserScript
  44. // @exclude https://*.taobao.com/*
  45. // @exclude https://*.tmall.com/*
  46. // @exclude https://*.1688.com/*
  47. // @exclude https://*.jd.com/*
  48. // @exclude https://*.vip.com/*
  49. // @exclude https://*.suning.com/*
  50. // @exclude https://*.aliexpress.com/*
  51. // @exclude https://*.amazon.com/*
  52. // @exclude https://*.amazon.cn/*
  53. // @exclude https://*.ebay.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. ], menuId = [], webType = 0, curSite = {SiteTypeID: 0}, DBSite, SiteType, pausePage = true, pageNum = {now: 1, _now: 1}, urlC = false, nowLocation = '', lp = location.pathname;
  92. 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, getNextEPN: getNextEPN, getNextUPN: getNextUPN, getNextUP: getNextUP, getNextF: getNextF, getCookie: getCookie, insStyle: insStyle, insScript: insScript, src_bF: src_bF, xs_bF: xs_bF}
  93.  
  94. for (let i=0;i<menuAll.length;i++){ // 如果读取到的值为 null 就写入默认值
  95. if (GM_getValue(menuAll[i][0]) == null){GM_setValue(menuAll[i][0], menuAll[i][3])};
  96. }
  97.  
  98. getRulesUrl();
  99. registerMenuCommand();
  100. if (menuId.length < 4) {return}
  101. // 注册脚本菜单
  102. function registerMenuCommand() {
  103. if (menuId.length != []){
  104. for (let i=0;i<menuId.length;i++){
  105. GM_unregisterMenuCommand(menuId[i]);
  106. }
  107. }
  108. for (let i=0;i<menuAll.length;i++) { // 循环注册脚本菜单
  109. menuAll[i][3] = GM_getValue(menuAll[i][0]);
  110.  
  111. if (menuAll[i][0] === 'menu_disable') { // 启用/禁用
  112.  
  113. if (menu_disable('check')) { // 当前网站在禁用列表中
  114. menuId[i] = GM_registerMenuCommand(`${menuAll[i][2]}`, function(){menu_disable('del')});
  115. return
  116. } else { // 不在禁用列表中
  117. webType = doesItSupport(); // 判断网站类型(即是否支持),顺便直接赋值
  118. if (webType === 0) {
  119. 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});});
  120. menuId[1] = GM_registerMenuCommand('🔄 更新外置翻页规则 (每天自动)', function(){getRulesUrl(true)});
  121. menuId[2] = GM_registerMenuCommand('#️⃣ 自定义翻页规则', function(){customRules()});
  122. console.info('[自动无缝翻页] - 暂不支持当前网页 [ ' + location.href + ' ],欢迎申请支持: https://github.com/XIU2/UserScript / https://greasyfork.org/zh-CN/scripts/419215/feedback');
  123. return
  124. } else if (webType === -1) {
  125. return
  126. }
  127. menuId[i] = GM_registerMenuCommand(`${menuAll[i][1]}`, function(){menu_disable('add')});
  128. }
  129.  
  130. } else if (menuAll[i][0] === 'menu_rules') {
  131. menuId[i] = GM_registerMenuCommand(`🔄 ${menuAll[i][1]}`, function(){getRulesUrl(true)});
  132.  
  133. } else if (menuAll[i][0] === 'menu_customRules') {
  134. menuId[i] = GM_registerMenuCommand(`#️⃣ ${menuAll[i][1]}`, function(){customRules()});
  135.  
  136. } else {
  137. menuId[i] = GM_registerMenuCommand(`${menuAll[i][3]?'✅':'❌'} ${menuAll[i][1]}`, function(){menu_switch(menuAll[i][3], menuAll[i][0], menuAll[i][2])});
  138. }
  139. }
  140. 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});});
  141. }
  142.  
  143.  
  144. // --------------------------------------------------------
  145.  
  146.  
  147. // 判断是支持
  148. function doesItSupport() {
  149. setDBSite(); // 配置 DBSite 变量对象
  150.  
  151. // 遍历判断是否是某个已支持的网站,顺便直接赋值
  152. let support = false;
  153. end:
  154. for (let now in DBSite) { // 遍历 对象
  155. if (!DBSite[now].host) continue; // 如果不存在则继续下一个循环
  156. //console.log(DBSite[now].host)
  157. // 如果是 数组
  158. if (Array.isArray(DBSite[now].host)) {
  159.  
  160. for (let i of DBSite[now].host) { // 遍历 数组
  161. // 针对自定义翻页规则中的正则
  162. if (typeof i === 'string' && i.slice(0,1) === '/') i = new RegExp(i.slice(1,i.length-1))
  163. if ((i instanceof RegExp && i.test(location.hostname)) || (typeof i === 'string' && i === location.hostname)) {
  164.  
  165. if (self != top) {if (!DBSite[now].iframe) break end;} // 如果当前位于 iframe 框架下,就需要判断是否需要继续执行
  166. if (DBSite[now].url) {
  167. if (typeof DBSite[now].url == 'function') {
  168. DBSite[now].url();
  169. } else { // 自定义翻页规则时,因为同域名不同页面 url 分开写,所以如果没找到就需要跳出当前数组循环,继续规则循环
  170. try {
  171. if (DBSite[now].url.slice(0,1) === '/') { // 如果是正则,则对 URL 路径进行匹配
  172. 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;}
  173. } else { // 如果是函数,那就执行代码
  174. if (new Function('fun', DBSite[now].url)(window.autoPage) === true) {curSite = DBSite[now];} else {if (urlC === true) {support = true;}; break;}
  175. }
  176. } catch (e) {
  177. console.error('[自动无缝翻页] - 当前网页规则 "url" 有误,请检查!', e);
  178. }
  179. }
  180. } else {
  181. curSite = DBSite[now];
  182. }
  183. support = true; break end; // 如果找到了就退出所有循环
  184. }
  185. }
  186.  
  187. // 如果是 正则/字符串
  188. } else {
  189. // 针对自定义翻页规则中的正则
  190. 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))
  191. if ((DBSite[now].host instanceof RegExp && DBSite[now].host.test(location.hostname)) || (typeof DBSite[now].host === 'string' && DBSite[now].host === location.hostname)) {
  192.  
  193. if (self != top) {if (!DBSite[now].iframe) break;} // 如果当前位于 iframe 框架下,就需要判断是否需要继续执行
  194. if (DBSite[now].url) {
  195. if (typeof DBSite[now].url == 'function') {
  196. DBSite[now].url();
  197. } else { // 自定义翻页规则时,因为同域名不同页面 url 分开写,所以如果没找到就需要继续规则循环
  198. try {
  199. if (DBSite[now].url.slice(0,1) === '/') { // 如果是正则,则对 URL 路径进行匹配
  200. 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;}
  201. } else { // 如果是函数,那就执行代码
  202.  
  203. if (new Function('fun', DBSite[now].url)(window.autoPage) === true) {curSite = DBSite[now];} else {if (urlC === true) {support = true;}; continue;}
  204.  
  205. }
  206. } catch (e) {
  207. console.error('[自动无缝翻页] - 当前网页规则 "url" 有误,请检查!', e);
  208. }
  209. }
  210. } else {
  211. curSite = DBSite[now];
  212. }
  213. support = true; break; // 如果找到了就退出循环
  214. }
  215. }
  216. }
  217.  
  218. if (support) {
  219. console.info('[自动无缝翻页] - 独立规则 网站'); return 1;
  220. } else if (self != top) {
  221. return -1;
  222. } 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!")]')) {
  223. console.info(`[自动无缝翻页] - <Discuz!> 论坛`); return 2;
  224.  
  225. } else if (typeof flarum != 'undefined' || getCSS('#flarum-loading')) {
  226. console.info(`[自动无缝翻页] - <Flarum> 论坛`); return 3;
  227.  
  228. } else if (typeof phpbb != 'undefined' || getCSS('body#phpbb')) {
  229. console.info(`[自动无缝翻页] - <phpBB> 论坛`); return 4;
  230.  
  231. } else if (typeof xn != 'undefined' && getXpath('//footer//a[contains(string(), "Xiuno")] | //link[contains(@href, "xiuno")] | //script[contains(@src, "xiuno")]')) {
  232. console.info(`[自动无缝翻页] - <Xiuno> 论坛`); return 5;
  233.  
  234. } else if (typeof XF != 'undefined') {
  235. console.info(`[自动无缝翻页] - <XenForo> 论坛`); return 6;
  236.  
  237. } else if (getCSS('head meta[name="generator" i][content="nexusphp" i]') || getXpath('id("footer")[contains(string(), "NexusPHP")]')) {
  238. console.info(`[自动无缝翻页] - <NexusPHP> 论坛`); return 7;
  239.  
  240. } else if (getAllCSS('.load-more, .loadmore, #load-more, #loadmore, .show_more').length === 1) {
  241. console.info(`[自动无缝翻页] - 部分自带 自动无缝翻页 的网站 1`); return 8;
  242.  
  243. } else if (getAllXpath('//*[@onclick][text()="加载更多" or text()="查看更多"][not(@href) or @href="#" or starts-with(@href, "javascript")]').length === 1) {
  244. console.info(`[自动无缝翻页] - 部分自带 自动无缝翻页 的网站 2`); return 9;
  245.  
  246. } else if (getCSS('link[href*="/wp-content/" i], script[src*="/wp-content/" i]')) {
  247. if (getAllCSS('article[class], div[id^="post-"], ul[class*="post"] > li.item').length > 2 && getCSS('#nav-below, nav.navigation, nav.paging-navigation, .pagination, .wp-pagenavi, .pagenavi')) {
  248. if (getCSS('a.next, a.next-page')) {
  249. console.info(`[自动无缝翻页] - 部分使用 WordPress 的网站 (a.next)`); return 100;
  250. } else if (getCSS('a[rel="next" i], a[aria-label="Next Page" i], a[aria-label="下一页"]')) {
  251. console.info(`[自动无缝翻页] - 部分使用 WordPress 的网站 (a[rel="next"])`); return 101;
  252. } else if (getCSS('li.next-page > a, li.next > a')) {
  253. console.info(`[自动无缝翻页] - 部分使用 WordPress 的网站 (li.next-page > a)`); return 102;
  254. } else if (getCSS('.nav-previous a, a.nav-previous')) {
  255. console.info(`[自动无缝翻页] - 部分使用 WordPress 的网站 (旧文章)`); return 103;
  256. } 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'))) {
  257. console.info(`[自动无缝翻页] - 部分使用 WordPress 的网站 (下一页)`); return 104;
  258. }
  259. }
  260. } else if (getCSS('meta[name="generator" i][content*="Typecho" i]')) {
  261. if (getCSS('li.next > a') && getCSS('.blog-post, .post-list') && getCSS('.page-navigator')) {
  262. console.info(`[自动无缝翻页] - 部分使用 Typecho 的网站 (handsome)`); return 150;
  263. }
  264.  
  265. } else if (getCSS('.stui-page, .stui-page__item') && getCSS('li.active.hidden-xs+li.hidden-xs>a') && getCSS('.stui-vodlist')) {
  266. console.info(`[自动无缝翻页] - 部分影视网站`); return 300;
  267.  
  268. } else if (getCSS('.ArticleImageBox, .PictureList') && getCSS('.article_page') && getXpath('//div[contains(@class,"article_page")]//a[text()="下一页"]')) {
  269. console.info(`[自动无缝翻页] - 部分美女图站 - 手机版`); return 301;
  270.  
  271. } else if (getCSS('.content > #content') && getCSS('.page_chapter') && getXpath('//div[contains(@class,"page_chapter")]//a[text()="下一章"]')) {
  272. console.info(`[自动无缝翻页] - <笔趣阁 1> 模板的小说网站`); return 200;
  273. } else if (getCSS('#nr1') && getCSS('.nr_page') && getCSS('#pb_next')) {
  274. console.info(`[自动无缝翻页] - <笔趣阁 2 - 手机版> 模板的小说网站`); return 201;
  275. } else if (getCSS('#txt, .txt') && getCSS('#pb_next, .url_next') && getCSS('.chapter-control, .chapter-page-btn')) {
  276. console.info(`[自动无缝翻页] - <笔趣阁 3> 模板的小说网站`); return 202;
  277. } 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(), "下一页")]'))) {
  278. console.info(`[自动无缝翻页] - <笔趣阁 4> 模板的小说网站`); return 203;
  279. }
  280. return 0;
  281. }
  282. // 判断网站类型
  283. function webTypeIf() {
  284. if (webType != 1) {
  285. switch (webType) {
  286. case 2: // < 所有 Discuz!论坛 >
  287. discuz_(); break;
  288. case 3: // < 所有 Flarum 论坛 >
  289. DBSite.flarum.url(); break;
  290. case 4: // < 所有 phpBB 论坛 >
  291. DBSite.phpbb.url(); break;
  292. case 5: // < 所有 Xiuno 论坛 >
  293. DBSite.xiuno.url(); break;
  294. case 6: // < 所有 XenForo 论坛 >
  295. DBSite.xenforo.url(); break;
  296. case 7: // < 所有 NexusPHP 论坛 >
  297. DBSite.nexusphp.url(); break;
  298. case 8: // < 部分自带 自动无缝翻页 的网站 1 >
  299. DBSite.loadmore.url('.load-more, .loadmore, #load-more, #loadmore, .show_more'); break;
  300. case 9: // < 部分自带 自动无缝翻页 的网站 2 >
  301. DBSite.loadmore.url('//*[@onclick][text()="加载更多" or text()="查看更多"][not(@href) or @href="#" or starts-with(@href, "javascript")]'); break;
  302. case 100: // < 部分使用 WordPress 的网站 (a.next) >
  303. DBSite.wp_article.url('a.next, a.next-page'); break;
  304. case 101: // < 部分使用 WordPress 的网站 (a[rel="next"]) >
  305. DBSite.wp_article.url('a[rel="next" i], a[aria-label="Next Page" i], a[aria-label="下一页"]'); break;
  306. case 102: // < 部分使用 WordPress 的网站 (li.next-page > a) >
  307. DBSite.wp_article.url('li.next-page > a, li.next > a'); break;
  308. case 103: // < 部分使用 WordPress 的网站 (旧文章) >
  309. DBSite.wp_article.url('.nav-previous a, a.nav-previous'); break;
  310. case 104: // < 部分使用 WordPress 的网站 (下一页) >
  311. DBSite.wp_article.url('//*[self::ul or self::nav or self::div][@id="nav-below" or contains(@class, "navigation") or contains(@class, "pagination") or contains(@class, "pagenavi")]//a[contains(text(), "下一页") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")]'); break;
  312. case 150: // < 部分使用 Typecho 的网站 (handsome) >
  313. curSite = DBSite.typecho_handsome; break;
  314. case 200: // < 所有使用 笔趣阁 1 模板的小说网站 >
  315. DBSite.biquge1.url(); break;
  316. case 201: // < 所有使用 笔趣阁 2 - 手机版 模板的小说网站 >
  317. curSite = DBSite.biquge1_m; break;
  318. case 202: // < 所有使用 笔趣阁 3 模板的小说网站 >
  319. DBSite.biquge2.url(); break;
  320. case 203: // < 所有使用 笔趣阁 4 模板的小说网站 >
  321. curSite = DBSite.biquge3; break;
  322. case 300: // < 部分影视网站 >
  323. curSite = DBSite.yingshi; break;
  324. case 301: // < 部分美女图站 - 手机版 >
  325. curSite = DBSite.meinvtu_m; break;
  326. }
  327. }
  328. }
  329. // 内置翻页规则
  330. function setDBSite() {
  331. /*
  332. url: 匹配到该域名后要执行的函数/正则(一般用于根据 URL 分配相应翻页规则)
  333. urlC: 对于使用 pjax 技术的网站,需要监听 URL 变化来重新判断翻页规则(需要放在 url: 中,自定义规则的话需要使用 fun.isUrlC())
  334.  
  335. noReferer: 获取下一页内容时,不携带 Referer(部分网站携带与不携带可能不一样)
  336. hiddenPN: 不显示脚本左下角的页码
  337. history: 添加历史记录 并 修改当前 URL(默认开启,对于不支持的网站要设置为 false)
  338. thread: 对于社区类网站,要在 帖子内 的规则中加入这个,用于脚本的 [帖子内自动翻页] 功能(即用户可以选择开启/关闭所有社区类网站帖子内的自动翻页)
  339. style: 要插入网页的 CSS Style 样式
  340. retry: 允许获取失败后重试
  341. blank: 强制新标签页打开链接(1 = <base>,2 = 对 body 点击事件委托,3 = 仅对 pageE 的父元素点击事件委托)
  342.  
  343. pager: {
  344. type: 翻页模式
  345. 1 = 由脚本实现自动无缝翻页,可省略(适用于:静态加载内容网站,常规模式)
  346.  
  347. 2 = 只需要点击下一页按钮(适用于:网站自带了 自动无缝翻页 功能)
  348. nextText: 按钮文本,当按钮文本 = 该文本时,才会点击按钮加载下一页(避免一瞬间加载太多次下一页,下同)
  349. nextTextOf: 按钮文本的一部分,当按钮文本包含该文本时,才会点击按钮加载下一页
  350. nextHTML: 按钮内元素,当按钮内元素 = 该元素内容时,才会点击按钮加载下一页
  351. interval: 点击间隔时间,对于没有按钮文字变化的按钮,可以手动指定间隔时间(单位 ms,默认 500,当指定上面三个时,会忽略 interval)
  352. isHidden: 只有下一页按钮可见时(没有被隐藏),才会点击
  353.  
  354. 3 = 依靠 [基准元素] 与 [浏览器可视区域底部] 之间的距离缩小来触发翻页(适用于:主体元素下方内容太多 且 高度不固定时)
  355. scrollE: 作为基准线的元素(一般为底部页码元素),和 replaceE 一样的话可以省略
  356. scrollD: 基准元素 - 可视区域底部
  357.  
  358. 4 = 动态加载类网站(适用于:简单的动态加载内容网站)
  359. insertE: 用来插入元素的函数
  360.  
  361. 5 = 插入 iframe 方式来加载下一页,无限套娃(适用于:部分动态加载内容的网站,需要允许 iframe 且支持通过 GET/POST 直接打开下一页)
  362. style: 加载 iframe 前要插入的 CSS Style 样式(比如为了悬浮的样式与下一页的重叠,隐藏网页底部间距提高阅读连续性)
  363. iframe: 这个必须加到 pager{} 外面(这样才会在该域名的 iframe 框架下运行脚本)
  364.  
  365. 6 = 通过 iframe 获取下一页动态加载内容插入本页,只有一个娃(适用于:部分动态加载内容的网站,与上面不同的是,该模式适合简单的网页,没有复杂事件什么的)
  366. loadTime: 预留的网页加载时间,确保网页内容加载完成
  367.  
  368. nextL: 下一页链接所在元素
  369. pageE: 要从下一页获取的元素
  370. insertP: 下一页元素插入本页的位置(数组第一个是基准元素,第二个是基准元素的前后具体位置)
  371. 1 = 插入基准元素自身的前面
  372. 2 = 插入基准元素内,第一个子元素前面
  373. 3 = 插入基准元素内,最后一个子元素后面
  374. 4 = 插入基准元素自身的后面
  375. 5 = 插入 pageE 列表最后一个元素的后面(该 insertP 可以直接省略不写,等同于 ['pageE', 5] )
  376. 6 = 插入该元素自身内部末尾(针对小说网站等文本类的),附带参数 insertP6Br: true, 用来中间插入换行
  377. // 小技巧:当基准元素是下一页主体元素的父元素时(或者说要将下一页元素插入到本页同元素最后一个后面时)是可以省略不写 insertP
  378. 例如:当 pageE: 'ul>li' 且 insertP: ['ul', 3] 时,实际等同于 ['ul>li', 5]
  379. 当 pageE: '.item' 且 insertP: ['.item', 4] 时,实际等同于 ['.item', 5]
  380. 当 pageE: '.item' 且 insertP: ['.page', 1] 时,实际等同于 ['.item', 5]
  381. 注意:如 pageE 中选择了多类元素,则不能省略 insertP(比如包含 `,` 与 `|` 符号),除非另外的选择器是 <script> <style> <link> 标签
  382.  
  383. replaceE: 要替换为下一页内容的元素(比如页码)
  384. scrollD: 翻页动作触发点([滚动条] 与 [网页底部] 之间的距离),数值越大,越早开始翻页,一般是访问网页速度越慢,该值就需要越大,省略后默认 1500
  385.  
  386. scriptT: 单独插入 <script> 标签
  387. 0 = 下一页的所有 <script> 标签
  388. 1 = 下一页的所有 <script> 标签(不包括 src 链接)
  389. 2 = 下一页主体元素 (pageE) 的同级 <script> 标签
  390. 3 = 下一页主体元素 (pageE) 的子元素 <script> 标签
  391.  
  392. interval: 翻页后间隔时间(单位 ms)
  393. forceHTTPS: 下一页链接强制 HTTPS
  394. },
  395. function: {
  396. bF = 插入前执行函数
  397. bFp = 参数
  398. aF = 插入后执行函数
  399. aFp = 参数
  400. }
  401. */ //<<< 规则简单说明 >>>
  402. DBSite = {
  403. loadmore: {
  404. url: function(nextL) {curSite = DBSite.loadmore; curSite.pager.nextL = nextL;},
  405. pager: {
  406. type: 2,
  407. isHidden: true,
  408. interval: 1000,
  409. scrollD: 2000
  410. }
  411. }, // 部分自带 自动无缝翻页 的网站
  412. wp_article: {
  413. url: function(nextL) {if (!indexOF('/post/') && !getCSS('#comments, .comments-area, #disqus_thread')) {curSite = DBSite.wp_article; curSite.pager.nextL = nextL; if (getCSS('img[data-src]')) {curSite.function = {bF: "return fun.src_bF(pageE, [0, 'img[data-src]', 'data-src'])"};} else if (getCSS('img[data-original]')) {curSite.function = {bF: "return fun.src_bF(pageE, [0, 'img[data-original]', 'data-original'])"};}}},
  414. blank: 1,
  415. pager: {
  416. pageE: 'article[class], div[id^="post-"], ul[class*="post"] > li.item',
  417. replaceE: '#nav-below, nav.navigation, nav.paging-navigation, .pagination, .wp-pagenavi, .pagenavi',
  418. scrollD: 2000
  419. }
  420. }, // 部分使用 WordPress 的网站
  421. typecho_handsome: {
  422. blank: 1,
  423. pager: {
  424. nextL: 'li.next > a',
  425. pageE: '.blog-post, .post-list',
  426. replaceE: '.page-navigator',
  427. scrollD: 2000
  428. }
  429. }, // 部分使用 Typecho 的网站 (handsome)
  430. biquge1: {
  431. url: ()=> {curSite = DBSite.biquge1;xs_bF(getAllCSS('.content > #content'),[/<br>.{0,10}秒记住.+$/, '']);},
  432. style: 'img, .posterror, a[href*="posterror()"], [style*="url("], #content > *:not(br):not(p) {display: none !important;}',
  433. history: true,
  434. pager: {
  435. nextL: '//div[@class="page_chapter"]//a[text()="下一章"]',
  436. pageE: '.content > #content',
  437. insertP: ['.content > #content', 6],
  438. replaceE: '.page_chapter'
  439. },
  440. function: {
  441. bF: xs_bF,
  442. bFp: [/<br>.{0,10}秒记住.+$/, '']
  443. }
  444. }, // 笔趣阁 1 模板的小说网站
  445. biquge1_m: {
  446. style: 'img, .posterror, .show-app2, a[href*="posterror()"], [onclick*="location.href"], [style*="url("], #nr1 > *:not(br):not(p) {display: none !important;}',
  447. history: true,
  448. pager: {
  449. nextL: '#pb_next',
  450. pageE: '#nr1',
  451. insertP: ['#nr1', 6],
  452. replaceE: '.nr_page'
  453. }
  454. }, // 笔趣阁 2 - 手机版 模板的小说网站
  455. biquge2: {
  456. url: ()=> {if (isMobile() || getCSS('.chapter-page-btn') != null) {curSite = DBSite.biquge2_m;} else {curSite = DBSite.biquge2;}},
  457. style: 'img, .posterror, a[href*="posterror()"], [style*="url("], #txt > *:not(br):not(p) {display: none !important;}',
  458. history: true,
  459. pager: {
  460. type: 6,
  461. nextL: '#pb_next, .url_next',
  462. pageE: '#txt, .txt',
  463. insertP: ['#txt, .txt', 6],
  464. replaceE: '.chapter-control, .chapter-page-btn',
  465. loadTime: 1500,
  466. scrollD: 3500
  467. }
  468. }, // 笔趣阁 3 模板的小说网站
  469. biquge2_m: {
  470. style: 'img, .posterror, a[href*="posterror()"], [style*="url("], #txt > *:not(br):not(p) {display: none !important;}',
  471. history: true,
  472. pager: {
  473. nextL: '#pb_next, .url_next',
  474. pageE: '#txt, .txt',
  475. insertP: ['#txt, .txt', 6],
  476. replaceE: '.chapter-control, .chapter-page-btn',
  477. scrollD: 2000
  478. }
  479. }, // 笔趣阁 3 - 手机版 模板的小说网站
  480. biquge3: {
  481. style: 'img, .posterror, a[href*="posterror()"], [style*="url("], script+div[style="padding:15px;"] {display: none !important;}',
  482. history: true,
  483. pager: {
  484. nextL: '//a[contains(text(), "下一章") or contains(text(), "下一页")]',
  485. pageE: '[id="content" i], [class~="content" i], [id="chaptercontent" i], [class~="chaptercontent" i], [id="booktext" i], [id="txtcontent" i]',
  486. insertP: ['[id="content" i], [class~="content" i], [id="chaptercontent" i], [class~="chaptercontent" i], [id="booktext" i], [id="txtcontent" i]', 6],
  487. insertP6Br: true,
  488. replaceE: '//a[contains(text(), "下一章") or contains(text(), "下一页")]/parent::*'
  489. },
  490. function: {
  491. bF: xs_bF,
  492. bFp: [/<br>.{0,10}秒记住.+$/, '']
  493. }
  494. }, // 笔趣阁 4 模板的小说网站
  495. yingshi: {
  496. style: 'div.stui-page__all {display: none !important;}',
  497. blank: 3,
  498. pager: {
  499. nextL: 'li.active.hidden-xs+li.hidden-xs>a',
  500. pageE: '.stui-vodlist',
  501. replaceE: '.stui-page, .stui-page__item',
  502. scrollD: 1000
  503. },
  504. function: {
  505. bF: src_bF,
  506. bFp: [1, '[data-original]', 'data-original']
  507. }
  508. }, // 部分影视网站
  509. meinvtu_m: {
  510. history: true,
  511. blank: 3,
  512. pager: {
  513. type: 3,
  514. nextL: '//div[contains(@class,"article_page")]//a[text()="下一页"]',
  515. pageE: '.ArticleImageBox, .PictureList',
  516. replaceE: '.article_page',
  517. scrollD: 500
  518. }
  519. }, // 部分美女图站 - 手机版
  520. discuz_forum: {
  521. pager: {
  522. type: 2,
  523. nextL: '#autopbn',
  524. nextTextOf: '下一'
  525. }
  526. }, // Discuz! 论坛 - 帖子列表(自带无缝加载下一页按钮的)
  527. discuz_guide: {
  528. pager: {
  529. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  530. pageE: 'id("threadlist")//table[./tbody[contains(@id, "normalthread_")]]/tbody[not(@id="separatorline")]',
  531. replaceE: '.pg, .pages',
  532. forceHTTPS: true
  533. }
  534. }, // Discuz! 论坛 - 导读页 及 帖子列表(不带无缝加载下一页按钮的)
  535. discuz_waterfall: {
  536. pager: {
  537. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  538. pageE: '#waterfall > li',
  539. replaceE: '.pg, .pages',
  540. forceHTTPS: true
  541. }
  542. }, // Discuz! 论坛 - 图片模式的帖子列表(不带无缝加载下一页按钮的)
  543. discuz_thread: {
  544. thread: true,
  545. style: '.pgbtn {display: none;}',
  546. pager: {
  547. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  548. pageE: '#postlist > div[id^="post_"]',
  549. 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"))]]',
  550. forceHTTPS: true
  551. },
  552. function: {
  553. bF: src_bF,
  554. bFp: [0, 'img[file]', 'file']
  555. }
  556. }, // Discuz! 论坛 - 帖子内
  557. discuz_search: {
  558. pager: {
  559. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  560. pageE: '#threadlist > ul',
  561. replaceE: '.pg, .pages',
  562. forceHTTPS: true
  563. }
  564. }, // Discuz! 论坛 - 搜索页
  565. discuz_youspace: {
  566. pager: {
  567. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  568. pageE: 'form:not([action^="search.php?"]) tbody > tr:not(.th)',
  569. replaceE: '.pg, .pages',
  570. forceHTTPS: true
  571. }
  572. }, // Discuz! 论坛 - 回复页、主题页(别人的)
  573. discuz_collection: {
  574. pager: {
  575. nextL: 'a.nxt:not([href^="javascript"]) ,a.next:not([href^="javascript"])',
  576. pageE: '#ct .bm_c table > tbody',
  577. replaceE: '.pg, .pages',
  578. forceHTTPS: true
  579. }
  580. }, // Discuz! 论坛 - 淘帖页
  581. discuz_m: {
  582. thread: true,
  583. pager: {
  584. nextL: '//a[@class="nxt" or @class="next"] | //div[@class="page"]/a[text()="下一页" or contains(text(), ">")]',
  585. replaceE: '.pg, .page',
  586. forceHTTPS: true,
  587. scrollD: 1000
  588. }
  589. }, // Discuz! 论坛 - 触屏手机版 - 帖子内
  590. discuz_m_forum: {
  591. pager: {
  592. type: 2,
  593. nextL: 'a.loadmore',
  594. interval: 500,
  595. scrollD: 1000
  596. }
  597. }, // Discuz! 论坛 - 触屏手机版 - 帖子列表(自带无缝加载下一页按钮的)
  598. flarum: {
  599. url: ()=> {urlC = true;if (!indexOF('/d/')) {curSite = DBSite.flarum;}},
  600. pager: {
  601. type: 2,
  602. nextL: '.DiscussionList-loadMore > button',
  603. isHidden: true
  604. }
  605. }, // Flarum 论坛
  606. phpbb: {
  607. url: ()=> {if (indexOF('/viewforum.php')) {
  608. curSite = DBSite.phpbb;
  609. } else if (indexOF('/viewtopic.php')) {
  610. curSite = DBSite.phpbb_post;
  611. } else if (indexOF('/search.php')) {
  612. curSite = DBSite.phpbb_search;
  613. }},
  614. pager: {
  615. nextL: '.pagination li.next a[rel="next"], .topic-actions .pagination strong~a',
  616. pageE: '.forumbg:not(.announcement) ul.topiclist.topics > li',
  617. replaceE: '.action-bar .pagination, .topic-actions .pagination',
  618. scrollD: 2000
  619. }
  620. }, // phpBB 论坛 - 帖子列表
  621. phpbb_post: {
  622. thread: true,
  623. pager: {
  624. nextL: '.pagination li.next a[rel="next"], .topic-actions .pagination strong~a',
  625. pageE: 'div.post[id], div.post[id]+hr',
  626. replaceE: '.action-bar .pagination, .topic-actions .pagination',
  627. scrollD: 2000
  628. }
  629. }, // phpBB 论坛 - 帖子内
  630. phpbb_search: {
  631. pager: {
  632. nextL: '.pagination li.next a[rel="next"], .topic-actions .pagination strong~a',
  633. pageE: 'div.search.post',
  634. replaceE: '.action-bar .pagination, .pagination',
  635. scrollD: 2000
  636. }
  637. }, // phpBB 论坛 - 搜索页
  638. xenforo: {
  639. url: ()=> {if (indexOF(/\/(forums|f)\//)) {
  640. curSite = DBSite.xenforo;
  641. } else if (indexOF(/\/(threads|t)\//)) {
  642. curSite = DBSite.xenforo_post;
  643. } else if (indexOF('/search/')) {
  644. curSite = DBSite.xenforo_search;
  645. }},
  646. pager: {
  647. nextL: 'a.pageNav-jump--next',
  648. pageE: '.structItemContainer-group.js-threadList > div',
  649. replaceE: 'nav.pageNavWrapper',
  650. scrollD: 2500
  651. }
  652. }, // XenForo 论坛 - 帖子列表
  653. xenforo_post: {
  654. thread: true,
  655. pager: {
  656. nextL: 'a.pageNav-jump--next',
  657. pageE: '.block-body.js-replyNewMessageContainer > article',
  658. replaceE: 'nav.pageNavWrapper',
  659. scrollD: 2500
  660. }
  661. }, // XenForo 论坛 - 帖子内
  662. xenforo_search: {
  663. pager: {
  664. nextL: 'a.pageNav-jump--next',
  665. pageE: 'ol.block-body > li',
  666. replaceE: 'nav.pageNavWrapper',
  667. scrollD: 2500
  668. }
  669. }, // XenForo 论坛 - 搜索页
  670. xiuno: {
  671. url: ()=> {if (lp == '/' || indexOF(/\/(index|forum)/)) {curSite = DBSite.xiuno;} else if (indexOF('/thread')) {curSite = DBSite.xiuno_post;}},
  672. pager: {
  673. nextL: '//li[@class="page-item"]/a[text()="▶" or text()="»" or contains(text(),">") or contains(text(),"下一页")]',
  674. pageE: 'ul.threadlist > li',
  675. replaceE: 'ul.pagination'
  676. }
  677. }, // Xiuno 论坛 - 帖子列表
  678. xiuno_post: {
  679. thread: true,
  680. pager: {
  681. nextL: '//li[@class="page-item"]/a[text()="▶" or text()="»" or contains(text(),">") or contains(text(),"下一页")]',
  682. pageE: 'li.post[data-pid]:not(.newpost)',
  683. replaceE: 'ul.pagination'
  684. }
  685. }, // Xiuno 论坛 - 帖子内
  686. nexusphp: {
  687. url: ()=> {
  688. if (lp == '/torrents.php' || getCSS('table.torrents')) {
  689. curSite = DBSite.nexusphp;
  690. } else if (lp == '/subtitles.php') {
  691. curSite = DBSite.nexusphp;
  692. curSite.pager.pageE = '#outer > table.main~table > tbody > tr:not(:first-of-type)'
  693. } else if (lp == '/forums.php' && indexOF('action=viewforum', 's')) {
  694. curSite = DBSite.nexusphp;
  695. curSite.pager.pageE = '#outer > table.main+table > tbody > tr:not(:first-of-type):not(:last-of-type)'
  696. } else if (lp == '/forums.php' && indexOF('action=viewtopic', 's')) {
  697. curSite = DBSite.nexusphp;
  698. curSite.thread = true;
  699. curSite.pager.pageE = 'td.text > div, td.text > div+table.main';
  700. }},
  701. pager: {
  702. nextL: '//a[./b[contains(text(), "下一页") or contains(text(), ">>")]]',
  703. pageE: 'table.torrents > tbody > tr:not(:first-of-type)',
  704. replaceE: '//p[@align][./font[@class="gray"]]'
  705. }
  706. }, // NexusPHP 论坛
  707. baidu_tieba: {
  708. host: ['tieba.baidu.com', 'jump2.bdimg.com'],
  709. url: ()=> {if (location.hostname == 'jump2.bdimg.com') location.hostname = 'tieba.baidu.com';
  710. if (lp == '/f') {
  711. baidu_tieba_1(); // 右侧悬浮发帖按钮点击事件(解决自动翻页导致无法发帖的问题)
  712. curSite = DBSite.baidu_tieba;
  713. } else if (indexOF('/p/')) {
  714. curSite = DBSite.baidu_tieba_post;
  715. } else if (lp == '/f/search/res') {
  716. curSite = DBSite.baidu_tieba_search;
  717. }},
  718. style: 'img.j_retract {margin-top: 0 !important;margin-bottom: 0 !important;}', // 修复帖子列表中预览图片,在切换下一个/上一个图片时,多出来的图片上下边距
  719. history: false,
  720. iframe: true,
  721. pager: {
  722. type: 4,
  723. nextL: ()=> {if (getNextE('a.next.pagination-item')) getPageE_(curSite.pageUrl + '&pagelets=frs-list%2Fpagelet%2Fthread&pagelets_stamp=' + new Date().getTime());},
  724. pageE: '#thread_list > li',
  725. insertP: ['#thread_list', 3],
  726. insertE: baidu_tieba_insertE,
  727. replaceE: '#frs_list_pager',
  728. interval: 2000,
  729. scrollD: 2500
  730. },
  731. function: {
  732. bF: src_bF,
  733. bFp: [0, 'img[data-original]', 'data-original']
  734. }
  735. }, // 百度贴吧 - 帖子列表
  736. baidu_tieba_post: {
  737. blank: true,
  738. thread: true,
  739. style: '.d_sign_split, img.j_user_sign, .d_author .d_pb_icons, .save_face_bg, .save_face_bg_2, li.d_name a.icon_tbworld, .lzl_cnt a.icon_tbworld, .topic_list_box.topic-fixed {display: none !important;} a.p_author_face.j_frame_guide {background: none repeat scroll 0 0 #FFF !important;border: 1px solid #CCC !important;padding: inherit !important;} .red_text, .red-text, .vip_red, .vip-red, .vip_red:hover, .vip-red:hover, .vip_red:visited, .vip-red:visited {color: #2d64b3 !important;}', // 签名、印记、头像边框、VIP 元素
  740. pager: {
  741. type: 5,
  742. nextL: '//li[contains(@class,"pb_list_pager")]/a[text()="下一页"]',
  743. style: 'ul.tbui_aside_float_bar, .core_title_wrap_bright.tbui_follow_fixed.core_title_absolute_bright {display: none !important;}'
  744. }
  745. }, // 百度贴吧 - 帖子内
  746. baidu_tieba_search: {
  747. pager: {
  748. nextL: 'a.next',
  749. pageE: '.s_post_list > div',
  750. replaceE: '.pager',
  751. scrollD: 1000
  752. }
  753. }, // 百度贴吧 - 搜索页
  754. nexusmods: {
  755. host: 'www.nexusmods.com',
  756. url: ()=> {urlC = true; if (!(lp == '/' || indexOF(/\/mods\/\d+/))) {curSite = DBSite.nexusmods;}},
  757. blank: 1,
  758. history: false,
  759. pager: {
  760. nextL: nexusmods_nextL,
  761. pageE: 'ul.tiles > li',
  762. replaceE: '.pagination',
  763. scrollD: 4000
  764. },
  765. function: {
  766. bF: nexusmods_bF
  767. }
  768. }, // NexusMods
  769. bilibili_search: {
  770. host: 'search.bilibili.com',
  771. url: ()=> {
  772. urlC = true;
  773. if ((lp == '/all' || lp == '/video') && getCSS('ul.video-list') != null) {
  774. curSite = DBSite.bilibili_search;
  775. } else if (lp == '/article' && getCSS('#article-list') != null) {
  776. curSite = DBSite.bilibili_search_article;
  777. }
  778. },
  779. retry: 100,
  780. pager: {
  781. nextL: bilibili_search_nextL,
  782. pageE: '//ul[contains(@class, "video-list")]/li | //script[contains(text(), "window.__INITIAL_STATE__")]',
  783. insertP: ['ul.video-list', 3],
  784. replaceE: 'ul.pages',
  785. scriptT: 2,
  786. scrollD: 1000
  787. },
  788. function: {
  789. bF: bilibili_search_bF,
  790. aF: bilibili_search_aF
  791. }
  792. }, // B 站(Bilibili) - 搜索页 - 视频
  793. bilibili_search_article: {
  794. retry: 100,
  795. pager: {
  796. nextL: bilibili_search_nextL,
  797. pageE: 'li.article-item',
  798. replaceE: 'ul.pages',
  799. //scriptT: 2,
  800. scrollD: 1000
  801. }
  802. }, // B 站(Bilibili) - 搜索页 - 专栏
  803. anime1: {
  804. host: 'anime1.me',
  805. url: ()=> {if (indexOF('s=', 's')) {curSite = DBSite.wp_article;} else if (lp == '/') {curSite = DBSite.anime1;}},
  806. history: false,
  807. pager: {
  808. type: 4,
  809. nextL: ()=> { // 获取下一页内容(叠加)
  810. let next = getCSS('a.paginate_button.next');
  811. if (next && next.className.indexOf('disabled') === -1) {
  812. let oldList = getCSS('#table-list > tbody').innerHTML;
  813. if (oldList) {next.click(); pageNum.now = pageNum._now + 1; getCSS('#table-list > tbody').insertAdjacentHTML('afterbegin', oldList);}
  814. }
  815. },
  816. interval: 500,
  817. scrollD: 800
  818. }
  819. }, // Anime1
  820. manben: {
  821. host: 'www.manben.com',
  822. url: ()=> {if (indexOF(/\/m\d+/)) {
  823. if (getCookie('showtype') != '2') {
  824. document.cookie='showtype=2; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/'; // 写入 Cookie 开启 [垂直阅读] 模式
  825. location.reload(); // 刷新网页
  826. }
  827. curSite = DBSite.mhxqiu;
  828. }}
  829. }, // 漫本
  830. cartoonmad: {
  831. host: ['www.cartoonmad.com','www.cartoonmad.cc'],
  832. url: ()=> {if (indexOF('/comic/')) {
  833. getCSS('body > table > tbody > tr:nth-child(4) > td > table > tbody > tr:first-child > td:first-child > a').href = 'javascript:void(0);'; // 清理图片上的链接
  834. curSite = DBSite.cartoonmad;
  835. } else if (lp != '/') {
  836. curSite = DBSite.cartoonmad_list;
  837. }},
  838. style: 'body > table > tbody > tr:nth-child(4) > td > table > tbody > tr:first-child > td:not(:first-child) {display: none !important;} body > table > tbody > tr:nth-child(4) > td > table > tbody > tr:first-child > td:first-child img {max-width: 100%;height: auto;display: block !important;margin: 0 auto !important;}',
  839. pager: {
  840. nextL: cartoonmad_nextL,
  841. pageE: 'body > table > tbody > tr:nth-child(4) > td > table > tbody > tr:first-child > td:first-child img',
  842. replaceE: 'body > table > tbody > tr:nth-child(2), body > table > tbody > tr:nth-child(5)',
  843. interval: 0,
  844. scrollD: 2000
  845. }
  846. }, // 动漫狂
  847. cartoonmad_list: {
  848. blank: 1,
  849. pager: {
  850. nextL: '//a[@class="pages"][contains(text(), "下一頁")]',
  851. pageE: 'td[background="/image/content_box4.gif"]+td > table > tbody > tr',
  852. replaceE: '//a[@class="pages"]/parent::td/parent::tr | //font[contains(text(), "目前在第")]',
  853. scrollD: 1000
  854. }
  855. }, // 动漫狂 - 分类/搜索页
  856. manhuacat: {
  857. host: ['www.manhuacat.com', 'www.maofly.com'],
  858. url: ()=> {if (indexOF(/\/manga\/\d+\/.+\.html/)) {
  859. if (getCookie('is_pull') == 'true') { // 强制关闭 [下拉] 模式
  860. document.cookie='is_pull=false; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/'; // 写入 Cookie 关闭 [下拉] 模式
  861. location.reload(); // 刷新网页
  862. }
  863. setTimeout(manhuacat_init, 100);
  864. curSite = DBSite.manhuacat;
  865. } else if (indexOF('/list')) {
  866. curSite = DBSite.manhuacat_list;
  867. } else if (indexOF('/search') || indexOF('/update')) {
  868. curSite = DBSite.manhuacat_search;
  869. }},
  870. 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;}', // 隐藏不需要的元素,调整图片
  871. pager: {
  872. type: 4,
  873. nextL: manhuacat_nextL,
  874. insertP: ['.img-content', 3],
  875. insertE: manhuacat_insertE,
  876. replaceE: '.comic-detail > .breadcrumb-bar, .comic-detail >h2.h4, .vg-r-data, body > script:not([src])',
  877. interval: 2000,
  878. scrollD: 3000
  879. }
  880. }, // 漫画猫
  881. manhuacat_list: {
  882. blank: 1,
  883. pager: {
  884. nextL: '//div[contains(@class, "pagination")]//a[contains(text(), "下一页") or contains(text(), "下页")]',
  885. pageE: '.comic-main-section > *',
  886. replaceE: '.pagination',
  887. scrollD: 1000
  888. },
  889. function: {
  890. bF: src_bF,
  891. bFp: [0, 'img[data-original]', 'data-original']
  892. }
  893. }, // 漫画猫 - 分类页
  894. manhuacat_search: {
  895. pager: {
  896. nextL: '//div[contains(@class, "pagination")]//a[contains(text(), "下一页") or contains(text(), "下页")]',
  897. pageE: '.comic-main-section .row > div',
  898. replaceE: '.pagination',
  899. scrollD: 1000
  900. }
  901. }, // 漫画猫 - 搜索页
  902. imanhuaw: {
  903. host: ['www.imanhuaw.net', 'www.imanhuaw.com', 'www.ccshwy.com'],
  904. url: ()=> {
  905. if (getCSS('.mh-search-result')) {
  906. curSite = DBSite.imanhuaw_list;
  907. } else if (getCSS('a#zhankai')) {
  908. getCSS('a#zhankai').click();
  909. } else if (indexOF(/\/\d{3,}\.html/)) {
  910. curSite = DBSite.imanhuaw; imanhuaw_init();
  911. }
  912. },
  913. 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;}',
  914. pager: {
  915. type: 4,
  916. nextL: imanhuaw_nextL,
  917. insertP: ['#qTcms_Pic_middle img:last-of-type', 4],
  918. insertE: imanhuaw_insertE,
  919. replaceE: '.title h2',
  920. interval: 2000,
  921. scrollD: 3000
  922. }
  923. }, // 爱漫画 + 188漫画网
  924. imanhuaw_list: {
  925. blank: 1,
  926. pager: {
  927. nextL: '//div[@class="NewPages"]//a[text()="下一页"]',
  928. pageE: 'ul.mh-search-list > li',
  929. replaceE: '.NewPages'
  930. }
  931. }, // 爱漫画 - 分类页
  932. manhuagui: {
  933. host: ['www.mhgui.com', 'tw.mhgui.com', 'www.manhuagui.com', 'tw.manhuagui.com'],
  934. url: ()=> {if (indexOF(/\/comic\/\d+\/\d+\.html/)) {
  935. if (!getXpath('//li[@class="pfunc"]/a[@class="current"][text()="双击" or text()="雙擊"]')) getXpath('//li[@class="pfunc"]/a[text()="双击" or text()="雙擊"]').click();
  936. pausePage = false;
  937. setTimeout(manhuagui_init, 100);
  938. curSite = DBSite.manhuagui;
  939. } else if (indexOF('list/') || indexOF('/s/')) {
  940. curSite = DBSite.manhuagui_list;
  941. }},
  942. style: '.sub-btn, .tc {display: none !important;} #mangaBox > img {width: auto !important;height: auto !important;display: block !important;margin: 0 auto !important;max-width: 100% !important;}',
  943. pager: {
  944. type: 4,
  945. nextL: manhuagui_nextL,
  946. pageE: 'body > script:not([src])',
  947. insertP: ['#mangaBox', 3],
  948. insertE: manhuagui_insertE,
  949. replaceE: 'title',
  950. interval: 4000,
  951. scrollD: 2500
  952. }
  953. }, // 漫画柜
  954. manhuagui_list: {
  955. blank: 1,
  956. pager: {
  957. nextL: '//div[@class="pager"]/a[text()="下一页" or text()="下一頁"]',
  958. pageE: '.book-result > ul > li, .book-list > ul > li',
  959. insertP: ['.book-result > ul, .book-list > ul', 3],
  960. replaceE: '.pager'
  961. },
  962. function: {
  963. bF: src_bF,
  964. bFp: [0, 'img[data-src]', 'data-src']
  965. }
  966. }, // 漫画台 - 分类/搜索页
  967. _36manga: {
  968. host: ['36manga.com', 'www.36manga.com', '36manhua.com', 'www.36manhua.com'],
  969. url: ()=> {if (indexOF(/\/manhua\/.+\/\d+\.html/)) {
  970. if (localStorage.getItem('chapterScroll') != '"pagination"') {
  971. localStorage.setItem('chapterScroll', '"pagination"'); location.reload()
  972. } else {
  973. pausePage = false;
  974. setTimeout(_36manga_init, 100);
  975. curSite = DBSite._36manga;
  976. }
  977. } else if (indexOF('list/') || indexOF('/search/')) {
  978. curSite = DBSite._36manga_list;
  979. }},
  980. style: '#sider-left, #sider-right, p.img_info, .tc, .chapter-view + .w996 {display: none !important;} #images > img {width: auto !important;height: auto !important;display: block !important;margin: 0 auto !important;max-width: 100% !important;}',
  981. pager: {
  982. type: 4,
  983. nextL: _36manga_nextL,
  984. pageE: '//body/script[contains(text(), "chapterImages")]',
  985. insertP: ['#images', 3],
  986. insertE: _36manga_insertE,
  987. replaceE: '.title',
  988. interval: 4000,
  989. scrollD: 2500
  990. }
  991. }, // 36漫画
  992. _36manga_list: {
  993. blank: 1,
  994. pager: {
  995. nextL: 'ul.pagination li.next a',
  996. pageE: '#contList',
  997. replaceE: 'ul.pagination'
  998. }
  999. }, // 36漫画 - 分类/搜索页
  1000. manhuadb: {
  1001. host: 'www.manhuadb.com',
  1002. url: ()=> {if (indexOF(/\/manhua\/\d+\/.+\.html/)) {
  1003. if (getCSS('img.img-fluid.show-pic')) getCSS('img.img-fluid.show-pic').style.display = 'none'; // 隐藏第一个图片(避免重复)
  1004. setTimeout(manhuadb_init, 100);
  1005. curSite = DBSite.manhuadb;
  1006. } else if (indexOF('/list')) {
  1007. curSite = DBSite.manhuacat_list;
  1008. } else if (indexOF('/search') || indexOF('/update')) {
  1009. curSite = DBSite.manhuacat_search;
  1010. }},
  1011. style: '.row.m-0.pt-3.ad_2_wrap, .row.m-0.ad_1_wrap, .pagination.justify-content-center, #left, #right {display: none !important;}',
  1012. pager: {
  1013. type: 4,
  1014. nextL: manhuadb_nextL,
  1015. pageE: 'body > script:not([type]):not([src]), .vg-r-data, ol.links-of-books.num_div',
  1016. insertP: ['.pjax-container', 3],
  1017. insertE: manhuadb_insertE,
  1018. interval: 5000,
  1019. scrollD: 3000
  1020. }
  1021. }, // 漫画 DB
  1022. hicomic: {
  1023. host: 'www.hicomic.net',
  1024. url: ()=> {if (indexOF('/chapters/')) {
  1025. setTimeout(hicomic_init, 100);
  1026. curSite = DBSite.hicomic;
  1027. }},
  1028. style: '.content {height: auto !important;} .footer, .left_cursor, .right_cursor, .finish {display: none !important;} .content > img {display: block !important;margin: 0 auto !important;}',
  1029. pager: {
  1030. type: 4,
  1031. nextL: hicomic_nextL,
  1032. insertP: ['.content', 3],
  1033. insertE: hicomic_insertE,
  1034. interval: 5000,
  1035. scrollD: 3000
  1036. }
  1037. }, // HiComic (嗨漫画)
  1038. dmzj: {
  1039. host: 'www.dmzj.com',
  1040. url: ()=> {if (indexOF('/view/')) {
  1041. if (getCookie('display_mode') != '1') { // 强制开启 [上下滚动阅读] 模式
  1042. document.cookie='display_mode=1; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/'; // 写入 Cookie 开启 [上下滚动阅读] 模式
  1043. location.reload(); // 刷新网页
  1044. }
  1045. setTimeout(function() {dmzj_init('.comic_wraCon > a > img')}, 100);
  1046. curSite = DBSite.dmzj;
  1047. } else if (indexOF('/category') || indexOF('/update')) {
  1048. curSite = DBSite.dmzj_list;
  1049. } else if (indexOF('/rank')) {
  1050. curSite = DBSite.dmzj_rank;
  1051. }},
  1052. style: 'p.mh_curr_page, .btmBtnBox, .float_code, #floatCode {display: none !important;} .comic_wraCon > img {display: block !important;margin: 0 auto !important; border: none !important; padding: 0 !important; max-width: 99% !important; height: auto !important;}', // 隐藏中间的页数信息
  1053. pager: {
  1054. type: 4,
  1055. nextL: 'span.next > a',
  1056. insertP: ['.comic_wraCon', 3],
  1057. insertE: dmzj_insertE,
  1058. replaceE: '.wrap_last_mid, .wrap_last_head',
  1059. interval: 2000,
  1060. scrollD: 3000
  1061. }
  1062. }, // 动漫之家 - 原创
  1063. dmzj_list: {
  1064. style: '.wrap_mhlist_l.con_left, .wrap_list {height: auto!important;}',
  1065. blank: 1,
  1066. pager: {
  1067. nextL: 'a.pg_next',
  1068. pageE: 'ul.list_con_li > li',
  1069. replaceE: '.page',
  1070. scrollD: 1000
  1071. }
  1072. }, // 动漫之家 - 原创 - 分类页
  1073. dmzj_rank: {
  1074. style: '.wrap_mhlist_l.con_left {height: auto!important;}',
  1075. pager: {
  1076. nextL: 'a.pg_next',
  1077. pageE: '.ph_r_con_li > div:not(.ad_column)',
  1078. replaceE: '.page',
  1079. scrollD: 1000
  1080. }
  1081. }, // 动漫之家 - 原创 - 排行榜
  1082. dmzj_manhua: {
  1083. host: 'manhua.dmzj.com',
  1084. url: ()=> {if (indexOF(/\/\d+\.shtml/)) {
  1085. let chapterScroll = getCSS('#qiehuan_txt') // 强制为 [上下滚动阅读] 模式
  1086. if (chapterScroll && chapterScroll.textContent === '切换到上下滚动阅读') {chapterScroll.click();}
  1087. setTimeout(function() {dmzj_init('#center_box > .inner_img img[src]')}, 100);
  1088. curSite = DBSite.dmzj_manhua;
  1089. /*} else if (indexOF('/tags/')) {
  1090. curSite = DBSite.dmzj_manhua_list;*/
  1091. } else if (indexOF('/update')) {
  1092. curSite = DBSite.dmzj_manhua_update;
  1093. }},
  1094. style: 'p.curr_page, .btmBtnBox, .float_code, #floatCode {display: none !important;} #center_box > img {display: block !important;margin: 0 auto !important; border: none !important; padding: 0 !important; max-width: 99% !important; height: auto !important;}', // 隐藏中间的页数信息
  1095. pager: {
  1096. type: 4,
  1097. nextL: '#next_chapter',
  1098. insertP: ['#center_box', 3],
  1099. insertE: dmzj_manhua_insertE,
  1100. replaceE: '.display_graybg',
  1101. interval: 2000,
  1102. scrollD: 3000
  1103. }
  1104. }, // 动漫之家 - 日漫
  1105. /*dmzj_manhua_list: {
  1106. pager: {
  1107. nextL: ()=> getNextUPN(/(?<=-)\d+(?=\.shtml)/, /-\d+\.shtml/, '-', '.shtml', '2', getCSS('#topage > option:last-child').value),
  1108. pageE: '#search_list_div ul'
  1109. }
  1110. },*/ // 动漫之家 - 日漫 - 分类页
  1111. dmzj_manhua_update: {
  1112. blank: 1,
  1113. pager: {
  1114. nextL: '//div[@class="pages"]/a[contains(text(), "下一页")]',
  1115. pageE: '.newpic_content > *:not(.pages)',
  1116. replaceE: '.pages',
  1117. scrollD: 1000
  1118. }
  1119. }, //动漫之家 - 日漫 - 最新更新
  1120. acgn: {
  1121. host: 'comic.acgn.cc',
  1122. url: ()=> {
  1123. if (indexOF('/view-')) {
  1124. curSite = DBSite.acgn;
  1125. acgn_aF();
  1126. } else if (indexOF('/cate-') || indexOF('/pinyin-')) {
  1127. curSite = DBSite.acgn_list;
  1128. }
  1129. },
  1130. style: '.img1 {cursor: initial !important;}',
  1131. pager: {
  1132. nextL: '#next_chapter',
  1133. pageE: '.pic[_src]',
  1134. replaceE: '[class^="display_"]',
  1135. interval: 2000,
  1136. scrollD: 2000
  1137. },
  1138. function: {
  1139. aF: acgn_aF
  1140. }
  1141. }, // 动漫戏说
  1142. acgn_list: {
  1143. blank: 1,
  1144. pager: {
  1145. nextL: 'a[rel="next"]',
  1146. pageE: 'ul#display > li',
  1147. replaceE: '#pagination',
  1148. scrollD: 1000
  1149. }
  1150. }, // 动漫戏说 - 分类页
  1151. ykmh: {
  1152. host: 'www.ykmh.com',
  1153. url: ()=> {if (indexOF(/\/\d+\.html/)) {
  1154. let chapterScroll = getCSS('#qiehuan_txt') // 强制为 [上下滚动阅读] 模式
  1155. if (localStorage.getItem('chapterScroll') != '"scroll"') {
  1156. localStorage.setItem('chapterScroll', '"scroll"'); location.reload()
  1157. } else {
  1158. setTimeout(ykmh_init, 100);
  1159. curSite = DBSite.ykmh;
  1160. }
  1161. } else if (indexOF('/list') || indexOF('/search')) {
  1162. curSite = DBSite.ykmh_list;
  1163. }},
  1164. style: 'p.img_info {display: none !important;} #images > img {display: block !important;margin: 0 auto !important; border: none !important; padding: 0 !important; max-width: 99% !important; height: auto !important;}',
  1165. pager: {
  1166. type: 4,
  1167. nextL: ykmh_nextL,
  1168. pageE: '//script[contains(text(),"chapterImages")]',
  1169. insertP: ['#images', 3],
  1170. insertE: ykmh_insertE,
  1171. replaceE: '.head_title, span.head_wz',
  1172. interval: 2000,
  1173. scrollD: 3000
  1174. }
  1175. }, // 优酷漫画
  1176. ykmh_list: {
  1177. blank: 1,
  1178. pager: {
  1179. nextL: 'li.next > a',
  1180. pageE: 'li.list-comic',
  1181. replaceE: 'ul.pagination',
  1182. scrollD: 1000
  1183. }
  1184. }, // 优酷漫画 - 分类页
  1185. mhxqiu: {
  1186. host: [/\.mhxqiu/,/www\.sixmh\d\./],
  1187. url: ()=> {if (indexOF(/\/\d+\.html/)) { // 阅读页
  1188. curSite = DBSite.mhxqiu;
  1189. } else if (indexOF(/\/\d+\/$/)) { // 目录页
  1190. setTimeout(function(){if (getCSS('#zhankai')) getCSS('#zhankai').click();}, 500)
  1191. } else if (indexOF(/\/(sort|rank)\//)) { // 分类页
  1192. curSite = DBSite.mhxqiu_list;
  1193. }},
  1194. style: '.imgFloat_1, .imgFloat_2, .main_control, span.comic-ft {display: none !important;} html, body, #mainView {height: auto !important;} body.view .main ul.comic-contain li{margin:0 auto !important;} .comic-contain .loaded{box-shadow: none !important;}',
  1195. pager: {
  1196. type: 4,
  1197. nextL: '#mainControlNext',
  1198. insertP: ['#comicContain', 3],
  1199. insertE: mhxqiu_insertE,
  1200. replaceE: '.main_control, h1.chaptername_title, span.title-comicHeading',
  1201. interval: 4000,
  1202. scrollD: 3000
  1203. }
  1204. }, // 漫画星球
  1205. mhxqiu_list: {
  1206. blank: 1,
  1207. pager: {
  1208. nextL: '//div[@class="NewPages"]//a[contains(text(), "下一页")]',
  1209. pageE: '.cy_list_mh > ul',
  1210. replaceE: '.NewPages',
  1211. scrollD: 1000
  1212. }
  1213. }, // 漫画星球 - 分类页
  1214. fffdm: {
  1215. host: 'manhua.fffdm.com',
  1216. url: ()=> {if (location.pathname.split('/').length === 4) {curSite = DBSite.fffdm;}},
  1217. style: '#footer, #header {display: none !important;} #mhimg0 img {display: block !important;margin: 0 auto !important;}',
  1218. pager: {
  1219. type: 4,
  1220. nextL: '//a[contains(text(), "下一页") or contains(text(), "下一頁") or contains(text(), "下一话") or contains(text(), "下一話")]',
  1221. insertP: ['#mhimg0', 3],
  1222. insertE: fffdm_insertE,
  1223. replaceE: '.navigation, #weizhi, h1',
  1224. scrollD: 2000
  1225. }
  1226. }, // 风之动漫
  1227. leyuman: {
  1228. host: 'www.leyuman.com',
  1229. url: ()=> {if (indexOF(/\/comic\/\d+\/\d+\.html/)) {
  1230. curSite = DBSite.leyuman;
  1231. setTimeout(leyuman_init, 100);
  1232. } else if (indexOF(/\/comic\/\d+\.html/)) {
  1233. setTimeout(function(){if (getCSS('#read-more')) getCSS('#read-more').click();}, 500)
  1234. } else {
  1235. curSite = DBSite.leyuman_list;
  1236. }},
  1237. style: '.mh_select, .mh_comicpic > p, mh_headpager {display: none !important;} .mh_comicpic > img{width: 100% !important; height: auto !important;}',
  1238. pager: {
  1239. type: 4,
  1240. nextL: '#xurl',
  1241. insertP: ['.mh_comicpic', 3],
  1242. insertE: leyuman_insertE,
  1243. replaceE: '.mh_headpager, .mh_readtitle',
  1244. interval: 3000,
  1245. scrollD: 3000
  1246. }
  1247. }, // 乐语漫画
  1248. leyuman_list: {
  1249. blank: 1,
  1250. pager: {
  1251. nextL: '//a[@class="page-link"][contains(text(), "下一页")]',
  1252. pageE: '.works_recommend.classification_works > ul',
  1253. replaceE: '.paging',
  1254. scrollD: 1000
  1255. },
  1256. function: {
  1257. bF: src_bF,
  1258. bFp: [0, 'img[data-src]', 'data-src']
  1259. }
  1260. }, // 乐语漫画 - 分类页
  1261. _77mh: {
  1262. host: 'www.77mh.cc',
  1263. url: ()=> {if (indexOF(/\/\d+\.html/)) {
  1264. curSite = DBSite._77mh;
  1265. setTimeout(_77mh_init, 100);
  1266. } else if (indexOF('/colist_')) {
  1267. setTimeout(function(){if (getCSS('#listmore1, .listmore')) getCSS('#listmore1, .listmore').click();}, 500)
  1268. } else {
  1269. curSite = DBSite._77mh_list;
  1270. }},
  1271. style: '.page_num, #bdtopbot {display: none !important;} #comicImg > img {display: block !important;margin: 0 auto !important; border: none !important; padding: 0 !important; max-width: 99% !important; height: auto !important;}',
  1272. pager: {
  1273. type: 4,
  1274. nextL: _77mh_nextL,
  1275. insertP: ['#comicImg', 3],
  1276. insertE: _77mh_insertE,
  1277. interval: 3000,
  1278. scrollD: 2000
  1279. }
  1280. }, // 新新漫画
  1281. _77mh_list: {
  1282. blank: 1,
  1283. pager: {
  1284. nextL: '//div[@class="pages_s"]/a[text()="下一页"]',
  1285. pageE: '.ar_list_co > ul > li',
  1286. replaceE: '.pages_s',
  1287. scrollD: 1000
  1288. }
  1289. }, // 新新漫画 - 分类页
  1290. _77mh_search: {
  1291. host: 'so.77mh.cc',
  1292. blank: 1,
  1293. pager: {
  1294. nextL: 'a.next',
  1295. pageE: '.ar_list_co > ul > dl',
  1296. replaceE: '.pages_s',
  1297. scrollD: 1000
  1298. }
  1299. }, // 新新漫画 - 搜索页
  1300. gufengmh: {
  1301. host: /^www\.gufengmh\d/,
  1302. url: ()=> {if (indexOF(/\/\d+.+\.html/)) {
  1303. let chapterScroll = getCSS('#chapter-scroll') // 强制为 [下拉阅读] 模式
  1304. if (chapterScroll && chapterScroll.className === '') {chapterScroll.click();}
  1305. curSite = DBSite.gufengmh;
  1306. } else if (indexOF(/\/(update|list|search)/)) {
  1307. curSite = DBSite.gufengmh_list;
  1308. }},
  1309. style: 'p.img_info {display: none !important;}', // 隐藏中间的页数信息
  1310. pager: {
  1311. type: 4,
  1312. nextL: ykmh_nextL,
  1313. pageE: '//script[contains(text(),"chapterImages")]',
  1314. insertP: ['#images', 3],
  1315. insertE: gufengmh_insertE,
  1316. interval: 5000,
  1317. scrollD: 4000
  1318. }
  1319. }, // 古风漫画网
  1320. gufengmh_list: {
  1321. blank: 1,
  1322. pager: {
  1323. nextL: 'li.next > a',
  1324. pageE: 'ul.book-list > li',
  1325. replaceE: 'ul.pagination',
  1326. scrollD: 1000
  1327. }
  1328. }, // 古风漫画网 - 分类页
  1329. szcdmj: {
  1330. host: 'www.szcdmj.com',
  1331. url: ()=> {
  1332. if (indexOF('/szcchapter/')) {
  1333. curSite = DBSite.szcdmj;
  1334. } else if (indexOF('/szcbook/')) {
  1335. if (getCSS('#detail-list-more')) getCSS('#detail-list-more').click();
  1336. } else if (lp == '/szcbolist' || lp == '/update') {
  1337. curSite = DBSite.szcdmj_list;
  1338. }},
  1339. style: '.header {opacity: 0.3 !important;}',
  1340. pager: {
  1341. nextL: '//div[@class="fanye"][1]/a[@href][text()="下一页" or text()="下一话"]',
  1342. pageE: '.comicpage > div',
  1343. insertP: ['.comicpage', 3],
  1344. replaceE: '.fanye,h1.title',
  1345. interval: 0,
  1346. scrollD: 2000
  1347. },
  1348. function: {
  1349. bF: src_bF,
  1350. bFp: [0, 'img[data-original]', 'data-original']
  1351. }
  1352. }, // 砂之船动漫家
  1353. szcdmj_list: {
  1354. blank: 1,
  1355. pager: {
  1356. nextL: '#nextPage',
  1357. pageE: 'ul.mh-list > li',
  1358. replaceE: '.pagination',
  1359. scrollD: 1000
  1360. }
  1361. }, // 砂之船动漫家 - 分类/搜索页
  1362. mangabz: {
  1363. host: ['mangabz.com', 'www.mangabz.com'],
  1364. url: ()=> {if (indexOF(/\/m\d+/)) {
  1365. setTimeout(mangabz_init, 1500);
  1366. curSite = DBSite.mangabz;
  1367. } else if (indexOF(/\/\d+bz\//)) {
  1368. if (getCSS('.detail-list-form-more')) getCSS('.detail-list-form-more').click();
  1369. } else if (indexOF('/manga-list') || lp == '/search') {
  1370. curSite = DBSite.mangabz_list;
  1371. }},
  1372. 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;}',
  1373. pager: {
  1374. type: 4,
  1375. nextL: mangabz_nextL,
  1376. insertP: ['#cp_img', 3],
  1377. insertE: mangabz_insertE,
  1378. replaceE: 'p.top-title, body > .container > div:not([id])',
  1379. interval: 500,
  1380. scrollD: 2000
  1381. }
  1382. }, // Mangabz 漫画
  1383. mangabz_list: {
  1384. blank: 1,
  1385. pager: {
  1386. nextL: '//div[contains(@class,"page-pagination")]//a[contains(text(), ">")]',
  1387. pageE: 'ul.mh-list > li',
  1388. replaceE: '.page-pagination',
  1389. scrollD: 800
  1390. }
  1391. }, // Mangabz 漫画 - 分类/搜索页
  1392. dm5: {
  1393. host: 'www.dm5.com',
  1394. url: ()=> {if (indexOF(/\/m\d+/)) {
  1395. setTimeout(mangabz_init, 1500);
  1396. curSite = DBSite.dm5;
  1397. } else if (indexOF('/manga-list') || lp == '/search' || getCSS('.box-body > ul.mh-list > li')) {
  1398. curSite = DBSite.mangabz_list;
  1399. } else if (getCSS('.detail-more')) {
  1400. getCSS('.detail-more').click();
  1401. }},
  1402. 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;}',
  1403. pager: {
  1404. type: 4,
  1405. nextL: dm5_nextL,
  1406. insertP: ['#cp_img', 3],
  1407. insertE: dm5_insertE,
  1408. replaceE: '.view-paging > .container, .rightToolBar',
  1409. interval: 500,
  1410. scrollD: 2000
  1411. }
  1412. }, // 动漫屋
  1413. xmanhua: {
  1414. host: ['xmanhua.com', 'www.xmanhua.com'],
  1415. url: ()=> {if (indexOF(/\/m\d+/)) {
  1416. setTimeout(mangabz_init, 1500);
  1417. curSite = DBSite.xmanhua;
  1418. } else if (indexOF(/\/\d+xm\//)) {
  1419. if (getCSS('.detail-list-form-more')) getCSS('.detail-list-form-more').click();
  1420. } else if (indexOF('/manga-list') || lp == '/search') {
  1421. curSite = DBSite.xmanhua_list;
  1422. }},
  1423. 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;}',
  1424. hiddenPN: true,
  1425. pager: {
  1426. type: 4,
  1427. nextL: xmanhua_nextL,
  1428. insertP: ['#cp_img', 3],
  1429. insertE: xmanhua_insertE,
  1430. replaceE: '.reader-title, body > .container > div:not([id])',
  1431. interval: 500,
  1432. scrollD: 2500
  1433. }
  1434. }, // Xmanhua 漫画
  1435. xmanhua_list: {
  1436. blank: 1,
  1437. pager: {
  1438. nextL: '//div[@class="page-pagination"]//a[contains(text(), ">")]',
  1439. pageE: 'ul.mh-list > li',
  1440. replaceE: '.page-pagination',
  1441. scrollD: 1000
  1442. }
  1443. }, // Xmanhua 漫画 - 分类/搜索页
  1444. cocomanga: {
  1445. host: 'www.cocomanga.com',
  1446. url: ()=> {if (indexOF('.html')) {
  1447. if (!(getCookie('mh_readmode') === '' || getCookie('mh_readmode') === '3')) {
  1448. document.cookie='mh_readmode=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; // 强制开启自带的无缝翻页功能
  1449. location.reload(); // 刷新网页
  1450. }
  1451. setTimeout(cocomanga_init, 500);
  1452. curSite = DBSite.cocomanga;
  1453. } else if (indexOF(/\/\d+\/$/)) {
  1454. setTimeout(function(){if (getCSS('a.website-display-all')) getCSS('a.website-display-all').click();}, 300)
  1455. } else if (lp == '/show') {
  1456. curSite = DBSite.cocomanga_list;
  1457. } else if (lp == '/search') {
  1458. curSite = DBSite.cocomanga_search;
  1459. }},
  1460. style: '.mh_readend, .mh_footpager, .mh_readmode {display: none !important;} .mh_comicpic img {cursor: unset !important;} .mh_comicpic img {min-height: 150px;}',
  1461. pager: {
  1462. type: 4,
  1463. nextL: '//a[contains(@class, "read_page_link") and contains(string(), "下一章")][not(contains(@href, "javascript"))]',
  1464. insertP: ['#mangalist', 3],
  1465. insertE: cocomanga_insertE,
  1466. replaceE: '.mh_readtitle, .mh_headpager > a.mh_prevbook, .mh_readend',
  1467. interval: 1000,
  1468. scrollD: 2500
  1469. }
  1470. }, // COCOMANGA 漫画
  1471. cocomanga_list: {
  1472. blank: 1,
  1473. pager: {
  1474. nextL: ()=> getNextEP('.fed-page-info a.fed-btns-green+a[onclick]', 'page=', /page=\d+/),
  1475. pageE: 'ul.fed-list-info > li',
  1476. replaceE: '.fed-page-info',
  1477. scrollD: 1000
  1478. },
  1479. function: {
  1480. bF: src_bF,
  1481. bFp: [1, 'a[data-original]', 'data-original']
  1482. }
  1483. }, // COCOMANGA 漫画 - 分类页
  1484. cocomanga_search: {
  1485. blank: 1,
  1486. pager: {
  1487. nextL: ()=> getNextEP('.fed-page-info a.fed-btns-green+a[onclick]', 'page=', /page=\d+/),
  1488. pageE: 'dl.fed-deta-info',
  1489. replaceE: '.fed-page-info',
  1490. scrollD: 1000
  1491. },
  1492. function: {
  1493. bF: src_bF,
  1494. bFp: [1, 'a[data-original]', 'data-original']
  1495. }
  1496. }, // COCOMANGA 漫画 - 搜索页
  1497. coolkeyan: {
  1498. host: 'www.coolkeyan.com',
  1499. url: ()=> {if (location.hash.indexOf('/project/') > -1) curSite = DBSite.coolkeyan;},
  1500. style: '.q-img {height: auto !important;} .q-img__image {max-height: 1000px !important;} .row.q-my-sm.q-gutter-sm {display: none !important;}',
  1501. pager: {
  1502. type: 4,
  1503. nextL: coolkeyan_nextL,
  1504. insertP: ['//div[contains(@class, "q-img__image")][last()]', 4],
  1505. insertE: coolkeyan_insertE,
  1506. interval: 0
  1507. }
  1508. }, // 酷科研
  1509. nsfc: {
  1510. host: ['output.nsfc.gov.cn', 'kd.nsfc.gov.cn'],
  1511. url: ()=> {if (indexOF('/conclusionProject/')) curSite = DBSite.nsfc;},
  1512. style: '#pageNoUl {display: none !important;}',
  1513. pager: {
  1514. type: 4,
  1515. nextL: nsfc_nextL,
  1516. insertP: ['#pageNoUl', 1],
  1517. insertE: nsfc_insertE,
  1518. interval: 0
  1519. }
  1520. } // 国家自然科学基金
  1521. };
  1522. // 合并 自定义规则、外置规则、内置规则
  1523. if (Object.keys(GM_getValue('menu_customRules', {})).length === 0) {
  1524. DBSite = Object.assign(GM_getValue('menu_customRules', {}), GM_getValue('menu_rules', {}), DBSite)
  1525. } else { // 自定义规则 覆盖 同名的外置规则
  1526. let a = GM_getValue('menu_customRules', {}), a1 = Object.keys(a),
  1527. b = GM_getValue('menu_rules', {}), b1 = Object.keys(b)
  1528. for (let i = 0; i < a1.length; i++) {if(b1.indexOf(a1[i]) != -1) {delete b[a1[i]]};}
  1529. DBSite = Object.assign(a, b, DBSite)
  1530. }
  1531.  
  1532. // 生成 SiteTypeID
  1533. setSiteTypeID();
  1534. //console.log(DBSite)
  1535. // 用于脚本判断(针对部分特殊的网站)
  1536. SiteType = {
  1537. BAIDU_TIEBA: DBSite.baidu_tieba.SiteTypeID
  1538. };
  1539. }
  1540. // 外置翻页规则
  1541. function getRulesUrl(update = false) {
  1542. // 如果是原来的时间格式 或 刚安装脚本,则需要立即更新
  1543. if (typeof(GM_getValue('menu_ruleUpdateTime', '')) == 'string') update = true
  1544.  
  1545. let urlArr = [//'https://userscript.gh2233.ml/other/Autopage/rules.json',
  1546. //'https://github-do.panbaidu.cn/https://raw.githubusercontent.com/XIU2/UserScript/master/other/Autopage/rules.json',
  1547. 'https://raw.iqiq.io/XIU2/UserScript/master/other/Autopage/rules.json',
  1548. 'https://hk1.monika.love/XIU2/UserScript/master/other/Autopage/rules.json',
  1549. 'https://raw.fastgit.org/XIU2/UserScript/master/other/Autopage/rules.json',
  1550. 'https://ghproxy.fsofso.com/https://github.com/XIU2/UserScript/blob/master/other/Autopage/rules.json',
  1551. 'https://raw-gh.gcdn.mirr.one/XIU2/UserScript/master/other/Autopage/rules.json',
  1552. 'https://cdn.staticaly.com/gh/XIU2/UserScript/master/other/Autopage/rules.json',
  1553. //'https://cdn.jsdelivr.net/gh/XIU2/UserScript/other/Autopage/rules.json',
  1554. 'https://gcore.jsdelivr.net/gh/XIU2/UserScript/other/Autopage/rules.json',
  1555. 'https://fastly.jsdelivr.net/gh/XIU2/UserScript/other/Autopage/rules.json'],
  1556. urlArr2 = [//'https://userscript.gh2233.ml/other/Autopage/rules.json',
  1557. 'https://userscript.xiu2.xyz/other/Autopage/rules.json',
  1558. 'https://raw.iqiq.io/XIU2/UserScript/master/other/Autopage/rules.json',
  1559. 'https://hk1.monika.love/XIU2/UserScript/master/other/Autopage/rules.json',
  1560. 'https://raw.fastgit.org/XIU2/UserScript/master/other/Autopage/rules.json',
  1561. 'https://ghproxy.fsofso.com/https://github.com/XIU2/UserScript/blob/master/other/Autopage/rules.json']
  1562.  
  1563. if (update) { // 手动更新(或安装后首次更新)
  1564. GM_notification({text: '🔄 更新外置翻页规则中,请勿操作网页...', timeout: 3000});
  1565. getRulesUrl_(true);
  1566. } else if (parseInt(+new Date()/1000) - GM_getValue('menu_ruleUpdateTime', 0) > 172800) { // 自动更新,距离上次检查更新超过 2 天,则立即更新规则
  1567. getRulesUrl_();
  1568. }
  1569.  
  1570. function getRulesUrl_(n = false, url) {
  1571. if (n) {url = urlArr2[Math.floor(Math.random()*urlArr2.length)];} else {url = urlArr[Math.floor(Math.random()*urlArr.length)];}
  1572. GM_xmlhttpRequest({
  1573. url: url,
  1574. method: 'GET',
  1575. responseType: 'json',
  1576. overrideMimeType: 'application/json; charset=utf-8',
  1577. timeout: 5000,
  1578. onload: function (response) {
  1579. try {
  1580. //console.log('最终 URL:' + response.finalUrl, '返回内容:',response.response, response.responseHeaders)
  1581. if (response.response) {
  1582. GM_setValue('menu_rules', response.response); // 写入最新规则
  1583. GM_setValue('menu_ruleUpdateTime', parseInt(+new Date()/1000)); // 写入当前时间戳
  1584.  
  1585. curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码
  1586. registerMenuCommand(); // 重新判断规则
  1587. if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式
  1588. pageLoading(); // 自动无缝翻页
  1589.  
  1590. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码
  1591. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1592.  
  1593. 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});}});
  1594. } else {
  1595. GM_notification({text: '❌ 为空!更新失败,请联系作者解决...', timeout: 5000});
  1596. }
  1597. } catch (e) {
  1598. console.log('URL:' + url, e);
  1599. GM_notification({text: '❌ 报错!更新失败,请联系作者解决...', timeout: 5000});
  1600. }
  1601. },
  1602. onerror: function (response) {
  1603. console.log('URL:' + url, response)
  1604. GM_notification({text: '❌ 错误!更新失败,请几分钟后重试...', timeout: 5000});
  1605. },
  1606. ontimeout: function (response) {
  1607. console.log('URL:' + url, response)
  1608. GM_notification({text: '❌ 超时!更新失败,请几分钟后重试...', timeout: 5000});
  1609. }
  1610. })
  1611. }
  1612. }
  1613.  
  1614.  
  1615. // --------------------------------------------------------
  1616.  
  1617.  
  1618. // 判断网站类型
  1619. webTypeIf();
  1620.  
  1621. // 帖子内自动翻页判断
  1622. if (!GM_getValue('menu_thread')) {
  1623. if (curSite.thread) {curSite = {SiteTypeID: 0}; pageNum.now = 1;}
  1624. }
  1625.  
  1626. //console.log(curSite)
  1627. // 显示页码
  1628. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');}
  1629. // 左键双击网页空白处暂停翻页
  1630. pausePageEvent();
  1631. // 强制新标签页打开链接
  1632. if (curSite.blank != undefined) forceTarget();
  1633. // 初始化事件
  1634. //if (curSite.initE != undefined) initEvent();
  1635.  
  1636. // 对于使用 pjax 技术的网站,需要监听 URL 变化来重新判断翻页规则
  1637. if (urlC) {
  1638. nowLocation = location.href
  1639. if (window.onurlchange === undefined) {addUrlChangeEvent();} // Tampermonkey v4.11 版本添加的 onurlchange 事件 grant,可以监控 pjax 等网页的 URL 变化
  1640. if (webType === 1) {
  1641. window.addEventListener('urlchange', function(){
  1642. lp = location.pathname;
  1643. //console.log(nowLocation, location.href)
  1644. if (curSite.history !== false && window.top.document.Autopage_nowUrl === location.href) {nowLocation = location.href; return}
  1645. if (nowLocation == location.href) return
  1646. if (curSite.pager && curSite.pager.type == 5) {
  1647. if (self != top) {window.top.location.href = location.href;} else {if (getCSS('iframe#Autopage_iframe')) {getCSS('iframe#Autopage_iframe').remove();}}
  1648. pausePage = true;
  1649. } // 对于翻页模式 5,如果是 iframe 框架内 URL 变动,则升级为顶级页面,如果是顶级页面的 URL 变动,则清理 iframe 框架
  1650. nowLocation = location.href; curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码
  1651. registerMenuCommand(); // 重新判断规则
  1652. //console.log(curSite);
  1653. if (curSite.blank != undefined) forceTarget(); // 强制新标签页打开链接
  1654. //if (curSite.initE != undefined) initEvent(); // 初始化事件
  1655. if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式
  1656. // 帖子内自动翻页判断
  1657. if (!GM_getValue('menu_thread')) {
  1658. if (curSite.thread) {curSite = {SiteTypeID: 0}; pageNum.now = 1;}
  1659. }
  1660. pageLoading(); // 自动无缝翻页
  1661.  
  1662. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码
  1663. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1664. })
  1665. } else if (webType === 2) {
  1666. window.addEventListener('urlchange', function(){
  1667. lp = location.pathname;
  1668. //console.log(nowLocation, location.href)
  1669. if (nowLocation == location.href) return
  1670. setTimeout(function(){
  1671. nowLocation = location.href; curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码
  1672. discuz_(); // 重新判断规则
  1673.  
  1674. // 帖子内自动翻页判断
  1675. if (!GM_getValue('menu_thread')) {
  1676. if (curSite.thread) {curSite = {SiteTypeID: 0}; pageNum.now = 1;}
  1677. }
  1678.  
  1679. if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式
  1680. pageLoading(); // 自动无缝翻页
  1681.  
  1682. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码
  1683. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1684. }, 500)
  1685. })
  1686. } else if (webType === 3) {
  1687. window.addEventListener('urlchange', function(){
  1688. lp = location.pathname;
  1689. if (nowLocation == location.href) return
  1690. nowLocation = location.href; curSite = {SiteTypeID: 0}; pageNum.now = 1; // 重置规则+页码
  1691. DBSite.flarum.url(); // 重新判断规则
  1692. if (curSite.style) {insStyle(curSite.style)} // 插入 Style CSS 样式
  1693. pageLoading(); // 自动无缝翻页
  1694.  
  1695. if (GM_getValue('menu_page_number')) {pageNumber('add');} else {pageNumber('set');} // 显示页码
  1696. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1697. })
  1698. }
  1699. }
  1700. // 插入 Style CSS 样式
  1701. if (curSite.style) insStyle(curSite.style)
  1702.  
  1703. // 自动无缝翻页
  1704. pageLoading();
  1705.  
  1706.  
  1707. // --------------------------------------------------------
  1708.  
  1709.  
  1710. // [Discuz! 论坛] 判断各版块帖子列表类型
  1711. function discuzForum(m) {
  1712. if (m == 'm') { // 手机版页面
  1713. if (getCSS('a.loadmore')) {
  1714. curSite = DBSite.discuz_m_forum;
  1715. } else if (getCSS('.threadlist')) {
  1716. curSite = DBSite.discuz_m; curSite.pager.pageE = '.threadlist > ul > li';
  1717. } else if (getCSS('[id^="normalthread_"]')) {
  1718. curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="normalthread_"]:not(.ZDlist)';
  1719. }
  1720. if (curSite.SiteTypeID !== 0 && location.hostname === 'keylol.com') {curSite.history = false; urlC = true;}
  1721. } else {
  1722. if (getCSS('#autopbn')) { // 判断是否有 [下一页] 按钮
  1723. curSite = DBSite.discuz_forum;
  1724. } else if (getCSS('#waterfall')) { // 判断是否为图片模式
  1725. if (!getCSS('#pgbtn, .pgbtn')) { // 如果各版块帖子列表已存在这个元素,说明自带了无缝翻页
  1726. curSite = DBSite.discuz_waterfall; waterfallStyle(); // 图片模式列表样式预处理
  1727. }
  1728. } else {
  1729. curSite = DBSite.discuz_guide;
  1730. }
  1731. }
  1732. }
  1733. // [Discuz! 论坛] 判断手机版帖子内
  1734. function discuzThreadM() {
  1735. if (getCSS('[id^="pid"]')) {
  1736. curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="pid"], [id^="pid"]+div:not([id="post_new"])'
  1737. } else if (getCSS('[id^="post_"]')) {
  1738. curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="post_"]';
  1739. }
  1740. if (curSite.SiteTypeID !== 0 && location.hostname === 'keylol.com') {curSite.history = false; urlC = true;}
  1741. }
  1742. function discuz_() {
  1743. if (getCSS('body[id="nv_forum"][class^="pg_"][onkeydown*="27"]')) {
  1744. switch (getCSS('body[id="nv_forum"][class^="pg_"][onkeydown*="27"]').className) {
  1745. case 'pg_forumdisplay': // < 各版块帖子列表 >
  1746. discuzForum(); break;
  1747. case 'pg_viewthread': // < 帖子内 >
  1748. curSite = DBSite.discuz_thread; break;
  1749. case 'pg_guide': // < 导读帖子列表等 >
  1750. curSite = DBSite.discuz_guide; break;
  1751. case 'pg_collection': // < 淘贴列表 >
  1752. curSite = DBSite.discuz_collection; break;
  1753. }
  1754. }
  1755. // 如果上面没有匹配的则继续 < 搜索结果 >
  1756. if (curSite.SiteTypeID === 0) {
  1757. if (indexOF('search') || getCSS('body[id="nv_search"][onkeydown*="27"]')) {
  1758. if (indexOF('mobile=2', 's')) { // 手机版页面
  1759. curSite = DBSite.discuz_m; curSite.pager.pageE = '.threadlist > ul > li'; urlC = true;
  1760. } else {
  1761. curSite = DBSite.discuz_search;
  1762. }
  1763. }
  1764. }
  1765. // 如果上面没有匹配的则继续
  1766. if (curSite.SiteTypeID === 0) {
  1767. if (indexOF('.html')) { // 判断是不是静态网页(.html 结尾)
  1768. if (indexOF('/forum-')) { // < 各版块帖子列表 >
  1769. if (getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面
  1770. discuzForum('m');
  1771. } else {
  1772. discuzForum();
  1773. }
  1774. } else if (indexOF('/thread-')) { // < 帖子内 >
  1775. if (getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面
  1776. discuzThreadM();
  1777. } else {
  1778. curSite = DBSite.discuz_thread;
  1779. }
  1780. }
  1781. }
  1782. }
  1783. // 如果上面没有匹配的则继续
  1784. if (curSite.SiteTypeID === 0) {
  1785. if (indexOF('mod=forumdisplay', 's') || indexOF('forumdisplay.php')) { // < 各版块帖子列表 >
  1786. 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/")]')) { // 手机版页面
  1787. discuzForum('m');
  1788. } else {
  1789. discuzForum();
  1790. }
  1791. } else if (indexOF('mod=viewthread', 's') || indexOF('viewthread.php')) { // < 帖子内 >
  1792. 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/")]')) { // 手机版页面
  1793. discuzThreadM();
  1794. } else {
  1795. curSite = DBSite.discuz_thread;
  1796. }
  1797. } else if (indexOF('mod=guide', 's')) { // < 导读帖子列表 >
  1798. curSite = DBSite.discuz_guide;
  1799. } else if(indexOF('mod=space', 's') && indexOF('do=thread', 's')) { // 别人的主题/回复
  1800. curSite = DBSite.discuz_youspace;
  1801. } else if (indexOF('mod=collection', 's')) { // < 淘贴列表 >
  1802. curSite = DBSite.discuz_collection;
  1803. } else if (getCSS('#threadlist')) { // < 部分论坛的各板块 URL 是自定义的 >
  1804. discuzForum();
  1805. } else if (getCSS('#postlist')) { // < 部分论坛的帖子内 URL 是自定义的 >
  1806. curSite = DBSite.discuz_thread;
  1807. } else if (isMobile()) { // 手机版判断
  1808. discuzForum('m');
  1809. if (curSite.SiteTypeID === 0) discuzThreadM();
  1810. }
  1811. }
  1812. }
  1813. // [Discuz! 论坛] 图片模式列表样式预处理
  1814. function waterfallStyle() {
  1815. let width = getCSS('#waterfall > li:first-child').style.width;
  1816. 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;}`);
  1817. }
  1818.  
  1819.  
  1820. // [百度贴吧](发帖按钮点击事件)
  1821. function baidu_tieba_1() {
  1822. let button = getCSS('.tbui_aside_fbar_button.tbui_fbar_post > a');
  1823. if (button) {
  1824. button.remove();
  1825. getCSS('li.tbui_aside_fbar_button.tbui_fbar_down').insertAdjacentHTML(getAddTo(4), '<li class="tbui_aside_fbar_button tbui_fbar_post"><a href="javascript:void(0);" title="因为 [自动无缝翻页] 的原因,请点击该按钮发帖!"></a></li>')
  1826. button = getCSS('.tbui_aside_fbar_button.tbui_fbar_post > a');
  1827. if (button) {
  1828. button.onclick = function(){
  1829. let button2 = getCSS('div.edui-btn.edui-btn-fullscreen.edui-btn-name-portrait');
  1830. if (button2) {button2.click();} else {alert('提示:登录后才能发帖!');}
  1831. return false;
  1832. }
  1833. }
  1834. }
  1835. }
  1836. // [百度贴吧] 插入数据
  1837. function baidu_tieba_insertE(pageE, type) {
  1838. if (!pageE) return
  1839. // 获取 <script> 内容
  1840. const scriptElems = getXpath(`//script[contains(text(), 'Bigpipe.register("frs-list/pagelet/thread_list", ')]`, pageE, pageE);
  1841. if (scriptElems) {
  1842. // 从 <script> 中提取帖子列表字符串
  1843. let scriptText = scriptElems.textContent.replace('Bigpipe.register("frs-list/pagelet/thread_list", ','');
  1844. scriptText = scriptText.slice(0, scriptText.indexOf(').'));
  1845. // 字符串转 Element 元素
  1846. let temp_baidu_tieba = document.createElement('div'); temp_baidu_tieba.innerHTML = JSON.parse(scriptText).content;
  1847. processElems(temp_baidu_tieba);
  1848. }
  1849. }
  1850.  
  1851.  
  1852. // [NexusMods] 获取下一页地址
  1853. function nexusmods_nextL() {
  1854. if (getCSS('.nexus-ui-blocker')) return
  1855. let modList;
  1856. if (indexOF('/news')) {modList = RH_NewsTabContent;} else {modList = RH_ModList;}
  1857. if (!modList) return
  1858. let out_items = JSON.stringify(modList.out_items).replace(/{|}|"/g,''),
  1859. nextNum = getXpath('//div[contains(@class, "pagenav")][1]//a[contains(@class, "page-selected")]/parent::li/following-sibling::li/a'),
  1860. categories = modList.out_items.categories, categoriesUrl = '';
  1861. var url = '';
  1862. if (nextNum && nextNum.innerText) {
  1863. nextNum = nextNum.innerText;
  1864. if (out_items.indexOf('page:') > -1) {
  1865. out_items = out_items.replace(/page:\d+/, `page:${nextNum}`)
  1866. } else {
  1867. out_items += `,page:${nextNum}`;
  1868. }
  1869. if (categories && categories != []) {
  1870. for (let i = 0; i < categories.length; i++) {
  1871. categoriesUrl += `,categories[]:${categories[i]}`
  1872. }
  1873. categoriesUrl = categoriesUrl.replace(/,/,'');
  1874. if (out_items.indexOf('categories:') > -1) {
  1875. out_items = out_items.replace(/categories:\[.*\]/, categoriesUrl)
  1876. }
  1877. }
  1878. return `https://www.nexusmods.com${modList.uri}?RH_${modList.id}=${out_items}`
  1879. }
  1880. return ''
  1881. }
  1882. // [NexusMods] 的插入前函数(隐藏底部元素)
  1883. function nexusmods_bF(pageE) {
  1884. pageE.forEach(function (one) {
  1885. let now = one.querySelector('.mod-tile-left');
  1886. if (now) {
  1887. let downloadCount = now.querySelector('.downloadcount > span.flex-label');
  1888. if (downloadCount) {
  1889. if (GlobalModStats[now.dataset.gameId] && GlobalModStats[now.dataset.gameId][now.dataset.modId]) {
  1890. downloadCount.textContent = shortFormat(parseInt(GlobalModStats[now.dataset.gameId][now.dataset.modId].total));
  1891. }
  1892. }
  1893. }
  1894. });
  1895. return pageE
  1896. }
  1897.  
  1898.  
  1899. // [bilibili_search] 获取下一页地址
  1900. function bilibili_search_nextL() {
  1901. if (!location.search) return
  1902. let pageActive = 1, pageLast = parseInt(getXpath('//ul[@class="pages"]/li[contains(@class, "page-item")][not(contains(@class, "next") or contains(@class, "prev"))][last()]').innerText);
  1903. if (!pageLast) return
  1904. if (indexOF(/page=\d+/, 's')) {
  1905. pageActive = parseInt(/page=\d+/.exec(location.search)[0].replace('page=',''))
  1906. }
  1907. if (pageActive < pageLast) {
  1908. if (indexOF(/page=\d+/, 's')) {
  1909. return (location.origin + location.pathname + location.search.replace(/page=\d+/,`page=${pageActive+1}`))
  1910. } else {
  1911. return (location.origin + location.pathname + location.search + `&page=${pageActive+1}`)
  1912. }
  1913. }
  1914. }
  1915. // [bilibili_search] 插入前函数(加载图片)
  1916. function bilibili_search_bF(pageE) {
  1917. pageE.forEach(function (one) {
  1918. let img = getCSS('.img > .lazy-img > img[src=""]', one)
  1919. if (img) {
  1920. img.setAttribute('data-srclz', 'lazy')
  1921. }
  1922. });
  1923. return pageE
  1924. }
  1925. // [bilibili_search] 插入后函数(加载图片)
  1926. function bilibili_search_aF() {
  1927. let result = __INITIAL_STATE__.flow[__INITIAL_STATE__.flow.fields[0]].result;
  1928. if (result.length > 0) {
  1929. let imgArr = getAllCSS('.img > .lazy-img > img[data-srclz]');
  1930. if (imgArr.length > 0) {
  1931. for (let i = 0; i < imgArr.length; i++) {
  1932. imgArr[i].src = result[i].pic;
  1933. imgArr[i].removeAttribute('data-srclz');
  1934. }
  1935. }
  1936. }
  1937. }
  1938.  
  1939.  
  1940. // [漫画狂] 获取下一页地址
  1941. function cartoonmad_nextL() {
  1942. let url = getXpath('//a[@class="pages"][contains(text(),"下一頁")]');
  1943. if (url) {
  1944. if (url.getAttribute('href') === 'thend.asp') {
  1945. url = getXpath('//a[@class="pages"][contains(string(),"下一話")]')
  1946. if (url) return url.href;
  1947. pausePage = false;
  1948. GM_notification({text: `注意:该网站早期漫画章节,因为网站自身问题而无法翻至下一话(仅限于显示为 [第 X 卷]/[下一卷] 的)。\n因此需要手动去 [目录页] 进入下一卷!`, timeout: 10000});
  1949. } else {
  1950. return url.href;
  1951. }
  1952. }
  1953. return '';
  1954. }
  1955.  
  1956.  
  1957. // [漫画猫] 初始化(显示本话所以图片)
  1958. function manhuacat_init() {
  1959. let _img = '';
  1960. for (let now of img_data_arr) {_img += `<img src="${asset_domain}${img_pre}${now}">`;}
  1961. getOne(curSite.pager.insertP[0]).innerHTML = _img;
  1962.  
  1963. }
  1964. // [漫画猫] 获取下一页地址
  1965. function manhuacat_nextL(pageE, type) {
  1966. if (type === 'url') {
  1967. if(pageE.code == '0000') {
  1968. if (pageE.url === curSite.pageUrl) return
  1969. curSite.pageUrl = pageE.url;
  1970. getPageE_(curSite.pageUrl); // 真正的下一页链接
  1971. }
  1972. } else {
  1973. let vg_r_data = getCSS('.vg-r-data');
  1974. if (vg_r_data) {
  1975. getPageE_(`${location.origin}/chapter_num?chapter_id=${vg_r_data.dataset.chapter_num}&ctype=1&type=${vg_r_data.dataset.chapterType};`, 'json', 'GET', '', 'url');
  1976. }
  1977. }
  1978. }
  1979. // [漫画猫] 插入数据
  1980. function manhuacat_insertE(pageE, type) {
  1981. if (!pageE) return
  1982. if (type === 'url') { // 获取下一页链接
  1983. manhuacat_nextL(pageE, type); return
  1984. }
  1985. addHistory(pageE);
  1986. replaceElems(pageE);
  1987.  
  1988. // 插入图片
  1989. 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');;
  1990. for (let now of _img_arr) {_img += `<img src="${vg_r_data.dataset.chapterDomain}${img_pre}${now}">`;}
  1991. if (_img) {
  1992. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  1993. pageNum.now = pageNum._now + 1
  1994. }
  1995. }
  1996.  
  1997.  
  1998. // [漫画柜] 初始化(将本话其余图片插入网页中)
  1999. function manhuagui_init() {
  2000. // hook imgDate 代码
  2001. SMH.imgData = function(n) {window['imgDate'] = n;return{preInit:function(){}}}
  2002. // 重新执行本页的 imgDate 代码
  2003. insScript(curSite.pager.pageE);
  2004. let _img = '', imgPath = `${location.protocol}//i.hamreus.com${window['imgDate'].path}`;
  2005. //console.log(imgPath, window['imgDate'])
  2006. if (!(window['imgDate']) || !(imgPath)) return
  2007. // 遍历图片文件名数组,组合为 img 标签
  2008. for (let i = 0; i < window['imgDate'].files.length; i++) {_img += `<img src="${imgPath + window['imgDate'].files[i]}?e=${window['imgDate'].sl.e}&m=${window['imgDate'].sl.m}">`;}
  2009. // 插入并覆盖原来的一个图片
  2010. getOne(curSite.pager.insertP[0]).innerHTML = _img;
  2011. pausePage = true;
  2012. }
  2013. // [漫画柜] 获取下一页地址
  2014. function manhuagui_nextL() {
  2015. if (window['imgDate'].nextId == 0) return
  2016. var url = location.origin + location.pathname.replace(window['imgDate'].cid.toString(), window['imgDate'].nextId.toString())
  2017. if (url === curSite.pageUrl) return
  2018. curSite.pageUrl = url
  2019. getPageE_(curSite.pageUrl);
  2020. }
  2021. // [漫画柜] 插入数据
  2022. function manhuagui_insertE(pageE, type) {
  2023. if (!pageE) return
  2024. // 重新执行本页的 imgDate 代码
  2025. insScript(curSite.pager.pageE, pageE);
  2026. let _img = '', imgPath = `${location.protocol}//i.hamreus.com${window['imgDate'].path}`;
  2027. //console.log(imgPath, window['imgDate'])
  2028. if (!(window['imgDate']) || !(imgPath)) return
  2029. // 遍历图片文件名数组,组合为 img 标签
  2030. for (let i = 0; i < window['imgDate'].files.length; i++) {_img += `<img src="${imgPath + window['imgDate'].files[i]}?e=${window['imgDate'].sl.e}&m=${window['imgDate'].sl.m}">`;}
  2031. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img);
  2032. addHistory(pageE);
  2033. pageNum.now = pageNum._now + 1
  2034. }
  2035.  
  2036.  
  2037. // [36漫画] 初始化(将本话其余图片插入网页中)
  2038. function _36manga_init() {
  2039. let _img = '', imgPath = `${SinConf.resHost[0].domain[0]}${chapterPath}`;
  2040. if (!(chapterImages) || !(imgPath)) return
  2041. // 遍历图片文件名数组,组合为 img 标签
  2042. for (let i = 0; i < chapterImages.length; i++) {_img += `<img src="${imgPath}${chapterImages[i]}">`;}
  2043. // 插入并覆盖原来的一个图片
  2044. getOne(curSite.pager.insertP[0]).innerHTML = _img;
  2045. pausePage = true;
  2046. }
  2047. // [36漫画] 获取下一页地址
  2048. function _36manga_nextL() {
  2049. if (!nextChapterData.id) return
  2050. var url = comicUrl + nextChapterData.id + '.html'
  2051. if (url === curSite.pageUrl) return
  2052. curSite.pageUrl = url
  2053. getPageE_(curSite.pageUrl);
  2054. }
  2055. // [36漫画] 插入数据
  2056. function _36manga_insertE(pageE, type) {
  2057. if (!pageE) return
  2058. // 插入并执行数据代码
  2059. insScript(curSite.pager.pageE, pageE);
  2060. let _img = '', imgPath = `${SinConf.resHost[0].domain[0]}${chapterPath}`;
  2061. if (!(chapterImages) || !(imgPath)) return
  2062. // 遍历图片文件名数组,组合为 img 标签
  2063. for (let i = 0; i < chapterImages.length; i++) {_img += `<img src="${imgPath}${chapterImages[i]}">`;}
  2064. // 插入并覆盖原来的一个图片
  2065. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img);
  2066. addHistory(pageE);
  2067. pageNum.now = pageNum._now + 1
  2068. }
  2069.  
  2070.  
  2071. // [爱漫画] 获取全部图片
  2072. function imanhuaw_getIMG() {
  2073. let _img = '', _imgUrl;
  2074. for (let one of base64_decode(qTcms_S_m_murl_e).split("$qingtiandy$")) {
  2075. _imgUrl = one;
  2076. if (one.substring(0,1) == '/') {
  2077. _imgUrl = qTcms_m_weburl + _imgUrl;
  2078. } else {
  2079. if (qTcms_Pic_m_if != '2') {
  2080. one = one.replace(/\?/gi, 'a1a1');
  2081. one = one.replace(/&/gi, 'b1b1');
  2082. one = one.replace(/%/gi, 'c1c1');
  2083. let m_httpurl = '';
  2084. if (typeof(qTcms_S_m_mhttpurl) != 'undefined') m_httpurl = base64_decode(qTcms_S_m_mhttpurl);
  2085. if (location.hostname == 'www.ccshwy.com') qTcms_m_indexurl = 'http://h.ccshwy.com/';
  2086. _imgUrl = qTcms_m_indexurl + 'statics/pic/?p=' + escape(one) + '&picid=' + qTcms_S_m_id + '&m_httpurl=' + escape(m_httpurl);
  2087. } else {
  2088. _imgUrl = _imgUrl.replace('http:', '') ;
  2089. _imgUrl = _imgUrl.replace('https:', '');
  2090. }
  2091. }
  2092. _img += `<img src="${_imgUrl}">`;
  2093. }
  2094. return _img;
  2095. }
  2096. // [爱漫画] 初始化(调整本话其余图片)
  2097. function imanhuaw_init() {
  2098. getOne(curSite.pager.insertP[0]).outerHTML = imanhuaw_getIMG();
  2099. document.oncontextmenu = function(){}
  2100. }
  2101. // [爱漫画] 获取下一页地址
  2102. function imanhuaw_nextL() {
  2103. let next = location.origin + qTcms_Pic_nextArr
  2104. if (next && next != location.origin && next != curSite.pageUrl) {
  2105. curSite.pageUrl = next;
  2106. getPageE_(curSite.pageUrl);
  2107. }
  2108. }
  2109. // [爱漫画] 插入数据
  2110. function imanhuaw_insertE(pageE, type) {
  2111. if (!pageE) return
  2112. // 插入并运行 <script>
  2113. insScript('//head/script[not(@src)][contains(text(), "qTcms_S_m_murl_e")]', pageE);
  2114. // 将 img 标签插入到网页中
  2115. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), imanhuaw_getIMG());
  2116. addHistory(pageE);
  2117. pageNum.now = pageNum._now + 1
  2118. }
  2119.  
  2120.  
  2121. // [漫画 DB] 初始化(将本话其余图片插入网页中)
  2122. function manhuadb_init() {
  2123. let _img = '', data = getCSS('.vg-r-data'), imgDate;
  2124. if (!data) return
  2125. getAllCSS(curSite.pager.pageE.replace('', '')).forEach(function (one) {
  2126. if (one.tagName === 'SCRIPT' && one.textContent.indexOf('var img_data =') > -1) {
  2127. let json = JSON.parse(window.atob(one.textContent.split("'")[1]));
  2128. if (json) {
  2129. let _img = '';
  2130. for (let i = 0; i < json.length; i++) {_img += `<img class="img-fluid show-pic" src="${data.dataset.host + data.dataset.img_pre + json[i].img}">`;}
  2131. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2132. }
  2133. }
  2134. })
  2135. }
  2136. // [漫画 DB] 获取下一页地址
  2137. function manhuadb_nextL() {
  2138. let nextArr = getAllCSS('a.fixed-a-es'), next;
  2139. var url = '';
  2140. if (nextArr.length == 0) return
  2141. for (let i = 0; i < nextArr.length; i++) {
  2142. if (nextArr[i].className.indexOf('active') > -1) {
  2143. if (nextArr[i+1]) url = nextArr[i+1].href;
  2144. break;
  2145. }
  2146. }
  2147. if (url === curSite.pageUrl) return
  2148. curSite.pageUrl = url
  2149. getPageE_(curSite.pageUrl);
  2150. }
  2151. // [漫画 DB] 插入数据
  2152. function manhuadb_insertE(pageE, type) {
  2153. if (!pageE) return
  2154. if (replaceElems(pageE, curSite.pager.pageE, curSite.pager.pageE)) {
  2155. addHistory(pageE);
  2156. pageNum.now = pageNum._now + 1
  2157. manhuadb_init(); // 将刚刚替换的图片插入网页中
  2158. }
  2159. }
  2160.  
  2161.  
  2162. // [HiComic(嗨漫画)] 初始化(将本话其余图片插入网页中)
  2163. function hicomic_init() {
  2164. let _img = '';
  2165. getAllCSS('.chapter > section:not(:first-child) > section[val]').forEach(function (one) {
  2166. let src = one.getAttribute('val');
  2167. if (src.indexOf('!p_c_c_') === -1) src += '!p_c_c_h'
  2168. _img += `<img src="${src}">`
  2169. })
  2170. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2171. window.document.title = window.document.title.replace(/(\(第.+\))? - HiComic/, `(${getCSS('.chapter_name').textContent}) - HiComic`); // 修改网页标题(加上 第 X 话)
  2172. }
  2173. // [HiComic(嗨漫画)] 获取下一页地址
  2174. function hicomic_nextL() {
  2175. let nextId;
  2176. nextId = getCSS('.next_chapter:not(.end)')
  2177. if (nextId && nextId.id && nextId.id != 'None') {
  2178. curSite.pageUrl = location.href;
  2179. getPageE_(`https://www.hicomic.net/api/web/chapter/${nextId.id}/contents`, 'json');
  2180. }
  2181. }
  2182. // [HiComic(嗨漫画)] 插入数据
  2183. function hicomic_insertE(pageE, type) {
  2184. if (!pageE || pageE.code != 200) return
  2185. if (pageE.results.chapter.next) { // 写入下一页的 UUID
  2186. getCSS('.next_chapter').id = pageE.results.chapter.next;
  2187. } else {
  2188. getCSS('.next_chapter').id = 'None';
  2189. getCSS('.next_chapter').classList.add('end');
  2190. }
  2191. curSite.pageUrl =`https://www.hicomic.net/chapters/${pageE.results.chapter.uuid}/contents`
  2192. getCSS('.chapter_name').textContent = pageE.results.chapter.name; // 修改漫画标题
  2193. addHistory(pageE, window.document.title.replace(/(\(第.+\))? - HiComic/, `(${pageE.results.chapter.name}) - HiComic`));
  2194. let _img = '';
  2195. for (let i = 0; i < pageE.results.chapter.contents.length; i++) { // 遍历图片文件名数组,组合为 img 标签
  2196. let src = pageE.results.chapter.contents[i].url;
  2197. if (src.indexOf('!p_c_c_') === -1) src += '!p_c_c_h';
  2198. _img += `<img src="${src}">`
  2199. }
  2200. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2201. pageNum.now = pageNum._now + 1
  2202. }
  2203.  
  2204.  
  2205. // [动漫之家] 初始化(调整本话其余图片)
  2206. function dmzj_init(css) {
  2207. let _img = '';
  2208. getAllCSS(css).forEach(function (one) {_img += `<img src="${one.dataset.original}">`;})
  2209. getOne(curSite.pager.insertP[0]).innerHTML = _img;
  2210. }
  2211. // [动漫之家] 插入数据
  2212. function dmzj_insertE(pageE, type) {
  2213. if (!pageE) return
  2214. // 插入并运行 <script>
  2215. insScript('head > script[type]:not([src])', pageE);
  2216.  
  2217. // 插入图片
  2218. let _img = '', _img_arr;
  2219. if (pages.indexOf('|') === -1) {
  2220. _img_arr = JSON.parse(pages.replace(/\r\n/g,'|')).page_url.split('|');
  2221. } else {
  2222. _img_arr = JSON.parse(pages).page_url.split('|');
  2223. }
  2224. for (let now of _img_arr) {
  2225. _img += `<img src="${img_prefix}${now}">`;
  2226. }
  2227. if (_img) {
  2228. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2229. addHistory(pageE);
  2230. if (replaceElems(pageE)) pageNum.now = pageNum._now + 1
  2231. }
  2232. }
  2233. // [动漫之家-漫画] 插入数据
  2234. function dmzj_manhua_insertE(pageE, type) {
  2235. if (!pageE) return
  2236. // 插入并运行 <script>
  2237. insScript('head > script[type]:not([src])', pageE);
  2238.  
  2239. // 插入图片
  2240. let _img = '';
  2241. for (let now of arr_pages) {
  2242. _img += `<img src="${img_prefix}${now}">`;
  2243. }
  2244. if (_img) {
  2245. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2246. addHistory(pageE);
  2247. if (replaceElems(pageE)) pageNum.now = pageNum._now + 1
  2248. }
  2249. }
  2250.  
  2251.  
  2252. // [优酷漫画] 初始化(调整本话其余图片)
  2253. function ykmh_init(css) {
  2254. let host = SinMH.getChapterImage(1).split('/')[0] + '//' + SinMH.getChapterImage(1).split('/')[2];
  2255. if (!host) return
  2256. let _img = '';
  2257. for (let one of chapterImages) {_img += `<img src="${host}${one}">`;}
  2258. getOne(curSite.pager.insertP[0]).innerHTML = _img;
  2259. }
  2260. // [优酷漫画] 获取下一页地址
  2261. function ykmh_nextL() {
  2262. let url = comicUrl + nextChapterData.id + '.html'
  2263. if (nextChapterData.id != null && url && url != '.html' && url != curSite.pageUrl) {
  2264. curSite.pageUrl = url;
  2265. getPageE_(curSite.pageUrl);
  2266. }
  2267. }
  2268. // [优酷漫画] 插入数据
  2269. function ykmh_insertE(pageE, type) {
  2270. if (!pageE) return
  2271. // 插入并运行 <script>
  2272. insScript(curSite.pager.pageE, pageE);
  2273.  
  2274. let host = SinMH.getChapterImage(1).split('/')[0] + '//' + SinMH.getChapterImage(1).split('/')[2];
  2275. if (!host) host = document.querySelector(curSite.pager.insertP[0]).src.split('/')[0] + '//' + document.querySelector(curSite.pager.insertP[0]).src.split('/')[2]
  2276. // 插入图片
  2277. let _img = '';
  2278. for (let one of chapterImages) {_img += `<img src="${host}${one}">`;}
  2279. if (_img) {
  2280. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2281. addHistory(document, pageTitle + ' - 优酷漫画');
  2282. if (replaceElems(pageE)) pageNum.now = pageNum._now + 1
  2283. }
  2284. }
  2285.  
  2286.  
  2287. // [动漫戏说] 插入后函数(加载图片)
  2288. function acgn_aF() {
  2289. let old = getAllCSS('.pic[_src][id]'), _img = '';
  2290. if (old.length > 0) {
  2291. for (let now of old) {now.outerHTML = `<div class="pic" _src="${now.getAttribute('_src')}"><img src="${now.getAttribute('_src')}" class="img1"></div>`;}
  2292. }
  2293. }
  2294.  
  2295.  
  2296. // [漫画星球] 插入数据
  2297. function mhxqiu_insertE(pageE, type) {
  2298. if (!pageE) return
  2299. // 插入并运行 <script>
  2300. insScript('//script[contains(text(), "eval") and contains(text(), "newImgs")]', pageE);
  2301.  
  2302. // 插入图片
  2303. let _img = '';
  2304. for (let now of newImgs) {_img += `<li><div style="display: inline-block;zoom: 1;"><img src="${now}" class="loaded lazy" style="opacity: 1;box-shadow:none;"></div></li>`;}
  2305. if (_img) {
  2306. // 将 img 标签插入到网页中
  2307. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img);
  2308. addHistory(pageE);
  2309. pageNum.now = pageNum._now + 1
  2310. replaceElems(pageE)
  2311. }
  2312. }
  2313.  
  2314.  
  2315. // [风之动漫] 插入数据
  2316. function fffdm_insertE(pageE, type) {
  2317. if (!pageE) return
  2318. // 插入并运行 <script>
  2319. let scriptElems = getXpath('id("main")/script[contains(text(), "mhpicurl")][1]', pageE, pageE);
  2320. if (scriptElems) {
  2321. document.body.appendChild(document.createElement('script')).textContent = scriptElems.textContent.replace(/document\.write.+/, '');
  2322.  
  2323. // 插入图片
  2324. setTimeout(function() {
  2325. getOne(curSite.pager.insertP[0]).appendChild(document.createElement('img')).src = mhpicurl;
  2326. addHistory(pageE);
  2327. pageNum.now = pageNum._now + 1
  2328. replaceElems(pageE)
  2329. }, 100)
  2330. }
  2331. }
  2332.  
  2333.  
  2334. // [乐语漫画] 初始化(调整本话其余图片)
  2335. function leyuman_init() {
  2336. let _img = '';
  2337. for (let one of JSON.parse(z_img)) {
  2338. if (one.slice(0,4) === 'http') {
  2339. _img += `<img src="${one}">`;
  2340. } else {
  2341. _img += `<img src="https://img.shishi-life.com/${one}">`;
  2342. }
  2343. }
  2344. getOne(curSite.pager.insertP[0]).innerHTML = _img;
  2345.  
  2346. }
  2347. // [乐语漫画] 插入数据
  2348. function leyuman_insertE(pageE, type) {
  2349. if (!pageE) return
  2350. // 插入并运行 <script>
  2351. insScript('//body//script[not(@src)][contains(text(), "z_img=")]', pageE);
  2352.  
  2353. // 插入图片
  2354. let _img = '';
  2355. for (let one of JSON.parse(z_img)) {
  2356. if (one.slice(0,4) === 'http') {
  2357. _img += `<img src="${one}">`;
  2358. } else {
  2359. _img += `<img src="https://img.shishi-life.com/${one}">`;
  2360. }
  2361. }
  2362. if (_img) {
  2363. // 将 img 标签插入到网页中
  2364. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img);
  2365. addHistory(pageE);
  2366. pageNum.now = pageNum._now + 1
  2367. replaceElems(pageE)
  2368. }
  2369. }
  2370.  
  2371.  
  2372. // [新新漫画] 初始化(调整本话其余图片)
  2373. function _77mh_init() {
  2374. let _img = '';
  2375. for (let one of arr) {_img += `<img src="${img_qianz}${one}">`;}
  2376. getOne(curSite.pager.insertP[0]).innerHTML = _img;
  2377. }
  2378. // [新新漫画] 获取下一页地址
  2379. function _77mh_nextL() {
  2380. let next = nextLink_b
  2381. if (next && next != curSite.pageUrl) {
  2382. curSite.pageUrl = next;
  2383. getPageE_(curSite.pageUrl);
  2384. }
  2385. }
  2386. // [新新漫画] 插入数据
  2387. function _77mh_insertE(pageE, type) {
  2388. if (!pageE) return
  2389. // 插入并运行 <script>
  2390. insScript('//script[not(@src)][contains(text(), "eval(")]', pageE);
  2391.  
  2392. // 插入图片
  2393. let _img = '';
  2394. for (let one of msg.split('|')) {_img += `<img src="${img_qianz}${one}.webp">`;}
  2395. if (_img) {
  2396. // 将 img 标签插入到网页中
  2397. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img);
  2398. addHistory(pageE);
  2399. pageNum.now = pageNum._now + 1
  2400. }
  2401. }
  2402.  
  2403. // [古风漫画网] 插入数据
  2404. function gufengmh_insertE(pageE, type) {
  2405. if (!pageE) return
  2406. // 插入并运行 <script>
  2407. insScript(curSite.pager.pageE, pageE);
  2408. let _img = '';
  2409. for (let one of chapterImages) {_img += `<img src="https://res.xiaoqinre.com/${chapterPath}${one}" data-index="0" style="display: inline-block;">`;}
  2410. if (_img) {
  2411. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img);
  2412. addHistory(document, pageTitle + '-古风漫画网');
  2413. pageNum.now = pageNum._now + 1
  2414. }
  2415. }
  2416.  
  2417.  
  2418. // [Mangabz 漫画] 初始化(调整本话图片)
  2419. function mangabz_init() {
  2420. let showimage = getCSS('#showimage'),
  2421. cp_img = getCSS('#cp_img'),
  2422. cp_image = getCSS('#cp_image');
  2423. if (showimage) {showimage.removeAttribute('oncontextmenu');}
  2424. if (cp_img) {cp_img.removeAttribute('oncontextmenu');}
  2425. if (cp_image) {
  2426. cp_image.removeAttribute('oncontextmenu');
  2427. cp_image.removeAttribute('id');
  2428. cp_image.removeAttribute('style');
  2429. }
  2430. }
  2431. // [Mangabz 漫画] 获取下一页地址
  2432. function mangabz_nextL() {
  2433. var url = '';
  2434. if (MANGABZ_PAGE === MANGABZ_IMAGE_COUNT) { // 下一话
  2435. if (getNextE('//a[./img[contains(@src, "icon_xiayizhang")]]')) getPageE_(curSite.pageUrl); // 访问下一话 URL 获取
  2436. } else { // 下一页
  2437. if (!mkey) var mkey = '';
  2438. 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}`
  2439. if (url === curSite.pageUrl) return
  2440. curSite.pageUrl = url
  2441. //console.log(curSite.pageUrl)
  2442. getPageE_(curSite.pageUrl, 'text', 'GET', '', 'Next'); // 访问下一页 URL 获取
  2443. }
  2444. }
  2445. // [Mangabz 漫画] 插入数据
  2446. function mangabz_insertE(pageE, type) {
  2447. if (pageE) {
  2448. if (type === 'Next') { // 下一页
  2449. let imgArr = eval(pageE),
  2450. _img = '';
  2451. for (let now of imgArr) {_img += `<img src="${now}">`;}
  2452. if (_img) {
  2453. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2454. MANGABZ_PAGE += imgArr.length;
  2455. addHistory(pageE, document.title, location.origin + MANGABZ_CURL.substring(0, MANGABZ_CURL.length - 1) + '-p' + MANGABZ_PAGE + '/');
  2456. }
  2457. } else { // 下一话
  2458. // 插入 <script> 标签
  2459. insScript('html:not([dir]) > head > script:not([src])', pageE);
  2460. addHistory(pageE);
  2461. pageNum.now = pageNum._now + 1
  2462. replaceElems(pageE)
  2463. MANGABZ_PAGE = 0;
  2464. mangabz_nextL();
  2465. }
  2466. }
  2467. }
  2468.  
  2469.  
  2470. // [动漫屋] 获取下一页地址
  2471. function dm5_nextL() {
  2472. var url = '';
  2473. if (DM5_PAGE === DM5_IMAGE_COUNT) { // 下一话
  2474. if (getNextE('//div[@class="view-paging"]//a[text()="下一章"]')) getPageE_(curSite.pageUrl); // 访问下一话 URL 获取
  2475. } else { // 下一页
  2476. if (!mkey) var mkey = '';
  2477. 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}`
  2478. if (url === curSite.pageUrl) return
  2479. curSite.pageUrl = url
  2480. //console.log(curSite.pageUrl)
  2481. getPageE_(curSite.pageUrl, 'text', 'GET', '', 'Next'); // 访问下一页 URL 获取
  2482. }
  2483. }
  2484. // [动漫屋] 插入数据
  2485. function dm5_insertE(pageE, type) {
  2486. if (pageE) {
  2487. if (type === 'Next') { // 下一页
  2488. let imgArr = eval(pageE),
  2489. _img = '';
  2490. for (let now of imgArr) {_img += `<img src="${now}">`;}
  2491. if (_img) {
  2492. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2493. DM5_PAGE += imgArr.length;
  2494. addHistory(pageE, document.title, location.origin + DM5_CURL.substring(0, DM5_CURL.length - 1) + '-p' + DM5_PAGE + '/');
  2495. }
  2496. } else { // 下一话
  2497. // 插入 <script> 标签
  2498. insScript('html:not([dir]) > head > script:not([src])', pageE);
  2499. addHistory(pageE);
  2500. pageNum.now = pageNum._now + 1
  2501. replaceElems(pageE)
  2502. DM5_PAGE = 0;
  2503. dm5_nextL();
  2504. }
  2505. }
  2506. }
  2507.  
  2508.  
  2509. // [Xmanhua 漫画] 获取下一页地址
  2510. function xmanhua_nextL() {
  2511. var url = '';
  2512. if (XMANHUA_PAGE === XMANHUA_IMAGE_COUNT) { // 下一话
  2513. if (getNextE('//a[./img[contains(@src, "reader-bottom-right-2.png")]]')) getPageE_(curSite.pageUrl); // 访问下一话 URL 获取
  2514. } else { // 下一页
  2515. if (!mkey) var mkey = '';
  2516. 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}`
  2517. if (url === curSite.pageUrl) return
  2518. curSite.pageUrl = url
  2519. //console.log(curSite.pageUrl)
  2520. getPageE_(curSite.pageUrl, 'text', 'GET', '', 'Next'); // 访问下一页 URL 获取
  2521. }
  2522. }
  2523. // [Xmanhua 漫画] 插入数据
  2524. function xmanhua_insertE(pageE, type) {
  2525. if (pageE) {
  2526. if (type === 'Next') { // 下一页
  2527. let imgArr = eval(pageE),
  2528. _img = '';
  2529. for (let now of imgArr) {_img += `<img src="${now}">`;}
  2530. if (_img) {
  2531. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2532. XMANHUA_PAGE += imgArr.length;
  2533. addHistory(pageE, document.title, location.origin + XMANHUA_CURL.substring(0, XMANHUA_CURL.length - 1) + '-p' + XMANHUA_PAGE + '/');
  2534. }
  2535. } else { // 下一话
  2536. // 插入 <script> 标签
  2537. insScript('html:not([dir]) > head > script:not([src])', pageE);
  2538. addHistory(pageE);
  2539. pageNum.now = pageNum._now + 1
  2540. replaceElems(pageE)
  2541. XMANHUA_PAGE = 0;
  2542. xmanhua_nextL();
  2543. }
  2544. }
  2545. }
  2546.  
  2547.  
  2548. // [COCOMANGA 漫画] 初始化(调整本话图片)
  2549. function cocomanga_init() {
  2550. let last = getCSS('.mh_comicpic:last-of-type');
  2551. if (last && last.getAttribute('p')) {
  2552. getOne(curSite.pager.insertP[0]).innerHTML = ''; // 删除旧图片元素
  2553. cocomanga_img(parseInt(last.getAttribute('p'))) // 插入新图片元素
  2554. }
  2555. }
  2556. // [COCOMANGA 漫画] 生成图片元素并插入网页
  2557. function cocomanga_img(totalImageCount) {
  2558. if (totalImageCount < 1) return
  2559. let _img = '';
  2560. for (let i=1; i<=totalImageCount; i++) {_img += `<div class="mh_comicpic" p="${i}"><img src="${__cr.getPicUrl(i)}"></div>`;}
  2561. getOne(curSite.pager.insertP[0]).insertAdjacentHTML(getAddTo(curSite.pager.insertP[1]), _img); // 将 img 标签插入到网页中
  2562. }
  2563. // [COCOMANGA 漫画] 插入数据
  2564. function cocomanga_insertE(pageE, type) {
  2565. if (pageE) {
  2566. // 插入 <script> 标签
  2567. insScript('head > script:not([src]), script[src*="custom.js"], script[src*="dynamicjs.js"]', pageE);
  2568.  
  2569. // 插入新图片元素
  2570. setTimeout(function() {
  2571. let totalImageCount = __cdecrypt('fw122587mkertyui', CryptoJS.enc.Base64.parse(mh_info.enc_code1).toString(CryptoJS.enc.Utf8));
  2572. if (!totalImageCount) totalImageCount = __cdecrypt('fw12558899ertyui', CryptoJS.enc.Base64.parse(mh_info.enc_code1).toString(CryptoJS.enc.Utf8));
  2573. cocomanga_img(parseInt(totalImageCount));
  2574. }, 100)
  2575. addHistory(pageE);
  2576. pageNum.now = pageNum._now + 1
  2577. replaceElems(pageE)
  2578. }
  2579. }
  2580.  
  2581.  
  2582. // [国家自然科学基金] 获取下一页地址
  2583. function nsfc_nextL() {
  2584. let id = decodeURIComponent(document.location.href.split('/')[document.location.href.split('/').length - 1]), data
  2585. if (!document.nowPageNum) document.nowPageNum = 2
  2586. data = `id=${id}&index=${document.nowPageNum}`
  2587. if (data === curSite.pageUrl) return
  2588. curSite.pageUrl = data
  2589. getPageE_(location.origin + '/baseQuery/data/completeProjectReport', 'json', 'POST', data); // 访问下一页 URL 获取
  2590. }
  2591. // [国家自然科学基金] 插入数据
  2592. function nsfc_insertE(pageE, type) {
  2593. if (!pageE || pageE.code != 200) {curSite.SiteTypeID = 0; return}
  2594. if (!pageE.data.hasnext) {curSite.SiteTypeID = 0} else {document.nowPageNum++}
  2595. pageNum.now = pageNum._now + 1
  2596. 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}">`);
  2597. }
  2598.  
  2599.  
  2600.  
  2601. // [酷科研] 获取下一页地址
  2602. function coolkeyan_nextL() {
  2603. if (!getCSS('.q-img__image')) return
  2604. let id = getCSS('.q-breadcrumbs--last > span.q-breadcrumbs__el'), data
  2605. if (id && id.textContent) {id=parseInt(id.textContent)} else {return}
  2606. if (!document.nowPageNum) document.nowPageNum = 2
  2607. data = `ratify_no=${id}&index=${document.nowPageNum}`
  2608. if (data === curSite.pageUrl) return
  2609. curSite.pageUrl = data
  2610. getPageE_(location.origin + '/api/funds/nsfc/creport?' + data, 'json', 'GET'); // 访问下一页 URL 获取
  2611. }
  2612. // [酷科研] 插入数据
  2613. function coolkeyan_insertE(pageE, type) {
  2614. if (!pageE || pageE == {}) {curSite.SiteTypeID = 0; return}
  2615. if (!pageE.url) {curSite.SiteTypeID = 0; return} else {document.nowPageNum++}
  2616. pageNum.now = pageNum._now + 1
  2617. getCSS('.q-img>div[style*="padding-bottom"]').style.paddingBottom = `${(document.nowPageNum * 1000) - 1000}px`
  2618. 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>`);
  2619. }
  2620.  
  2621.  
  2622. // --------------------------------------------------------
  2623.  
  2624.  
  2625. // 自动无缝翻页
  2626. function pageLoading() {
  2627. if (curSite.SiteTypeID === 0 || !curSite.pager) return
  2628. if (curSite.pager.type === undefined) curSite.pager.type = 1; // 默认翻页模式 1
  2629. if (curSite.pager.scrollD === undefined) curSite.pager.scrollD = 1500; // 默认翻页触发线 1500
  2630. if (curSite.pager.interval === undefined) curSite.pager.interval = 500; // 默认间隔时间 500ms
  2631. //console.log(curSite)
  2632. curSite.pageUrl = ''; // 下一页URL
  2633. windowScroll(function (direction, e) {
  2634. // 下滑 且 未暂停翻页 且 SiteTypeID > 0 时,才准备翻页
  2635. if (direction != 'down' || !pausePage || curSite.SiteTypeID == 0) return
  2636.  
  2637. // 翻页模式 5 且为框架内时,要判断顶层是否通过页码暂停翻页了
  2638. if (curSite.pager.type == 5 && self != top && window.top.document.xiu_pausePage == false) return
  2639.  
  2640. let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop,
  2641. scrollHeight = window.innerHeight || document.documentElement.clientHeight,
  2642. scrollD = curSite.pager.scrollD;
  2643. // <<<<< 翻页类型 3(依靠 [基准元素] 与 [浏览器可视区域底部] 之间的距离缩小来触发翻页)>>>>>
  2644. if (curSite.pager.type === 3) {
  2645. if (!curSite.pager.scrollE) curSite.pager.scrollE = curSite.pager.replaceE; // 默认基准元素是页码
  2646. let scrollE = getOne(curSite.pager.scrollE);
  2647. //console.log(scrollE.offsetTop, scrollE.offsetTop - (scrollTop + scrollHeight), scrollD, scrollTop + scrollHeight, curSite.SiteTypeID)
  2648. if (scrollE.offsetTop - (scrollTop + scrollHeight) <= scrollD) {intervalPause(); checkURL(getPageE);}
  2649.  
  2650. } else if (document.documentElement.scrollHeight <= scrollHeight + scrollTop + scrollD) {
  2651. // <<<<< 翻页类型 1(由脚本实现自动无缝翻页)>>>>>
  2652. if (curSite.pager.type === 1) {
  2653. intervalPause(); checkURL(getPageE);
  2654.  
  2655. // <<<<< 翻页类型 2(网站自带了自动无缝翻页功能,只需要点击下一页按钮即可)>>>>>
  2656. } else if (curSite.pager.type === 2) {
  2657. let autopbn = getOne(curSite.pager.nextL);
  2658. if (!autopbn) return
  2659. if (curSite.pager.isHidden && isHidden(autopbn)) return // 如果 isHidden = true,那么需要判断元素是否隐藏
  2660. if (curSite.pager.nextText) {
  2661. //console.log(curSite.pager.nextText, autopbn.innerText, autopbn)
  2662. // 按钮文本,当按钮文本 = 该文本时,才会点击按钮加载下一页
  2663. if (autopbn.innerText === curSite.pager.nextText) {autopbn.click(); pageNum.now = pageNum._now + 1;}
  2664. } else if (curSite.pager.nextTextOf) {
  2665. // 按钮文本的一部分,当按钮文本包含该文本时,才会点击按钮加载下一页
  2666. if (autopbn.innerText.indexOf(curSite.pager.nextTextOf) > -1) {autopbn.click(); pageNum.now = pageNum._now + 1;}
  2667. } else if (curSite.pager.nextHTML) {
  2668. // 按钮内元素,当按钮内元素 = 该元素内容时,才会点击按钮加载下一页
  2669. if (autopbn.innerHTML === curSite.pager.nextHTML) {autopbn.click(); pageNum.now = pageNum._now + 1;}
  2670. } else {
  2671. intervalPause();
  2672. // 如果没有指定按钮文字就直接点击
  2673. autopbn.click(); pageNum.now = pageNum._now + 1;
  2674. }
  2675.  
  2676. // <<<<< 翻页类型 4(部分简单的动态加载类网站)>>>>>
  2677. } else if (curSite.pager.type === 4) {
  2678. // 为百度贴吧的发帖考虑,预留底部一小部分...
  2679. if (!(curSite.SiteTypeID === SiteType.BAIDU_TIEBA && document.documentElement.scrollHeight <= scrollHeight + scrollTop + 200)) {
  2680. intervalPause(); if (typeof curSite.pager.nextL == 'function') {curSite.pager.nextL();} else if (getNextE(curSite.pager.nextL)) {getPageE_(curSite.pageUrl);}
  2681. }
  2682.  
  2683. // <<<<< 翻页类型 5(插入 iframe 方式来加载下一页)>>>>>
  2684. } else if (curSite.pager.type === 5) {
  2685. checkURL(insIframe);
  2686.  
  2687. // <<<<< 翻页类型 6(通过 iframe 获取下一页动态加载内容)>>>>>
  2688. } else if (curSite.pager.type === 6) {checkURL(insIframe_);}
  2689. }
  2690. });
  2691.  
  2692. function intervalPause() {
  2693. if (curSite.pager.interval) {
  2694. pausePage = false
  2695. setTimeout(function(){pausePage = true;}, curSite.pager.interval)
  2696. }
  2697. }
  2698. }
  2699.  
  2700. // 翻页类型 1/3
  2701. function getPageE(url) {
  2702. GM_xmlhttpRequest({
  2703. url: url,
  2704. method: 'GET',
  2705. overrideMimeType: 'text/html; charset=' + document.charset,
  2706. headers: {
  2707. 'Referer': (curSite.noReferer === true) ? '':location.href,
  2708. 'User-Agent': navigator.userAgent
  2709. },
  2710. timeout: 10000,
  2711. onload: function (response) {
  2712. try {
  2713. //console.log('URL:' + url, '最终 URL:' + response.finalUrl, '返回内容:' + response.responseText)
  2714. processElems(createDocumentByString(response.responseText));
  2715. } catch (e) {
  2716. console.error('[自动无缝翻页] - 处理获取到的下一页内容时出现问题,请检查!', e);
  2717. }
  2718. },
  2719. onerror: function (response) {
  2720. console.log('URL:' + url, response)
  2721. GM_notification({text: '❌ 获取下一页失败...', timeout: 5000});
  2722. },
  2723. ontimeout: function (response) {
  2724. setTimeout(function(){curSite.pageUrl = '';}, 3000)
  2725. console.log('URL:' + url, response)
  2726. GM_notification({text: '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...', timeout: 5000});
  2727. }
  2728. });
  2729. }
  2730. // 翻页类型 4
  2731. function getPageE_(url, type = '', method = 'GET', data = '', type2) {
  2732. let mimeType;
  2733. switch (type) {
  2734. case 'json':
  2735. mimeType = 'application/json; charset=' + document.charset; break;
  2736. case 'text':
  2737. mimeType = 'text/plain; charset=' + document.charset; break;
  2738. default:
  2739. mimeType = 'text/html; charset=' + document.charset;
  2740. }
  2741.  
  2742. GM_xmlhttpRequest({
  2743. url: url,
  2744. method: method,
  2745. data: data,
  2746. responseType: type,
  2747. overrideMimeType: mimeType,
  2748. headers: {
  2749. 'Referer': (curSite.noReferer === true) ? '':location.href,
  2750. 'Content-Type': (method === 'POST') ? 'application/x-www-form-urlencoded':'',
  2751. 'User-Agent': navigator.userAgent
  2752. },
  2753. timeout: 10000,
  2754. onload: function (response) {
  2755. try {
  2756. //console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText)
  2757. switch (type) {
  2758. case 'json':
  2759. curSite.pager.insertE(response.response, type2);
  2760. break;
  2761. case 'text':
  2762. curSite.pager.insertE(response.responseText, type2)
  2763. break;
  2764. default:
  2765. curSite.pager.insertE(createDocumentByString(response.responseText), type2)
  2766. }
  2767. } catch (e) {
  2768. console.log(e);
  2769. }
  2770. },
  2771. onerror: function (response) {
  2772. console.log('URL:' + url, response)
  2773. GM_notification({text: '❌ 获取下一页失败...', timeout: 5000});
  2774. },
  2775. ontimeout: function (response) {
  2776. setTimeout(function(){curSite.pageUrl = '';}, 3000)
  2777. console.log('URL:' + url, response)
  2778. GM_notification({text: '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...', timeout: 5000});
  2779. }
  2780. });
  2781. }
  2782. // 翻页类型 5(插入 iframe 方式加载下一页,无限套娃)
  2783. function insIframe(src) {
  2784. // 停用当前页面翻页
  2785. if (curSite.SiteTypeID == 0) return
  2786. curSite.SiteTypeID = 0;
  2787.  
  2788. // 创建 iframe
  2789. let iframe = document.createElement('iframe');
  2790. iframe.style = 'position: absolute !important; width: 100% !important; height: 100% !important; border: none !important;';
  2791. iframe.id = 'Autopage_iframe';
  2792. iframe.src = src;
  2793.  
  2794. var beforeScrollTop = document.documentElement.scrollTop || document.body.scrollTop
  2795. // 当滚动条到底部时(即完全显示 iframe 框架),隐藏当前页面的滚动条
  2796. window.addEventListener('scroll', function () {
  2797. let scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  2798. clientHeight = document.documentElement.clientHeight || document.body.clientHeight,
  2799. scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight,
  2800. afterScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  2801. delta = afterScrollTop - beforeScrollTop;
  2802. if (delta == 0) return false;
  2803. beforeScrollTop = afterScrollTop;
  2804.  
  2805. //console.log(delta, (scrollTop + clientHeight + 10), scrollHeight, '1111')
  2806. if (delta > 0 && scrollTop + clientHeight + 10 >= scrollHeight && !getCSS('#Autopage_iframe-scroll')) {
  2807. let newStyle = document.createElement('style'); newStyle.id = 'Autopage_iframe-scroll';
  2808. newStyle.textContent = 'html::-webkit-scrollbar, body::-webkit-scrollbar {width: 0 !important;height: 0 !important;} html, body {scrollbar-width: none !important;}';
  2809. if (curSite.pager.style) newStyle.textContent += curSite.pager.style;
  2810. document.documentElement.appendChild(newStyle);
  2811.  
  2812. // 恢复 iframe 的滚动条
  2813. if (iframe.contentWindow.document.querySelector('#Autopage_iframe-scroll-hidden')) iframe.contentWindow.document.querySelector('#Autopage_iframe-scroll-hidden').remove();
  2814.  
  2815. // 给予 iframe 焦点
  2816. iframe.focus();
  2817. if (iframe.contentWindow.document.body) {iframe.contentWindow.document.body.focus(); iframe.contentWindow.document.body.click();}
  2818. } else if (delta < 0 && scrollTop + clientHeight + 10 <= scrollHeight && getCSS('#Autopage_iframe-scroll')) {
  2819. getCSS('#Autopage_iframe-scroll').remove();
  2820.  
  2821. // 再次禁用 iframe 的滚动条
  2822. let newStyle = document.createElement('style'); newStyle.id = 'Autopage_iframe-scroll-hidden';
  2823. newStyle.textContent = 'html, body {overflow: hidden !important;}';
  2824. iframe.contentWindow.document.documentElement.appendChild(newStyle);
  2825. }
  2826. }, false);
  2827.  
  2828. // 加载完成后才继续
  2829. iframe.onload = function() {
  2830. // 暂时禁用 iframe 的滚动条
  2831. let newStyle = document.createElement('style'); newStyle.id = 'Autopage_iframe-scroll-hidden';
  2832. newStyle.textContent = 'html, body {overflow: hidden !important;}';
  2833. iframe.contentWindow.document.documentElement.appendChild(newStyle);
  2834.  
  2835. // 添加历史记录
  2836. if (curSite.history === undefined) {
  2837. if (GM_getValue('menu_history', true)) addHistory(iframe.contentWindow.document, iframe.contentWindow.document.title);
  2838. } else {
  2839. if (curSite.history) addHistory(iframe.contentWindow.document, iframe.contentWindow.document.title);
  2840. }
  2841. // 当前页码 + 1
  2842. if (!curSite.hiddenPN) {
  2843. let autopageNumber = getCSS('#Autopage_number', window.top.document)
  2844. if (autopageNumber) {autopageNumber.textContent = parseInt(autopageNumber.textContent) + 1;}
  2845. }
  2846. }
  2847.  
  2848. // 插入 iframe
  2849. document.documentElement.appendChild(iframe);
  2850. }
  2851. // 翻页类型 6(通过 iframe 获取下一页动态加载内容,只有一个娃)
  2852. function insIframe_(src) {
  2853. // 暂停翻页
  2854. if (!pausePage) return
  2855. pausePage = false
  2856. //console.log(src)
  2857. // 如果不存在,则创建一个 iframe
  2858. let iframe = document.getElementById('Autopage_iframe');
  2859. if (!iframe) {
  2860. iframe = document.createElement('iframe');
  2861. iframe.style = 'position: absolute !important; top: -9999px !important; left: -9999px !important; width: 100% !important; height: 100% !important; border: none !important; z-index: -999 !important; /*visibility: hidden;*/';
  2862. //iframe.sandbox = 'allow-same-origin allow-scripts allow-popups allow-forms';
  2863. iframe.id = 'Autopage_iframe';
  2864. iframe.src = src;
  2865. }
  2866.  
  2867. // 加载完成后才继续
  2868. iframe.onload = function() {
  2869. if (!curSite.pager.loadTime) curSite.pager.loadTime = 300; // 默认 300ms
  2870. let time1 = 0 ,time2 = setInterval(function(){
  2871. let scrollHeight = (iframe.contentWindow.document.documentElement.scrollHeight || iframe.contentWindow.document.body.scrollHeight)/10
  2872. iframe.contentWindow.scrollTo(0, 999999);
  2873. iframe.contentWindow.scrollTo(0, scrollHeight*time1);
  2874. if (++time1 == 10) {
  2875. clearInterval(time2);
  2876. processElems(iframe.contentWindow.document); // 插入/替换元素等
  2877. pausePage = true; // 恢复翻页
  2878. }
  2879. }, curSite.pager.loadTime/10)
  2880. }
  2881.  
  2882. // 插入 iframe(如果已存在则直接改 src)
  2883. if (document.getElementById('Autopage_iframe')) {
  2884. iframe.src = src;
  2885. } else {
  2886. document.documentElement.appendChild(iframe);
  2887. }
  2888. }
  2889.  
  2890.  
  2891. // XHR 后处理结果,插入、替换元素等(适用于翻页类型 1/3/6)
  2892. function processElems(response) {
  2893. if (!curSite.pager.insertP) {curSite.pager.insertP = [curSite.pager.pageE, 5]}
  2894. let pageE = getAll(curSite.pager.pageE, response, response), toE;
  2895. if (curSite.pager.insertP[1] === 5) { // 插入 pageE 列表最后一个元素的后面
  2896. toE = toE5pop(getAll(curSite.pager.insertP[0]));
  2897. } else {
  2898. toE = getOne(curSite.pager.insertP[0]);
  2899. }
  2900. //console.log(curSite.pager.pageE, pageE, curSite.pager.insertP, toE)
  2901.  
  2902. if (pageE.length > 0 && toE) {
  2903. // 如果有插入前函数就执行函数
  2904. if (curSite.function && curSite.function.bF) {
  2905. if (curSite.function.bFp) { // 如果指定了参数
  2906. if (typeof(curSite.function.bF) == 'string') { // 如果是字符串,说明是自定义规则
  2907. pageE = new Function('pageE', 'bFp', 'fun', curSite.function.bF)(pageE, curSite.function.bFp, window.autoPage)
  2908. } else {
  2909. pageE = curSite.function.bF(pageE, curSite.function.bFp);
  2910. }
  2911. } else {
  2912. if (typeof(curSite.function.bF) == 'string') { // 如果是字符串,说明是自定义规则
  2913. pageE = new Function('pageE', 'fun', curSite.function.bF)(pageE, window.autoPage)
  2914. } else {
  2915. pageE = curSite.function.bF(pageE);
  2916. }
  2917. }
  2918. }
  2919.  
  2920. // 插入位置
  2921. let addTo = getAddTo(curSite.pager.insertP[1]);
  2922.  
  2923. // 插入新页面元素
  2924. if (curSite.pager.insertP[1] === 6) { // 插入到目标内部末尾(针对文本,比如小说网页)
  2925. let afterend = '';
  2926. if (curSite.pager.insertP6Br) afterend += '<br/><br/>'
  2927. pageE.forEach(function (one) {afterend += one.innerHTML;});
  2928. toE.insertAdjacentHTML(addTo, afterend);
  2929. } else {
  2930. if (curSite.pager.insertP[1] === 2 || curSite.pager.insertP[1] === 4 || curSite.pager.insertP[1] === 5) pageE.reverse(); // 插入到 [元素内头部]、[目标本身后面] 时,需要反转顺序
  2931. pageE.forEach(function (one) {toE.insertAdjacentElement(addTo, one);});
  2932. }
  2933.  
  2934. // 当前页码 + 1
  2935. pageNum.now = pageNum._now + 1
  2936.  
  2937. // 添加历史记录
  2938. if (curSite.history === undefined) {
  2939. if (GM_getValue('menu_history', true)) addHistory(response);
  2940. } else {
  2941. if (curSite.history) addHistory(response);
  2942. }
  2943.  
  2944. // 替换待替换元素
  2945. if (curSite.pager.replaceE) replaceElems(response);
  2946.  
  2947. // 插入 <script> 标签
  2948. if (curSite.pager.scriptT || curSite.pager.scriptT == 0) {
  2949. switch (curSite.pager.scriptT) {
  2950. case 0: // 下一页的所有 <script> 标签
  2951. insScript('script', response); break;
  2952. case 1: // 下一页的所有 <script> 标签(不包括 src 链接)
  2953. insScript('script:not([src])', response); break;
  2954. case 2: // 下一页主体元素 (pageE) 的同级 <script> 标签
  2955. if (curSite.pager.insertP[1] === 2 || curSite.pager.insertP[1] === 4 || curSite.pager.insertP[1] === 5) pageE.reverse(); // 为了避免 JS 执行顺序反了,还需要再给反转回去
  2956. insScript(null, pageE); break;
  2957. case 3: // 下一页主体元素 (pageE) 的子元素 <script> 标签
  2958. if (curSite.pager.insertP[1] === 2 || curSite.pager.insertP[1] === 4 || curSite.pager.insertP[1] === 5) pageE.reverse(); // 为了避免 JS 执行顺序反了,还需要再给反转回去
  2959. insScript('script:not([src])', pageE); break;
  2960. }
  2961. }
  2962.  
  2963. // 如果有插入后函数就执行函数
  2964. if (curSite.function && curSite.function.aF) {
  2965. if (curSite.function.aFp) { // 如果指定了参数
  2966. if (typeof(curSite.function.aF) == 'string') { // 如果是字符串,说明是自定义规则
  2967. new Function('aFp', 'fun', curSite.function.aF)(curSite.function.aFp, window.autoPage)
  2968. } else {
  2969. curSite.function.aF(curSite.function.aFp);
  2970. }
  2971. } else {
  2972. if (typeof(curSite.function.aF) == 'string') { // 如果是字符串,说明是自定义规则
  2973. new Function('fun', curSite.function.aF)(window.autoPage);
  2974. } else {
  2975. curSite.function.aF();
  2976. }
  2977. }
  2978. }
  2979. } else { // 获取主体元素失败后,尝试重新获取
  2980. console.log(curSite.pager.pageE, pageE, curSite.pager.insertP, toE)
  2981. if (curSite.retry) {
  2982. console.warn('[自动无缝翻页] 获取主体元素失败,尝试重新获取...')
  2983. setTimeout(function(){curSite.pageUrl = '';}, curSite.retry)
  2984. } else {
  2985. console.error('[自动无缝翻页] 获取主体元素失败...')
  2986. // 尝试替换元素看能不能继续翻页下去
  2987. /*if (curSite.pager.replaceE) {
  2988. if (replaceElems(response)) { // 如果替换成功
  2989. console.log('[自动无缝翻页] 获取主体元素失败,尝试替换元素成功!')
  2990. // 当前页码 + 1
  2991. pageNum.now = pageNum._now + 1;
  2992. // 添加历史记录
  2993. if (curSite.history === undefined) {
  2994. if (GM_getValue('menu_history', true)) addHistory(response);
  2995. } else {
  2996. if (curSite.history) addHistory(response);
  2997. }
  2998. } else {console.error('[自动无缝翻页] 获取主体元素失败,尝试替换元素失败...')}
  2999. }*/
  3000. }
  3001. }
  3002. }
  3003. // 通用型插入前函数(加载图片)
  3004. function src_bF(pageE, css) {
  3005. pageE.forEach(function (one) {
  3006. if (css[0] == 0) { // src 图片
  3007. if (one.tagName == 'IMG' && one.getAttribute(css[2])) one.src = one.getAttribute(css[2]);
  3008. one.querySelectorAll(css[1]).forEach(function (now) {
  3009. now.src = now.getAttribute(css[2]);
  3010. });
  3011. } else if (css[0] == 1) { // 背景图片
  3012. if (one.tagName == 'IMG' && one.getAttribute(css[2])) one.style.backgroundImage = 'url("' + one.getAttribute(css[2]) + '")';
  3013. one.querySelectorAll(css[1]).forEach(function (now) {
  3014. now.style.backgroundImage = 'url("' + now.getAttribute(css[2]) + '")';
  3015. });
  3016. }
  3017. });
  3018. return pageE
  3019. }
  3020. // 文字型插入前函数(正则过滤)
  3021. function xs_bF(pageE, reg) {
  3022. pageE.forEach(function (one) {one.innerHTML = one.innerHTML.replace(reg[0], reg[1])});
  3023. return pageE
  3024. }
  3025.  
  3026. // 通用型获取下一页地址(从 元素 中获取页码)
  3027. function getNextE(css) {
  3028. if (!css) css = curSite.pager.nextL;
  3029. let next = getOne(css);
  3030. if (next && next.nodeType === 1 && next.href && next.href.slice(0,4) === 'http' && next.getAttribute('href').slice(0,1) !== '#') {
  3031. if (next.href != curSite.pageUrl) {
  3032. if (curSite.pager.forceHTTPS && location.protocol === 'https:') {
  3033. if (next.href.replace(/^http:/,'https:') === curSite.pageUrl) {
  3034. return false
  3035. }
  3036. curSite.pageUrl = next.href.replace(/^http:/,'https:');
  3037. } else {
  3038. curSite.pageUrl = next.href;
  3039. }
  3040. } else {
  3041. return false
  3042. }
  3043. //console.log(curSite.pageUrl)
  3044. return true
  3045. }
  3046. return false
  3047. }
  3048. // 通用型获取下一页地址(从 元素 中获取页码,URL 替换 page= 参数)
  3049. function getNextEP(css, pf, reg) {
  3050. let nextNum = getOne(css), url = '';
  3051. if (nextNum && nextNum.textContent) {
  3052. nextNum = nextNum.textContent.replaceAll(' ','');
  3053. if (location.search) {
  3054. if (indexOF(pf, 's')) {
  3055. url = location.search.replace(reg, pf + nextNum);
  3056. } else {
  3057. url = location.search + '&' + pf + nextNum;
  3058. }
  3059. } else {
  3060. url = '?' + pf + nextNum;
  3061. }
  3062. url = location.origin + location.pathname + url;
  3063. }
  3064. return url
  3065. }
  3066. // 通用型获取下一页地址(从 元素 中获取页码,URL 替换 pathname 路径)
  3067. function getNextEPN(css, reg, a, b = '') {
  3068. let nextNum = getOne(css), url = '';
  3069. if (nextNum && nextNum.textContent) {
  3070. nextNum = nextNum.textContent.replaceAll(' ','');
  3071. if (location.pathname) {
  3072. if (indexOF(reg)) {
  3073. url = location.pathname.replace(reg, a + nextNum + b);
  3074. } else {
  3075. url = location.pathname + a + nextNum + b;
  3076. }
  3077. } else {
  3078. url = location.pathname + a + nextNum + b;
  3079. }
  3080. url = location.origin + url + location.search;
  3081. }
  3082. return url
  3083. }
  3084. // 通用型获取下一页地址(从 URL 中获取页码,URL 替换 pathname 路径)
  3085. function getNextUPN(urlReg, reg, a, b = '', initP = '2', endP) {
  3086. let nextNum = urlReg.exec(location.pathname);
  3087. if (nextNum) {
  3088. nextNum = String(parseInt(nextNum[0])+1);
  3089. if (endP && (parseInt(nextNum) > parseInt(endP))) return ''
  3090. } else {
  3091. nextNum = initP;
  3092. if (endP && (parseInt(nextNum) >= parseInt(endP))) return ''
  3093. }
  3094. let url = '';
  3095. if (location.pathname) {
  3096. if (indexOF(reg)) {
  3097. url = location.pathname.replace(reg, a + nextNum + b);
  3098. } else {
  3099. url = location.pathname + a + nextNum + b;
  3100. }
  3101. } else {
  3102. url = location.pathname + a + nextNum + b;
  3103. }
  3104. url = location.origin + url + location.search;
  3105. return url
  3106. }
  3107. // 通用型获取下一页地址(从 URL 中获取页码,URL 替换 page= 参数)
  3108. function getNextUP(pf, reg, lp = location.pathname, initP = '2', endP) {
  3109. let nextNum = getSearch(pf.replace('=',''));
  3110. if (nextNum) {
  3111. nextNum = String(parseInt(nextNum)+1);
  3112. if (endP && (parseInt(nextNum) > parseInt(endP))) return ''
  3113. } else {
  3114. nextNum = initP;
  3115. if (endP && (parseInt(nextNum) >= parseInt(endP))) return ''
  3116. }
  3117. let url = '';
  3118. if (location.search) {
  3119. if (indexOF(pf, 's')) {
  3120. url = location.search.replace(reg, pf + nextNum);
  3121. } else {
  3122. url = location.search + '&' + pf + nextNum;
  3123. }
  3124. } else {
  3125. url = '?' + pf + nextNum;
  3126. }
  3127. url = location.origin + lp + url;
  3128. return url
  3129. }
  3130. // 通用型获取下一页地址(从 form input 中获取,返回 GET URL)
  3131. function getNextF(css) {
  3132. let form = getOne(css), value = '';
  3133. if (form) {
  3134. form.querySelectorAll('input[name]').forEach(function(input) {value += input.name + '=' + input.value + '&';}) // 生成表单参数
  3135. value = encodeURI(value.replace(/&$/,'')); // 清理最后一个 & 符号
  3136. if (form.action && value) return (form.action + '?' + value)
  3137. }
  3138. return '';
  3139. }
  3140.  
  3141.  
  3142. // 检查 URL
  3143. function checkURL(func) {
  3144. if (!curSite.pager.nextL) return
  3145. if (typeof curSite.pager.nextL == 'function') {
  3146. let tempUrl = curSite.pager.nextL();
  3147. if (!tempUrl || tempUrl === curSite.pageUrl || tempUrl.slice(0,4) !== 'http') return
  3148. curSite.pageUrl = tempUrl;
  3149. func(curSite.pageUrl);
  3150. } else if (curSite.pager.nextL.search(/^js;/i) === 0) { // 自定义翻页规则中执行 JavaScript 代码的
  3151. try {
  3152. let tempUrl = new Function('fun', curSite.pager.nextL.slice(3))(window.autoPage);
  3153. if (!tempUrl || tempUrl === curSite.pageUrl || tempUrl.slice(0,4) !== 'http') return
  3154. curSite.pageUrl = tempUrl;
  3155. func(curSite.pageUrl);
  3156. } catch (e) {
  3157. console.error('[自动无缝翻页] - 当前网页规则 "nextL" 内 JS 代码有误,请检查!', e);
  3158. }
  3159. } else if (getNextE()) {
  3160. func(curSite.pageUrl);
  3161. }
  3162. //console.log(curSite.pageUrl);
  3163. }
  3164. // 替换元素
  3165. function replaceElems(pageE, o = curSite.pager.replaceE, r = curSite.pager.replaceE) {
  3166. let oE = getAll(o),
  3167. rE = getAll(r, pageE, pageE);
  3168. if (oE.length != 0 && rE.length != 0 && oE.length === rE.length) {
  3169. for (let i = 0; i < oE.length; i++) {
  3170. oE[i].outerHTML = rE[i].outerHTML;
  3171. }
  3172. return true
  3173. }
  3174. return false
  3175. }
  3176. // 添加历史记录
  3177. function addHistory(pageE, title, url) {
  3178. if (!curSite.pageUrl) return
  3179. // 对于自带类似功能 或者 覆盖了 history 原生函数的网站,则跳过不再添加历史记录
  3180. if (window.top.history.toString() !== '[object History]') return
  3181. title = title || ((pageE.querySelector('title')) ? pageE.querySelector('title').textContent : window.top.document.title);
  3182. url = url || curSite.pageUrl;
  3183. window.top.document.Autopage_nowUrl = curSite.pageUrl;
  3184. // 对于下一页 URL 和当前网页 URL 的协议不同时,跳过
  3185. if (url.indexOf(window.top.location.protocol) === -1) return
  3186. window.top.history.pushState('Autopage_history', title, url);
  3187. window.top.document.title = title;
  3188. }
  3189. // 插入 <Script>
  3190. function insScript(selector, contextNode = document, toE = document.body) {
  3191. let scriptElems = contextNode;
  3192. if (selector) {
  3193. if (contextNode instanceof Array) {
  3194. scriptElems = []; contextNode.forEach(function (one) {scriptElems = scriptElems.concat(getAll(selector, one, one));})
  3195. } else {
  3196. scriptElems = getAll(selector, contextNode, contextNode);
  3197. }
  3198. }
  3199.  
  3200. scriptElems.forEach(function (one) {
  3201. if (one.tagName === 'SCRIPT') {
  3202. if (one.src) {
  3203. toE.appendChild(document.createElement('script')).src = one.src;
  3204. } else {
  3205. toE.appendChild(document.createElement('script')).textContent = one.textContent;//.replaceAll('document.write', '');
  3206. }
  3207. }
  3208. });
  3209. }
  3210. // 插入 <Style>
  3211. function insStyle(style) {
  3212. document.documentElement.appendChild(document.createElement('style')).textContent = style;
  3213. }
  3214.  
  3215.  
  3216. // 获取元素(CSS/Xpath)来自:https://github.com/machsix/Super-preloader
  3217. function getCSS(css, contextNode = document) {
  3218. return contextNode.querySelector(css);
  3219. }
  3220. function getAllCSS(css, contextNode = document) {
  3221. return [].slice.call(contextNode.querySelectorAll(css));
  3222. }
  3223. function getXpath(xpath, contextNode, doc = document) {
  3224. contextNode = contextNode || doc;
  3225. try {
  3226. const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  3227. // 应该总是返回一个元素节点
  3228. return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue;
  3229. } catch (err) {
  3230. throw new Error(`无效 Xpath: ${xpath}`);
  3231. }
  3232. }
  3233. function getAllXpath(xpath, contextNode, doc = document) {
  3234. contextNode = contextNode || doc;
  3235. const result = [];
  3236. try {
  3237. const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3238. for (let i = 0; i < query.snapshotLength; i++) {
  3239. const node = query.snapshotItem(i);
  3240. // 如果是 Element 节点
  3241. if (node.nodeType === 1) result.push(node);
  3242. }
  3243. } catch (err) {
  3244. throw new Error(`无效 Xpath: ${xpath}`);
  3245. }
  3246. return result;
  3247. }
  3248. function getOne(selector, contextNode = undefined, doc = document) {
  3249. if (!selector) return;
  3250. contextNode = contextNode || doc;
  3251. if (selector.slice(0,1) === '/' || selector.slice(0,2) === './' || selector.slice(0,3) === 'id(') {
  3252. return getXpath(selector, contextNode, doc);
  3253. } else {
  3254. return getCSS(selector, contextNode);
  3255. }
  3256. }
  3257. function getAll(selector, contextNode = undefined, doc = document) {
  3258. if (!selector) return [];
  3259. contextNode = contextNode || doc;
  3260. if (selector.slice(0,1) === '/' || selector.slice(0,2) === './' || selector.slice(0,3) === 'id(') {
  3261. return getAllXpath(selector, contextNode, doc);
  3262. } else {
  3263. return getAllCSS(selector, contextNode);
  3264. }
  3265. }
  3266. function createDocumentByString(e) {
  3267. if (e) {
  3268. if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml');
  3269. var t;
  3270. try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {}
  3271. if (t) return t;
  3272. if (document.implementation.createHTMLDocument) {
  3273. t = document.implementation.createHTMLDocument('ADocument');
  3274. } else {
  3275. 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) {}
  3276. }
  3277. if (t) {
  3278. var r = document.createRange(),
  3279. n = r.createContextualFragment(e);
  3280. r.selectNodeContents(document.body);
  3281. t.body.appendChild(n);
  3282. 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);
  3283. return t;
  3284. }
  3285. } else console.error('没有找到要转成 DOM 的字符串');
  3286. }
  3287.  
  3288.  
  3289. // 强制新标签页打开链接
  3290. function forceTarget() {
  3291. if (curSite.blank === 1) {
  3292. document.head.appendChild(document.createElement('base')).target = '_blank';
  3293.  
  3294. } else {
  3295. let d;
  3296. if (curSite.blank === 2) {
  3297. d = document.body
  3298. } else if (curSite.blank === 3) {
  3299. let dd = toE5pop(getAll(curSite.pager.pageE));
  3300. if (dd && dd.parentElement != null) d = dd.parentElement
  3301. }
  3302. if (!d) return
  3303.  
  3304. function forceTarget_(target, e){
  3305. if (target.href && target.target != '_blank' && !(target.getAttribute('onclick')) && target.href.slice(0,4) == 'http' && target.getAttribute('href').slice(0,1) != '#') {
  3306. e.preventDefault(); // 阻止默认打开链接事件
  3307. window.GM_openInTab(target.href, {active: true,insert: true,setParent: true});
  3308. }
  3309. }
  3310. d.addEventListener('click', function(e) {
  3311. //console.log(e.target.tagName, e.path)
  3312. if (e.target.tagName === 'A') {
  3313. forceTarget_(e.target, e);
  3314. } else {
  3315. let path = e.path || e.composedPath();
  3316. for (let i = 1; i < path.length - 4; i++) {if (path[i].tagName === 'A') {forceTarget_(path[i], e); break;}}
  3317. }
  3318. });
  3319. }
  3320. }
  3321. // 初始化事件
  3322. /*function initEvent() {
  3323. if (curSite.initE[1] == undefined) curSite.initE[1] = 500;
  3324. setTimeout(function(){getAllCSS(curSite.initE[0]).forEach(function (o) {o.innerHTML = o.innerHTML;});}, curSite.initE[1])
  3325. }*/
  3326. // 判断元素是否隐藏(隐藏返回 true)
  3327. function isHidden(el){
  3328. return (el.offsetParent === null);
  3329. }
  3330. // 判断是否为手机版(是则返回 true)
  3331. function isMobile(){
  3332. 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));
  3333. }
  3334. // 用以自定义规则中设置 urlC = true
  3335. function isUrlC(){
  3336. urlC = true;
  3337. }
  3338. // 判断 URL 是否存在指定文本
  3339. function indexOF(e, l = 'p', low = true){
  3340. switch (l) {
  3341. case 'h':
  3342. l = location.href; break;
  3343. case 'p':
  3344. l = location.pathname; break;
  3345. case 's':
  3346. l = location.search; break;
  3347. }
  3348. //console.log(l,e,l.indexOf(e))
  3349. if (e instanceof RegExp) {
  3350. if (e.test(l)) return true
  3351. } else {
  3352. if (low) {e = e.toLowerCase(); l = l.toLowerCase();} // 全部转为小写(即不区分大小写)
  3353. if (l.indexOf(e) != -1) return true
  3354. }
  3355. return false
  3356. }
  3357. // 获取 Search 指定参数
  3358. function getSearch(variable) {
  3359. let query = window.location.search.substring(1),
  3360. vars = query.split('&');
  3361. for (var i=0;i<vars.length;i++) {
  3362. var pair = vars[i].split('=');
  3363. if(pair[0] == variable){return pair[1];}
  3364. }
  3365. return '';
  3366. }
  3367. // 启用/禁用 (当前网站)
  3368. function menu_disable(type) {
  3369. switch(type) {
  3370. case 'check':
  3371. return check(); break;
  3372. case 'add':
  3373. add(); break;
  3374. case 'del':
  3375. del(); break;
  3376. }
  3377.  
  3378. function check() { // 存在返回真,不存在返回假
  3379. if (GM_getValue('menu_disable').indexOf(location.hostname) == -1) return false // 不存在返回假
  3380. return true
  3381. }
  3382.  
  3383. function add() {
  3384. if (check()) return
  3385. let list = GM_getValue('menu_disable'); // 读取网站列表
  3386. list.push(location.hostname); // 追加网站域名
  3387. GM_setValue('menu_disable', list); // 写入配置
  3388. location.reload(); // 刷新网页
  3389. }
  3390.  
  3391. function del() {
  3392. if (!check()) return
  3393. let list = GM_getValue('menu_disable'), // 读取网站列表
  3394. index = list.indexOf(location.hostname);
  3395. list.splice(index, 1); // 删除网站域名
  3396. GM_setValue('menu_disable', list); // 写入配置
  3397. location.reload(); // 刷新网页
  3398. }
  3399. }
  3400. // 左键双击网页空白处暂停翻页
  3401. function pausePageEvent() {
  3402. if (!GM_getValue('menu_pause_page')) return
  3403. if (curSite.SiteTypeID === 0) return
  3404. if (curSite.pager && curSite.pager.type == 5) window.top.document.xiu_pausePage = pausePage
  3405. document.body.addEventListener('dblclick', function () {
  3406. if (pausePage) {GM_notification({text: `❌ 已暂停本页 [自动无缝翻页]\n (再次双击可恢复)`, timeout: 2000});} else {GM_notification({text: `✅ 已恢复本页 [自动无缝翻页]\n (再次双击可暂停)`, timeout: 2000});}
  3407. pausePage = !pausePage;
  3408. if (curSite.pager && curSite.pager.type == 5) window.top.document.xiu_pausePage = pausePage
  3409. });
  3410. }
  3411. // 自定义翻页规则
  3412. function customRules() {
  3413. if (getCSS('#Autopage_customRules')) return
  3414.  
  3415. let customRules = JSON.stringify(GM_getValue('menu_customRules', {}), null, '\t');
  3416. if (customRules == '{}') customRules = '{\n\t\n}'; // 引导用户插入位置
  3417. 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;">
  3418. <h3 style="font-size: 22px !important;"><strong># 自定义翻页规则(优先级最高,但前提是 "规则名" 不能重复)-【将规则插入默认的 <code>{ }</code> 中间】</strong></h3>
  3419. <details><summary style="cursor: pointer;"><kbd><strong>「 点击展开 查看规则示例 」(为了避免需要的时候还要找,我干脆把常用规则都一股脑塞进去了)</strong></kbd></summary>
  3420. <ul style="list-style: disc !important; margin-left: 35px !important;">
  3421. <li>翻页规则为 JSON 格式,因此大家需要多少<strong>了解一点 JSON 的基本格式</strong>(主要就是逗号、转义、双引号等)。</li>
  3422. <li>具体的翻页规则说明、示例,为了方便更新及补充,我都写到 <strong><a href="https://github.com/XIU2/UserScript/issues/176" target="_blank">Github</a></strong> 里面了。</li>
  3423. <li>脚本会自动格式化规则,因此<strong>无需手动缩进、换行</strong>,只需把规则<strong>插入默认的 { } 中间</strong>即可。</li>
  3424. </ul>
  3425. <pre>
  3426. // 下面示例是把所有规则都塞进去了,但实际上大都用不上,大多数网站只需要像第一个 "aaa" 这样的规则
  3427. // "aaa" 是规则名,唯一!不能重复!否则会被 外置/内置规则 覆盖,支持中文等各种字符
  3428. // "url" 是用来控制哪些网站中页面适用该规则,省略后代表该规则应用于全站
  3429. // "scrollD" 是用来控制翻页敏感度的(越大就越早触发翻页,访问速度慢的网站需要调大,可省略(注意逗号),默认 1500)
  3430. {
  3431. "aaa": {
  3432. "host": "aaaa",
  3433. "url": "xxxx",
  3434. "pager": {
  3435. "nextL": "xxxx",
  3436. "pageE": "xxxx",
  3437. "replaceE": "xxxx",
  3438. "scrollD": 1500
  3439. }
  3440. },
  3441. "bbb": {
  3442. "host": ["bbb1.com", "bbb2.com"],
  3443. "url": "/^\\/s$/",
  3444. "style": ".aaaa {display: none !important;}",
  3445. "blank": 1,
  3446. "hiddenPN": true,
  3447. "history": false,
  3448. "thread": true,
  3449. "iframe": true,
  3450. "pager": {
  3451. "type": 1,
  3452. "nextL": "id('page')//a[contains(text(),'下一页')] || id('page2')//a[text()='下一页']",
  3453. "pageE": "aaa",
  3454. "insertP": [".bbb",3],
  3455. "replaceE": ".page",
  3456. "scriptT": 1,
  3457. "forceHTTPS": true,
  3458. "interval": 500,
  3459. "scrollD": 1500
  3460. },
  3461. "function": {
  3462. "bF": "return fun.src_bF(pageE, [0,'img[data-src]','data-src'])",
  3463. "aF": "document.body.appendChild(document.createElement('script')).textContent = 'xxx'"
  3464. }
  3465. },
  3466. "这里也可以用中文": {
  3467. "host": "/\\.ccc\\.com/",
  3468. "url": "fun.isUrlC(); return (fun.lp() == '/' || fun.indexOF('/s') || fun.isMobile())",
  3469. "pager": {
  3470. "type": 2,
  3471. "nextL": "#autopbn",
  3472. "nextText": "下一页",
  3473. "nextTextOf": "下一页",
  3474. "isHidden": true,
  3475. "interval": 1000,
  3476. "scrollD": 1500
  3477. }
  3478. }
  3479. }
  3480. </pre></details>
  3481. <details><summary style="cursor: pointer;"><kbd><strong>「 点击展开 查看所有规则 」(可 Ctrl+F 搜索规则名、域名等信息来寻找,规则顺序为:自定义、外置、内置)</strong></kbd></summary>
  3482. <pre style="overflow: scroll !important;height: 500px !important;">
  3483. ${JSON.stringify(DBSite, null, '\t')}
  3484. </pre></details>
  3485.  
  3486. <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>
  3487. <button id="Autopage_customRules_save" style="margin-right: 20px !important;">保存并刷新</button><button id="Autopage_customRules_cancel">取消修改</button>
  3488. </div>`
  3489. document.documentElement.insertAdjacentHTML('beforeend', _html);
  3490. document.documentElement.style.overflow = document.body.style.overflow = 'hidden';
  3491. // 点击事件
  3492. getCSS('#Autopage_customRules_save').onclick = function () {
  3493. customRules = getCSS('#Autopage_customRules_textarea').value;
  3494. //console.log(customRules)
  3495. if (!customRules) customRules = '{}'
  3496. try {
  3497. customRules = JSON.parse(customRules)
  3498. //console.log(customRules)
  3499. GM_setValue('menu_customRules', customRules)
  3500. location.reload();
  3501. } catch (e) {
  3502. console.error('自定义规则存在格式错误:\n' + e + '\n\n格式错误一般为:\n· 逗号:每组 {} 中的最后一个值末尾不能加逗号\n\n· 转义:如果正则表达式中含有转义符 \\ 那就要对其再次转义为 \\\\\n\n· 双引号:规则中冒号左右的内容都需要加上双引号,如果内容中含有双引号则需要对双引号转义(即 \\" 这样),或改为单引号')
  3503. window.alert('自定义规则存在格式错误:\n' + e + '\n\n格式错误一般为:\n· 逗号:每组 {} 中的最后一个值末尾不能加逗号\n\n· 转义:如果正则表达式中含有转义符 \\ 那就要对其再次转义为 \\\\\n\n· 双引号:规则中冒号左右的内容都需要加上双引号,如果内容中含有双引号则需要对双引号转义(即 \\" 这样),或改为单引号');
  3504. }
  3505. }
  3506. getCSS('#Autopage_customRules_cancel').onclick = function () {document.documentElement.style.overflow = document.body.style.overflow = ''; getCSS('#Autopage_customRules').remove();}
  3507. }
  3508. // 显示页码
  3509. function pageNumber(type) {
  3510. 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}
  3511. let status = getCSS('#Autopage_number');
  3512. switch (type) {
  3513. case 'add':
  3514. add(); break;
  3515. case 'del':
  3516. del(); break;
  3517. case 'set':
  3518. set(); break;
  3519. }
  3520.  
  3521. function add(){
  3522. if (status) {
  3523. if (status.style.display === 'none') {status.style.display = 'flex';}
  3524. return
  3525. }
  3526. // 插入网页
  3527. 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>`,
  3528. _html = `<div id="Autopage_number" title="1. 此为 [当前页码](仅指脚本翻了多少页,并非实际页码,该页码可在脚本菜单中关闭)&#10;&#10;2. 鼠标 [左键] 点击此处可 [临时暂停翻页](再次点击可恢复)&#10;&#10;3. 鼠标 [右键] 点击此处可 [回到顶部]">${pageNum._now}</div>`
  3529. document.documentElement.insertAdjacentHTML('beforeend', _style + _html);
  3530. // 解决 远景论坛 会清理掉前面插入的 CSS 样式的问题
  3531. if (location.hostname === 'bbs.pcbeta.com') {setTimeout(function(){document.documentElement.insertAdjacentHTML('beforeend', _style);}, 500);}
  3532. if (curSite.pager && curSite.pager.type == 5) window.top.document.xiu_pausePage = pausePage
  3533. // 左键点击事件(临时暂停翻页)
  3534. getCSS('#Autopage_number').onclick = function(e) {
  3535. if (pausePage) {this.style = 'color: #FF5722 !important; font-style: italic !important;';} else {this.style = '';}
  3536. pausePage = !pausePage;
  3537. if (curSite.pager && curSite.pager.type == 5) window.top.document.xiu_pausePage = pausePage
  3538. e.preventDefault();
  3539. e.stopPropagation();
  3540. return false
  3541. };
  3542. // 右键点击事件(回到顶部)
  3543. getCSS('#Autopage_number').oncontextmenu = function(e) {
  3544. window.scrollTo(0,0);
  3545. e.preventDefault();
  3546. e.stopPropagation();
  3547. return false
  3548. };
  3549. status = getCSS('#Autopage_number');
  3550. set();
  3551. }
  3552. // 监听储存当前页码的对象值的变化
  3553. function set(){
  3554. Object.defineProperty(pageNum, 'now', {
  3555. set: function(value) {
  3556. this._now = value;
  3557. if (status) status.textContent = value;
  3558. }
  3559. });
  3560. }
  3561. function del(){
  3562. if (!status) return
  3563. status.style.display = 'none';
  3564. }
  3565. }
  3566. // 菜单开关
  3567. function menu_switch(menu_status, Name, Tips) {
  3568. if (menu_status === true){
  3569. GM_setValue(Name, false);
  3570. } else {
  3571. GM_setValue(Name, true);
  3572. }
  3573. if (Name === 'menu_page_number') {
  3574. if (menu_status === true){pageNumber('del');} else {pageNumber('add');}
  3575. registerMenuCommand(); // 重新注册脚本菜单
  3576. } else {
  3577. location.reload();}
  3578. };
  3579. // 生成 SiteTypeID
  3580. function setSiteTypeID() {
  3581. let num = 0
  3582. for (let val in DBSite) {
  3583. DBSite[val].SiteTypeID = num = num + 1;
  3584. }
  3585. }
  3586. // 获取 Cookie
  3587. function getCookie(name) {
  3588. if (!name) return ''
  3589. let arr = document.cookie.split(';');
  3590. name += '='
  3591. for (let i=0; i<arr.length; i++) {
  3592. let now = arr[i].trim();
  3593. if (now.indexOf(name) == 0) return now.substring(name.length, now.length);
  3594. }
  3595. return '';
  3596. }
  3597. // 插入位置
  3598. function getAddTo(num) {
  3599. switch (num) {
  3600. case 1:
  3601. return 'beforebegin'; break;
  3602. case 2:
  3603. return 'afterbegin'; break;
  3604. case 3:
  3605. case 6:
  3606. return 'beforeend'; break;
  3607. case 4:
  3608. case 5:
  3609. return 'afterend'; break;
  3610. }
  3611. }
  3612. // 插入位置 5 时,排除 <script> <style> <link> 标签
  3613. function toE5pop(a) {
  3614. if (a.length === 0) return
  3615. let b = a.pop();
  3616. if (b.tagName === 'SCRIPT' || b.tagName === 'STYLE' || b.tagName === 'LINK') {
  3617. return toE5pop(a);
  3618. }
  3619. return b
  3620. }
  3621. // 滚动条事件
  3622. function windowScroll(fn1) {
  3623. var beforeScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  3624. fn = fn1 || function () {};
  3625. setTimeout(function () { // 延时 1 秒执行,避免刚载入到页面就触发翻页事件
  3626.  
  3627. // 避免网页内容太少,高度撑不起来,不显示滚动条而无法触发翻页事件
  3628. let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop,
  3629. scrollHeight = window.innerHeight || document.documentElement.clientHeight
  3630. if (scrollTop === 0 && document.documentElement.scrollHeight === scrollHeight) {
  3631. insStyle(`html, body {min-height: ${document.documentElement.scrollHeight+10}px;}`)
  3632. }
  3633.  
  3634. window.addEventListener('scroll', function (e) {
  3635. var afterScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  3636. delta = afterScrollTop - beforeScrollTop;
  3637. if (delta == 0) return false;
  3638. fn(delta > 0 ? 'down' : 'up', e);
  3639. beforeScrollTop = afterScrollTop;
  3640. }, false);
  3641. }, 1000)
  3642. }
  3643. // 自定义 urlchange 事件(用来监听 URL 变化)
  3644. function addUrlChangeEvent() {
  3645. history.pushState = ( f => function pushState(){
  3646. var ret = f.apply(this, arguments);
  3647. window.dispatchEvent(new Event('pushstate'));
  3648. window.dispatchEvent(new Event('urlchange'));
  3649. return ret;
  3650. })(history.pushState);
  3651.  
  3652. history.replaceState = ( f => function replaceState(){
  3653. var ret = f.apply(this, arguments);
  3654. window.dispatchEvent(new Event('replacestate'));
  3655. window.dispatchEvent(new Event('urlchange'));
  3656. return ret;
  3657. })(history.replaceState);
  3658.  
  3659. window.addEventListener('popstate',()=>{
  3660. window.dispatchEvent(new Event('urlchange'))
  3661. });
  3662. }
  3663. })();