自动无缝翻页

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

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

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