自动无缝翻页

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

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