自动无缝翻页

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

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

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