自动无缝翻页

⭐无缝衔接下一页内容到网页底部(类似瀑布流)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、微博、NGA、V2EX、B 站(Bilibili)、煎蛋网、龙的天空、起点中文、千图网、千库网、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-15 提交的版本,查看 最新版本

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