自动无缝翻页

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

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