自动无缝翻页

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

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