自动无缝翻页

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

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

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