自动无缝翻页

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

当前为 2022-03-29 提交的版本,查看 最新版本

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