自动无缝翻页

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

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

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址