自动无缝翻页

无缝拼接下一页内容,目前支持:[所有使用「Discuz!、Flarum、DUX(WordPress)」的网站]、百度、谷歌、必应、贴吧、豆瓣、微博、千图网、Pixabay、3DM、游侠网、游民星空、Steam 创意工坊、423Down、Sordum、不死鸟、小众软件、六音软件、微当下载、异次元软件、老殁殁漂遥、异星软件空间、动漫狂、漫画DB、HiComic(嗨漫画)、古风漫画网、砂之船动漫家、高清电台、宝书网、SrkBT、RARBG、PubMed、AfreecaTV、GreasyFork、CS.RIN.RU、Crackhub213、FitGirl Repacks...

目前为 2021-08-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name 自动无缝翻页
  3. // @version 1.7.3
  4. // @author X.I.U
  5. // @description 无缝拼接下一页内容,目前支持:[所有使用「Discuz!、Flarum、DUX(WordPress)」的网站]、百度、谷歌、必应、贴吧、豆瓣、微博、千图网、Pixabay、3DM、游侠网、游民星空、Steam 创意工坊、423Down、Sordum、不死鸟、小众软件、六音软件、微当下载、异次元软件、老殁殁漂遥、异星软件空间、动漫狂、漫画DB、HiComic(嗨漫画)、古风漫画网、砂之船动漫家、高清电台、宝书网、SrkBT、RARBG、PubMed、AfreecaTV、GreasyFork、CS.RIN.RU、Crackhub213、FitGirl Repacks...
  6. // @match *://*/*
  7. // @connect www.gamersky.com
  8. // @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_registerMenuCommand
  11. // @grant GM_openInTab
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_notification
  15. // @noframes
  16. // @license GPL-3.0 License
  17. // @run-at document-end
  18. // @namespace https://github.com/XIU2/UserScript
  19. // @supportURL https://github.com/XIU2/UserScript
  20. // @homepageURL https://github.com/XIU2/UserScript
  21. // ==/UserScript==
  22.  
  23. (function() {
  24. 'use strict';
  25. var webType, curSite = {SiteTypeID: 0}, pausePage = true;
  26. // 目前支持的网站(仅单独规则的,不包含通用规则的网站)
  27. const websiteList = ['www.baidu.com', 'www.google.com', 'www.bing.com', 'cn.bing.com', 'tieba.baidu.com', 'movie.douban.com', 'weibo.com', 'www.58pic.com', 'pixabay.com',
  28. 'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', 'steamcommunity.com',
  29. 'www.423down.com', 'www.sordum.org', 'iao.su', 'www.appinn.com', 'www.sixyin.com', 'www.weidown.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com',
  30. 'www.cartoonmad.com', 'www.cartoonmad.cc', 'www.manhuadb.com', 'www.hicomic.net', 'www.gufengmh8.com', 'www.szcdmj.com',
  31. 'gaoqing.fm', 'www.baoshuu.com', 'm.baoshuu.com', 'skrbtba.xyz','rarbgprx.org',
  32. 'pubmed.ncbi.nlm.nih.gov', 'www.afreecatv.com', 'greasyfork.org',
  33. 'cs.rin.ru', 'crackhub.site', 'fitgirl-repacks.site'];
  34.  
  35. if (GM_getValue('menu_disable') == null){GM_setValue('menu_disable', [])};
  36. if (GM_getValue('menu_discuz_thread_page') == null){GM_setValue('menu_discuz_thread_page', true)};
  37. if (GM_getValue('menu_pause_page') == null){GM_setValue('menu_pause_page', true)};
  38. // 注册脚本菜单
  39. if (menu_disable('check')) { // 当前网站是否已存在禁用列表中
  40. GM_registerMenuCommand('❌ 已禁用 (点击对当前网站启用)', function(){menu_disable('del')});
  41. return
  42. } else {
  43. if (websiteList.indexOf(location.host) > -1) {
  44. webType = 1; console.info('[自动无缝翻页] - 其他网站(独立规则)'); // 其他网站(独立规则)
  45. } else if (document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]') || document.getElementById('ft') && document.getElementById('ft').textContent.indexOf('Discuz!') > -1) {
  46. webType = 2; console.info('[自动无缝翻页] - Discuz! 论坛'); // 所有 Discuz! 论坛
  47. } else if (document.getElementById('flarum-loading')) {
  48. webType = 3; console.info('[自动无缝翻页] - Flarum 论坛'); // 所有 Flarum 论坛
  49. } else if (document.querySelector('link[href*="themes/dux" i], script[src*="themes/dux" i]')) {
  50. webType = 4; console.info('[自动无缝翻页] - 使用 WordPress DUX 主题的网站'); // 所有使用 WordPress DUX 主题的网站
  51. } else {
  52. 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});});
  53. console.info('[自动无缝翻页] - 不支持当前网站,欢迎申请支持:https://github.com/XIU2/UserScript / https://greasyfork.org/zh-CN/scripts/419215/feedback');
  54. return
  55. }
  56. GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')});
  57. if (webType === 2 || location.host === 'cs.rin.ru') {
  58. GM_registerMenuCommand(`${GM_getValue('menu_discuz_thread_page')?'✅':'❌'} 帖子内自动翻页 (仅论坛)`, function(){menu_switch(GM_getValue('menu_discuz_thread_page'), 'menu_discuz_thread_page', 'Discuz! 论坛帖子内翻页')});
  59. }
  60. GM_registerMenuCommand(`${GM_getValue('menu_pause_page')?'✅':'❌'} 左键双击网页空白处暂停翻页`, function(){menu_switch(GM_getValue('menu_pause_page'), 'menu_pause_page', '左键双击网页空白处暂停翻页')});
  61. }
  62. 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});});
  63.  
  64.  
  65. /*
  66. 自动翻页规则
  67. type:
  68. 1 = 由脚本实现自动无缝翻页
  69. 2 = 网站自带了自动无缝翻页功能,只需要点击下一页按钮即可
  70. nextText: 按钮文本,当按钮文本 = 该文本时,才会点击按钮加载下一页(避免一瞬间加载太多次下一页)
  71. nextTextOf: 按钮文本的一部分,当按钮文本包含该文本时,才会点击按钮加载下一页(避免一瞬间加载太多次下一页)
  72. nextHTML: 按钮内元素,当按钮内元素 = 该元素内容时,才会点击按钮加载下一页(避免一瞬间加载太多次下一页)
  73. intervals: 点击间隔时间,对于没有按钮文字变化的按钮,可以手动指定间隔时间,单位:ms
  74. 3 = 依靠元素距离可视区域底部的距离来触发翻页
  75. 4 = 部分简单的动态加载类网站(暂时)
  76. insertPosition:
  77. 1 = 插入该元素本身的前面;
  78. 2 = 插入该元素当中,第一个子元素前面;
  79. 3 = 插入该元素当中,最后一个子元素后面;
  80. 4 = 插入该元素本身的后面;
  81. scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页),一般是访问网页速度越慢,该值就需要越大(如果 Type = 3,则相反)
  82. function:
  83. before = 插入前执行函数;
  84. after = 插入后执行函数;
  85. parameter = 参数
  86. */
  87. let DBSite = {
  88. discuz_forum: {
  89. SiteTypeID: 0,
  90. pager: {
  91. type: 2,
  92. nextLink: '#autopbn',
  93. nextText: '下一页 »',
  94. scrollDelta: 1000
  95. }
  96. },
  97. discuz_thread: {
  98. SiteTypeID: 0,
  99. pager: {
  100. type: 1,
  101. nextLink: '//a[@class="nxt"][@href] | //a[@class="next"][@href]',
  102. pageElement: 'css;#postlist > div[id^="post_"]',
  103. insertPosition: ['css;#postlist', 3],
  104. replaceE: 'css;.pg, .pages',
  105. scrollDelta: 1000
  106. }
  107. },
  108. discuz_search: {
  109. SiteTypeID: 0,
  110. pager: {
  111. type: 1,
  112. nextLink: '//a[@class="nxt"][@href] | //a[@class="next"][@href]',
  113. pageElement: 'css;#threadlist > ul',
  114. insertPosition: ['css;#threadlist', 3],
  115. replaceE: 'css;.pg, .pages',
  116. scrollDelta: 1000
  117. }
  118. },
  119. discuz_guide: {
  120. SiteTypeID: 0,
  121. pager: {
  122. type: 1,
  123. nextLink: '//a[@class="nxt"][@href] | //a[@class="next"][@href]',
  124. pageElement: 'css;#threadlist table > tbody[id^="normalthread_"]',
  125. insertPosition: ['id("threadlist")//table/tbody[starts-with(@id, "normalthread_")]/parent::table', 3],
  126. replaceE: 'css;.pg, .pages',
  127. scrollDelta: 1000
  128. }
  129. },
  130. discuz_youspace: {
  131. SiteTypeID: 0,
  132. pager: {
  133. type: 1,
  134. nextLink: '//a[@class="nxt"][@href] | //a[@class="next"][@href]',
  135. pageElement: 'css;tbody > tr:not(.th)',
  136. insertPosition: ['css;tbody', 3],
  137. replaceE: 'css;.pg, .pages',
  138. scrollDelta: 1000
  139. }
  140. },
  141. discuz_collection: {
  142. SiteTypeID: 0,
  143. pager: {
  144. type: 1,
  145. nextLink: '//a[@class="nxt"][@href] | //a[@class="next"][@href]',
  146. pageElement: 'css;#ct .bm_c table > tbody',
  147. insertPosition: ['css;#ct .bm_c table', 3],
  148. replaceE: 'css;.pg, .pages',
  149. scrollDelta: 1000
  150. }
  151. },
  152. flarum: {
  153. SiteTypeID: 0,
  154. pager: {
  155. type: 2,
  156. nextLink: '.DiscussionList-loadMore > button[title]',
  157. scrollDelta: 1000
  158. }
  159. },
  160. dux: {
  161. SiteTypeID: 0,
  162. pager: {
  163. type: 1,
  164. nextLink: '//li[@class="next-page"]/a[@href]',
  165. pageElement: 'css;.content > article',
  166. insertPosition: ['css;.content > .pagination', 1],
  167. replaceE: 'css;.content > .pagination',
  168. scrollDelta: 1500
  169. },
  170. function: {
  171. before: dux_functionBefore
  172. }
  173. },
  174. baidu: {
  175. SiteTypeID: 0,
  176. pager: {
  177. type: 1,
  178. nextLink: 'id("page")//a[contains(text(),"下一页")][@href]',
  179. pageElement: 'css;#content_left > *',
  180. insertPosition: ['css;#content_left', 3],
  181. replaceE: 'css;#page',
  182. scrollDelta: 1200
  183. }
  184. },
  185. google: {
  186. SiteTypeID: 0,
  187. pager: {
  188. type: 1,
  189. nextLink: 'id("pnnext")[@href]',
  190. pageElement: 'css;#res > *',
  191. insertPosition: ['css;#res', 3],
  192. replaceE: 'id("navcnt") | id("rcnt")//div[@role="navigation"]',
  193. scrollDelta: 2000
  194. }
  195. },
  196. bing: {
  197. SiteTypeID: 0,
  198. pager: {
  199. type: 1,
  200. nextLink: '//a[contains(@class,"sb_pagN")][@href]',
  201. pageElement: 'css;#b_results > li:not(.b_msg):not(.b_pag):not(#mfa_root)',
  202. insertPosition: ['css;#b_results > .b_pag', 1],
  203. replaceE: 'css;#b_results > .b_pag',
  204. scrollDelta: 1500
  205. }
  206. },
  207. baidu_tieba: {
  208. SiteTypeID: 0,
  209. pager: {
  210. type: 1,
  211. nextLink: '//a[@class="next pagination-item "][@href]',
  212. pageElement: 'css;#thread_list > li',
  213. insertPosition: ['css;#thread_list', 3],
  214. replaceE: 'css;#frs_list_pager',
  215. scrollDelta: 1500
  216. },
  217. function: {
  218. before: baidu_tieba_functionBefore
  219. }
  220. },
  221. baidu_tieba_post: {
  222. SiteTypeID: 0,
  223. pager: {
  224. type: 1,
  225. nextLink: '//li[contains(@class,"pb_list_pager")]/a[contains(text(),"下一页")][@href]',
  226. pageElement: 'css;#j_p_postlist > div',
  227. insertPosition: ['css;#j_p_postlist', 3],
  228. replaceE: 'css;li.pb_list_pager',
  229. scrollDelta: 1000
  230. }
  231. },
  232. baidu_tieba_search: {
  233. SiteTypeID: 0,
  234. pager: {
  235. type: 1,
  236. nextLink: '//a[@class="next"][@href]',
  237. pageElement: 'css;.s_post_list > .s_post',
  238. insertPosition: ['css;.s_post_list', 3],
  239. replaceE: 'css;.pager.pager-search',
  240. scrollDelta: 1000
  241. }
  242. },
  243. douban_subject_comments: {
  244. SiteTypeID: 0,
  245. pager: {
  246. type: 1,
  247. nextLink: '//a[@class="next"][@href]',
  248. pageElement: 'css;#comments > .comment-item',
  249. insertPosition: ['css;#paginator', 1],
  250. replaceE: 'css;#paginator',
  251. scrollDelta: 1000
  252. }
  253. },
  254. douban_subject_reviews: {
  255. SiteTypeID: 0,
  256. pager: {
  257. type: 1,
  258. nextLink: '//link[@rel="next"][@href]',
  259. pageElement: 'css;.review-list > div',
  260. insertPosition: ['css;.review-list', 3],
  261. replaceE: 'css;.paginator',
  262. scrollDelta: 1000
  263. }
  264. },
  265. douban_subject_episode: {
  266. SiteTypeID: 0,
  267. pager: {
  268. type: 1,
  269. nextLink: '//link[@rel="next"][@href]',
  270. pageElement: 'css;#comments > div',
  271. insertPosition: ['css;#comments', 3],
  272. replaceE: 'css;.paginator',
  273. scrollDelta: 1000
  274. }
  275. },
  276. weibo_comment: {
  277. SiteTypeID: 0,
  278. pager: {
  279. type: 2,
  280. nextLink: 'a[action-type="click_more_comment"]',
  281. nextText: '查看更多c',
  282. scrollDelta: 1000
  283. }
  284. },
  285. _58pic: {
  286. SiteTypeID: 0,
  287. pager: {
  288. type: 1,
  289. nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]',
  290. pageElement: 'css;.pic-box > .qtw-card',
  291. insertPosition: ['css;.pic-box', 3],
  292. replaceE: 'css;.page-box',
  293. scrollDelta: 2000
  294. },
  295. function: {
  296. before: _58pic_functionBefore
  297. }
  298. },
  299. _58pic_c: {
  300. SiteTypeID: 0,
  301. pager: {
  302. type: 1,
  303. nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]',
  304. pageElement: 'css;.list-box > .qtw-card',
  305. insertPosition: ['css;.list-box', 3],
  306. replaceE: 'css;.page-box',
  307. scrollDelta: 4000
  308. },
  309. function: {
  310. before: _58pic_functionBefore
  311. }
  312. },
  313. pixabay: {
  314. SiteTypeID: 0,
  315. pager: {
  316. type: 1,
  317. nextLink: '//a[text()="Next page"][@href]',
  318. pageElement: 'css;[class^="results"] > [class^="container"] > div',
  319. insertPosition: ['css;[class^="results"] > [class^="container"]', 3],
  320. replaceE: '//a[text()="Next page"][@href]',
  321. scrollDelta: 2000
  322. },
  323. function: {
  324. before: pixabay_functionBefore
  325. }
  326. },
  327. _3dmgame: {
  328. SiteTypeID: 0,
  329. pager: {
  330. type: 3,
  331. nextLink: '//li[@class="next"]/a[@href]',
  332. pageElement: 'css;.news_warp_center > *',
  333. insertPosition: ['css;.news_warp_center', 3],
  334. replaceE: 'css;.pagewrap',
  335. scrollElement: '.pagewrap',
  336. scrollDelta: 400
  337. }
  338. },
  339. ali213_www: {
  340. SiteTypeID: 0,
  341. pager: {
  342. type: 3,
  343. nextLink: 'id("after_this_page")[@href]',
  344. pageElement: 'css;#Content >*:not(.news_ding):not(.page_fenye)',
  345. insertPosition: ['css;.page_fenye', 1],
  346. replaceE: 'css;.page_fenye',
  347. scrollElement: '.page_fenye',
  348. scrollDelta: 400
  349. }
  350. },
  351. ali213_gl: {
  352. SiteTypeID: 0,
  353. pager: {
  354. type: 3,
  355. nextLink: '//a[@class="next n"][@href]',
  356. pageElement: 'css;.c-detail >*',
  357. insertPosition: ['css;.c-detail', 3],
  358. replaceE: 'css;.page_fenye',
  359. scrollElement: '.page_fenye',
  360. scrollDelta: 400
  361. }
  362. },
  363. gamersky_ent: {
  364. SiteTypeID: 0,
  365. pager: {
  366. type: 3,
  367. nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]',
  368. pageElement: 'css;.Mid2L_con > *:not(.gs_nc_editor):not(.pagecss):not(.page_css):not(.gs_ccs_solve):not(.post_ding)',
  369. insertPosition: ['css;.page_css', 1],
  370. replaceE: 'css;.page_css',
  371. scrollElement: '.page_css',
  372. scrollDelta: 100
  373. }
  374. },
  375. gamersky_gl: {
  376. SiteTypeID: 0,
  377. pager: {
  378. type: 3,
  379. nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]',
  380. pageElement: 'css;.Mid2L_con > *:not(.gs_nc_editor):not(.pagecss):not(.gs_ccs_solve):not(.post_ding)',
  381. insertPosition: ['css;.gs_nc_editor', 1],
  382. replaceE: 'css;.page_css',
  383. scrollElement: '.pagecss',
  384. scrollDelta: -1000
  385. },
  386. function: {
  387. before: gamersky_gl_functionBefore
  388. }
  389. },
  390. steamcommunity: {
  391. SiteTypeID: 0,
  392. pager: {
  393. type: 1,
  394. nextLink: '//a[@class="pagebtn"][last()][@href]',
  395. pageElement: 'css;.workshopBrowseItems > *',
  396. insertPosition: ['css;.workshopBrowseItems', 3],
  397. replaceE: 'css;.workshopBrowsePaging',
  398. scrollDelta: 1500
  399. }
  400. },
  401. _423down: {
  402. SiteTypeID: 0,
  403. pager: {
  404. type: 1,
  405. nextLink: '//div[@class="paging"]//a[contains(text(),"下一页")][@href]',
  406. pageElement: 'css;div.content-wrap ul.excerpt > li',
  407. insertPosition: ['css;div.content-wrap ul.excerpt', 3],
  408. replaceE: 'css;div.paging',
  409. scrollDelta: 1500
  410. }
  411. },
  412. sordum: {
  413. SiteTypeID: 0,
  414. pager: {
  415. type: 1,
  416. nextLink: '//a[@class="next page-numbers"][@href]',
  417. pageElement: 'css;.article > article',
  418. insertPosition: ['css;nav.navigation.posts-navigation', 1],
  419. replaceE: 'css;nav.navigation.posts-navigation',
  420. scrollDelta: 1500
  421. }
  422. },
  423. iao_su: {
  424. SiteTypeID: 0,
  425. pager: {
  426. type: 1,
  427. nextLink: '//li[@class="btn btn-primary next"]//a[@href]',
  428. pageElement: 'css;#index > article, #archive > article',
  429. insertPosition: ['css;ol.page-navigator', 1],
  430. replaceE: 'css;ol.page-navigator',
  431. scrollDelta: 800
  432. },
  433. function: {
  434. before: iao_su_functionBefore
  435. }
  436. },
  437. appinn: {
  438. SiteTypeID: 0,
  439. pager: {
  440. type: 1,
  441. nextLink: '//a[@class="next page-numbers"][@href]',
  442. pageElement: 'css;section#latest-posts > article',
  443. insertPosition: ['css;nav.navigation.pagination', 1],
  444. replaceE: 'css;div.nav-links',
  445. scrollDelta: 1500
  446. }
  447. },
  448. sixyin: {
  449. SiteTypeID: 0,
  450. pager: {
  451. type: 2,
  452. nextLink: '.load-more',
  453. nextHTML: '点击查看更多',
  454. scrollDelta: 1500
  455. }
  456. },
  457. sixyin_postlist: {
  458. SiteTypeID: 0,
  459. pager: {
  460. type: 1,
  461. nextLink: '//a[@class="next"][@href]',
  462. pageElement: 'css;ul.post-loop > li',
  463. insertPosition: ['css;ul.post-loop', 3],
  464. replaceE: 'css;ul.pagination',
  465. scrollDelta: 1500
  466. }
  467. },
  468. weidown: {
  469. SiteTypeID: 0,
  470. pager: {
  471. type: 1,
  472. nextLink: '//a[@class="nextpage"][@href]',
  473. pageElement: 'css;.articleWrapper > .itemArticle, .articleWrapper > .richTextItem.search',
  474. insertPosition: ['css;.articleWrapper', 3],
  475. replaceE: 'css;#pageGroup',
  476. scrollDelta: 1500
  477. }
  478. },
  479. weidown_search: {
  480. SiteTypeID: 0,
  481. pager: {
  482. type: 1,
  483. nextLink: '//a[@class="nextpage"][@href]',
  484. pageElement: 'css;.articleListWrapper > .richTextItem.search',
  485. insertPosition: ['css;#pageGroup', 1],
  486. replaceE: 'css;#pageGroup',
  487. scrollDelta: 700
  488. }
  489. },
  490. weidown_special: {
  491. SiteTypeID: 0,
  492. pager: {
  493. type: 1,
  494. nextLink: '//a[@class="nextpage"][@href]',
  495. pageElement: 'css;.special > .item',
  496. insertPosition: ['css;.special', 3],
  497. replaceE: 'css;#pageGroup',
  498. scrollDelta: 700
  499. }
  500. },
  501. iplaysoft_postslist: {
  502. SiteTypeID: 0,
  503. pager: {
  504. type: 1,
  505. nextLink: '//div[@class="pagenavi"]//a[@title="下一页"][@href]',
  506. pageElement: 'css;#postlist > div.entry',
  507. insertPosition: ['css;#postlist > .pagenavi-button', 1],
  508. replaceE: 'css;.pagenavi-button, .pagenavi',
  509. scrollDelta: 1200
  510. },
  511. function: {
  512. before: iplaysoft_postslist_functionBefore
  513. }
  514. },
  515. iplaysoft_postcomments: {
  516. SiteTypeID: 0,
  517. pager: {
  518. type: 2,
  519. nextLink: '#loadHistoryComments',
  520. nextTextOf: '展开后面',
  521. scrollDelta: 1200
  522. }
  523. },
  524. mpyit: {
  525. SiteTypeID: 0,
  526. pager: {
  527. type: 1,
  528. nextLink: '//a[@class="page-numbers"][@title="下一页"][@href]',
  529. pageElement: 'css;#post > div[id^="post-"]',
  530. insertPosition: ['css;#post > #pagenavi', 1],
  531. replaceE: 'css;#post > #pagenavi',
  532. scrollDelta: 1700
  533. }
  534. },
  535. mpyit_category: {
  536. SiteTypeID: 0,
  537. pager: {
  538. type: 1,
  539. nextLink: '//a[@class="page-numbers"][@title="下一页"][@href]',
  540. pageElement: 'css;#content > div[class^="entry_box"]',
  541. insertPosition: ['css;#content > #pagenavi', 1],
  542. replaceE: 'css;#content > #pagenavi',
  543. scrollDelta: 1700
  544. }
  545. },
  546. yxssp: {
  547. SiteTypeID: 0,
  548. pager: {
  549. type: 1,
  550. nextLink: '//div[@class="page-nav td-pb-padding-side"]/a[last()][@href]',
  551. pageElement: 'css;.td-modules-container.td-module-number4 > div',
  552. insertPosition: ['css;.td-modules-container.td-module-number4', 3],
  553. replaceE: 'css;.page-nav.td-pb-padding-side',
  554. scrollDelta: 1000
  555. }
  556. },
  557. cartoonmad: {
  558. SiteTypeID: 0,
  559. pager: {
  560. type: 1,
  561. nextLink: cartoonmad_functionNext,
  562. pageElement: 'css;body > table > tbody > tr:nth-child(4) > td > table > tbody > tr:first-child > td:first-child img',
  563. insertPosition: ['css;body > table > tbody > tr:nth-child(4) > td > table > tbody > tr:first-child > td:first-child > a', 3],
  564. replaceE: 'css;body > table > tbody > tr:nth-child(2), body > table > tbody > tr:nth-child(5)',
  565. mimeType: 'text/html; charset=big5',
  566. scrollDelta: 2000
  567. }
  568. },
  569. manhuadb: {
  570. SiteTypeID: 0,
  571. pager: {
  572. type: 4,
  573. nextLink: manhuadb_functionNext,
  574. pageElement: 'css;body > script:not([type]):not([src]), .vg-r-data, ol.links-of-books.num_div',
  575. insertPosition: ['css;.pjax-container', 3],
  576. insertElement: manhuadb_insertElement,
  577. intervals: 5000,
  578. scrollDelta: 3000
  579. }
  580. },
  581. hicomic: {
  582. SiteTypeID: 0,
  583. pager: {
  584. type: 4,
  585. nextLink: hicomic_functionNext,
  586. insertPosition: ['css;.content', 3],
  587. insertElement: hicomic_insertElement,
  588. intervals: 5000,
  589. scrollDelta: 3000
  590. }
  591. },
  592. gufengmh8: {
  593. SiteTypeID: 0,
  594. pager: {
  595. type: 4,
  596. nextLink: gufengmh8_functionNext,
  597. pageElement: 'css;body > script:first-child',
  598. insertPosition: ['css;#images', 3],
  599. insertElement: gufengmh8_insertElement,
  600. intervals: 5000,
  601. scrollDelta: 4000
  602. }
  603. },
  604. szcdmj: {
  605. SiteTypeID: 0,
  606. pager: {
  607. type: 1,
  608. nextLink: '//div[@class="fanye"][1]/a[@href][text()="下一页" or text()="下一话"]',
  609. pageElement: 'css;.comicpage > div,title',
  610. insertPosition: ['css;.comicpage', 3],
  611. replaceE: 'css;.fanye,h1.title',
  612. scrollDelta: 2000
  613. },
  614. function: {
  615. before: szcdmj_functionBefore
  616. }
  617. },
  618. gaoqing_fm: {
  619. SiteTypeID: 0,
  620. pager: {
  621. type: 2,
  622. nextLink: '.col-md-12 > a[href], #loadmore > a[href]',
  623. intervals: 1500,
  624. scrollDelta: 1000
  625. }
  626. },
  627. baoshuu: {
  628. SiteTypeID: 0,
  629. pager: {
  630. type: 1,
  631. nextLink: '//div[@class="listl2"]//a[@href][text()="下一页"]',
  632. pageElement: 'css;.listl2 > ul > li',
  633. insertPosition: ['css;.listl2 > ul', 3],
  634. replaceE: 'css;listl2 > dl',
  635. mimeType: 'text/html; charset=gb2312',
  636. scrollDelta: 900
  637. }
  638. },
  639. baoshuu_m: {
  640. SiteTypeID: 0,
  641. pager: {
  642. type: 1,
  643. nextLink: '//div[@class="man_first"]//a[@href][text()="下一页"]',
  644. pageElement: 'css;.man_first > ul > li',
  645. insertPosition: ['css;.man_first > ul', 3],
  646. replaceE: 'css;.man_first > dl',
  647. mimeType: 'text/html; charset=gb2312',
  648. scrollDelta: 900
  649. }
  650. },
  651. skrbtba: {
  652. SiteTypeID: 0,
  653. pager: {
  654. type: 1,
  655. nextLink: '//a[@aria-label="Next"]',
  656. pageElement: 'css;div[class="row"] > .col-md-6 > ul',
  657. insertPosition: ['css;nav[aria-label*="Page"]', 1],
  658. replaceE: 'css;ul.pagination',
  659. scrollDelta: 900
  660. }
  661. },
  662. rarbgprx: {
  663. SiteTypeID: 0,
  664. pager: {
  665. type: 1,
  666. nextLink: '(//a[@title="next page"])[1][@href]',
  667. pageElement: 'css;table.lista2t tr.lista2',
  668. insertPosition: ['css;table.lista2t > tbody', 3],
  669. replaceE: 'css;#pager_links',
  670. scrollDelta: 900
  671. }
  672. },
  673. pubmed_postslist: {
  674. SiteTypeID: 0,
  675. pager: {
  676. type: 2,
  677. nextLink: 'button.load-button.next-page',
  678. nextText: 'Show more',
  679. scrollDelta: 1500
  680. }
  681. },
  682. afreecatv: {
  683. SiteTypeID: 0,
  684. pager: {
  685. type: 2,
  686. nextLink: '.btn-more > button',
  687. intervals: 2000,
  688. scrollDelta: 1000
  689. }
  690. },
  691. greasyfork: {
  692. SiteTypeID: 0,
  693. pager: {
  694. type: 1,
  695. nextLink: '//a[@class="next_page"][@href]',
  696. pageElement: 'css;ol#browse-script-list > li',
  697. insertPosition: ['css;ol#browse-script-list', 3],
  698. replaceE: 'css;.pagination',
  699. scrollDelta: 1000
  700. }
  701. },
  702. greasyfork_feedback: {
  703. SiteTypeID: 0,
  704. pager: {
  705. type: 1,
  706. nextLink: '//a[@class="next_page"][@href]',
  707. pageElement: 'css;.script-discussion-list > div',
  708. insertPosition: ['css;.script-discussion-list', 3],
  709. replaceE: 'css;.pagination',
  710. scrollDelta: 1500
  711. }
  712. },
  713. greasyfork_discussions: {
  714. SiteTypeID: 0,
  715. pager: {
  716. type: 1,
  717. nextLink: '//a[@class="next_page"][@href]',
  718. pageElement: 'css;.discussion-list > div',
  719. insertPosition: ['css;.discussion-list', 3],
  720. replaceE: 'css;.pagination',
  721. scrollDelta: 1000
  722. }
  723. },
  724. cs_rin_ru: {
  725. SiteTypeID: 0,
  726. pager: {
  727. type: 1,
  728. nextLink: '//td[@class="gensmall"][@align="right"]//a[text()="Next"][@href]',
  729. pageElement: 'css;#pagecontent > table.tablebg > tbody > tr:not([align])',
  730. insertPosition: ['css;#pagecontent > table.tablebg > tbody > tr[align]', 1],
  731. replaceE: 'css;#pagecontent > table:first-child',
  732. scrollDelta: 1500
  733. },
  734. function: {
  735. before: cs_rin_ru_functionBefore
  736. }
  737. },
  738. cs_rin_ru_viewtopic: {
  739. SiteTypeID: 0,
  740. pager: {
  741. type: 1,
  742. nextLink: 'id("pageheader")/p[@class="gensmall"]//a[text()="Next"][@href]',
  743. pageElement: 'css;#pagecontent > table.tablebg:not(:nth-last-child(2)):not(:nth-child(2))',
  744. insertPosition: ['css;#pagecontent > table.tablebg:nth-last-child(2)', 1],
  745. replaceE: 'css;#pagecontent >table:not(.tablebg), #pageheader p.gensmall',
  746. scrollDelta: 1500
  747. }
  748. },
  749. cs_rin_ru_search: {
  750. SiteTypeID: 0,
  751. pager: {
  752. type: 1,
  753. nextLink: 'id("wrapcentre")/div[@class="nav"]//a[text()="Next"]',
  754. pageElement: 'css;#wrapcentre > form > table.tablebg > tbody > tr[valign]',
  755. insertPosition: ['css;#wrapcentre > form > table.tablebg > tbody > tr:last-child', 1],
  756. replaceE: 'css;#wrapcentre > div',
  757. scrollDelta: 1500
  758. }
  759. },
  760. fitgirl: {
  761. SiteTypeID: 0,
  762. pager: {
  763. type: 1,
  764. nextLink: '//a[@class="next page-numbers"][@href]',
  765. pageElement: 'css;article[id^="post-"]',
  766. insertPosition: ['css;nav.paging-navigation', 1],
  767. replaceE: 'css;nav.paging-navigation',
  768. scrollDelta: 2000
  769. }
  770. }
  771. };
  772. // 生成 SiteTypeID
  773. generateID();
  774.  
  775. // 用于脚本判断(针对部分特殊的网站)
  776. const SiteType = {
  777. GOOGLE: DBSite.google.SiteTypeID,
  778. BAIDU_TIEBA: DBSite.baidu_tieba.SiteTypeID,
  779. GAMERSKY_GL: DBSite.gamersky_gl.SiteTypeID,
  780. STEAMCOMMUNITY: DBSite.steamcommunity.SiteTypeID
  781. };
  782.  
  783.  
  784. // < 其他网站 >
  785. if (webType === 1) {
  786. switch (location.host) {
  787. case 'www.baidu.com': // < 百度搜索 >
  788. curSite = DBSite.baidu;
  789. break;
  790. case 'www.google.com': // < 谷歌搜索 >
  791. if (location.pathname === '/search') curSite = DBSite.google;
  792. break;
  793. case 'www.bing.com': // < 必应搜索 >
  794. case 'cn.bing.com':
  795. if (location.pathname === '/search') {curSite = DBSite.bing; document.lastElementChild.appendChild(document.createElement('style')).textContent = '.b_imagePair.square_mp > .inner {display: none;}';}
  796. break;
  797. case 'tieba.baidu.com': // < 百度贴吧 >
  798. if (location.pathname === '/f') { // 帖子列表
  799. baidu_tieba_1(); // 右侧悬浮发帖按钮点击事件(解决自动翻页导致无法发帖的问题)
  800. curSite = DBSite.baidu_tieba; document.lastElementChild.appendChild(document.createElement('style')).textContent = 'img.j_retract {margin-top: 0 !important;margin-bottom: 0 !important;}'; // 修复帖子列表中预览图片,在切换下一个/上一个图片时,多出来的图片上下边距
  801. //} else if (location.pathname.indexOf('/p/') > -1) { // 帖子内
  802. // curSite = DBSite.baidu_tieba_post;
  803. } else if (location.pathname === '/f/search/res') { // 吧内搜索/全吧搜索
  804. curSite = DBSite.baidu_tieba_search;
  805. }
  806. break;
  807. case 'movie.douban.com': // < 豆瓣评论 >
  808. if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评列表
  809. curSite = DBSite.douban_subject_comments;
  810. } else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评列表
  811. curSite = DBSite.douban_subject_reviews;
  812. } else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论
  813. curSite = DBSite.douban_subject_episode;
  814. }
  815. break;
  816. case 'weibo.com': // < 微博评论 >
  817. curSite = DBSite.weibo_comment;
  818. break;
  819. case 'www.58pic.com': // < 千图网 >
  820. if (location.pathname.indexOf('/tupian/') > -1) {
  821. curSite = DBSite._58pic; document.lastElementChild.appendChild(document.createElement('style')).textContent = '.qtw-card.place-box.is-two {display: none !important;}'; // 隐藏末尾很大的 [下一页] 按钮
  822. } else if (location.pathname.indexOf('/c/') > -1) {
  823. curSite = DBSite._58pic_c;
  824. }
  825. break;
  826. case 'pixabay.com': // < Pixabay >
  827. curSite = DBSite.pixabay;
  828. break;
  829. case 'www.3dmgame.com': // < 3DM >
  830. curSite = DBSite._3dmgame;
  831. break;
  832. case 'www.ali213.net': // < 游侠网 >
  833. curSite = DBSite.ali213_www;
  834. break;
  835. case 'gl.ali213.net': // < 游侠网 - 攻略页 >
  836. curSite = DBSite.ali213_gl; document.lastElementChild.appendChild(document.createElement('style')).textContent = '.n_show_b {display: none !important;}'; // 隐藏部分碍事元素
  837. break;
  838. case 'www.gamersky.com': // < 游民星空 >
  839. if (location.pathname.indexOf('/ent/') > -1) {
  840. curSite = DBSite.gamersky_ent;
  841. } else {
  842. curSite = DBSite.gamersky_gl;
  843. }
  844. break;
  845. case 'steamcommunity.com': // < Steam 创意工坊 >
  846. curSite = DBSite.steamcommunity;
  847. break;
  848. case 'www.423down.com': // < 423down >
  849. if (location.pathname.indexOf('.html') === -1) curSite = DBSite._423down;
  850. break;
  851. case 'www.sordum.org': // < Sordum >
  852. curSite = DBSite.sordum;
  853. break;
  854. case 'iao.su': // < 不死鸟 >
  855. curSite = DBSite.iao_su;
  856. break;
  857. case 'www.appinn.com': // < 小众软件 >
  858. curSite = DBSite.appinn;
  859. break;
  860. case 'www.sixyin.com': // < 六音软件 >
  861. if (location.pathname === '/' && location.search === '') { // 首页
  862. curSite = DBSite.sixyin;
  863. } else if (location.pathname.indexOf('.html') === -1) { // 分类页
  864. curSite = DBSite.sixyin_postlist;
  865. }
  866. break;
  867. case 'www.weidown.com': // < 微当下载 >
  868. if (location.pathname.indexOf('/search/') > -1) {
  869. curSite = DBSite.weidown_search;
  870. } else if (location.pathname.indexOf('/special/') > -1) {
  871. curSite = DBSite.weidown_special;
  872. } else {
  873. curSite = DBSite.weidown;
  874. }
  875. break;
  876. case 'www.iplaysoft.com': // < 异次元软件 >
  877. if (location.pathname.indexOf('.html') > -1 || location.pathname.indexOf('/p/') > -1) { // 文章内
  878. curSite = DBSite.iplaysoft_postcomments;
  879. } else { // 其他页面
  880. curSite = DBSite.iplaysoft_postslist;
  881. }
  882. break;
  883. case 'www.mpyit.com': // < 老殁殁漂遥 >
  884. if (location.pathname === '/' && !location.search) {
  885. curSite = DBSite.mpyit;
  886. } else if (location.pathname.indexOf('/category/') > -1 || location.search.indexOf('?s=') > -1) {
  887. curSite = DBSite.mpyit_category;
  888. }
  889. break;
  890. case 'www.yxssp.com': // < 异星软件空间 >
  891. curSite = DBSite.yxssp;
  892. break;
  893. case 'www.cartoonmad.com': // < 漫画狂 >
  894. case 'www.cartoonmad.cc':
  895. if (location.pathname.indexOf('/comic/') > -1) {
  896. document.lastElementChild.appendChild(document.createElement('style')).textContent = '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;}';
  897. document.querySelector('body > table > tbody > tr:nth-child(4) > td > table > tbody > tr:first-child > td:first-child > a').href = 'javascript:void(0);'; // 清理图片上的链接
  898. curSite = DBSite.cartoonmad;
  899. }
  900. break;
  901. case 'www.manhuadb.com': // < 漫画DB >
  902. if (location.pathname.indexOf('/manhua/') > -1 && location.pathname.indexOf('.html') > -1) {
  903. document.lastElementChild.appendChild(document.createElement('style')).textContent = '.row.m-0.pt-3.ad_2_wrap, .row.m-0.ad_1_wrap, .pagination.justify-content-center, #left, #right {display: none !important;}';
  904. document.querySelector('img.img-fluid.show-pic').style.display = 'none'; // 隐藏第一个图片(避免重复)
  905. setTimeout(manhuadb_init, 100);
  906. curSite = DBSite.manhuadb;
  907. }
  908. break;
  909. case 'www.hicomic.net': // < HiComic(嗨漫画) >
  910. if (location.pathname.indexOf('/chapters/') > -1) {
  911. document.lastElementChild.appendChild(document.createElement('style')).textContent = '.content {height: auto !important;} .footer, .left_cursor, .right_cursor, .finish {display: none !important;} .content > img {display: block !important;margin: 0 auto !important;}';
  912. setTimeout(hicomic_init, 100);
  913. curSite = DBSite.hicomic;
  914. }
  915. break;
  916. case 'www.gufengmh8.com': // < 古风漫画网 >
  917. if (location.pathname.indexOf('.html') > -1) {
  918. let chapterScroll = document.getElementById('chapter-scroll') // 强制为 [下拉阅读] 模式
  919. if (chapterScroll && chapterScroll.className === '') {chapterScroll.click();}
  920. curSite = DBSite.gufengmh8; document.lastElementChild.appendChild(document.createElement('style')).textContent = 'p.img_info {display: none !important;}'; // 隐藏中间的页数信息
  921. }
  922. break;
  923. case 'www.szcdmj.com': // < 砂之船动漫家 >
  924. if (location.pathname.indexOf('/szcchapter/') > -1) curSite = DBSite.szcdmj;
  925. break;
  926. case 'gaoqing.fm': // < 高清电台 >
  927. curSite = DBSite.gaoqing_fm;
  928. break;
  929. case 'www.baoshuu.com': // < 宝书网 >
  930. if (location.pathname.indexOf('/TXT/list') > -1) curSite = DBSite.baoshuu;
  931. break;
  932. case 'm.baoshuu.com': // < 宝书网 - 手机版 >
  933. if (location.pathname.indexOf('/TXT/list') > -1) curSite = DBSite.baoshuu_m;
  934. break;
  935. case 'skrbtba.xyz': // < SkrBt >
  936. if (location.pathname === '/search') curSite = DBSite.skrbtba;
  937. break;
  938. case 'rarbgprx.org': // < RARBG >
  939. curSite = DBSite.rarbgprx;
  940. break;
  941. case 'pubmed.ncbi.nlm.nih.gov': // < 国外学术网站 >
  942. curSite = DBSite.pubmed_postslist;
  943. break;
  944. case 'www.afreecatv.com': // < 直播网站 >
  945. curSite = DBSite.afreecatv;
  946. break;
  947. case 'greasyfork.org': // < GreasyFork >
  948. if (location.pathname.indexOf('/scripts') + 8 === location.pathname.length) {
  949. curSite = DBSite.greasyfork;
  950. } else if (location.pathname.lastIndexOf('/feedback') + 9 === location.pathname.length) {
  951. curSite = DBSite.greasyfork_feedback;
  952. } else if (location.pathname.lastIndexOf('/discussions') + 12 === location.pathname.length) {
  953. curSite = DBSite.greasyfork_discussions;
  954. }
  955. break;
  956. case 'cs.rin.ru': // < 游戏下载论坛 >
  957. if (location.pathname === '/forum/viewforum.php') { // 版块帖子列表
  958. curSite = DBSite.cs_rin_ru;
  959. } else if (location.pathname === '/forum/viewtopic.php') { // 帖子内
  960. if (GM_getValue('menu_discuz_thread_page')) curSite = DBSite.cs_rin_ru_viewtopic;
  961. } else if (location.pathname === '/forum/search.php') { // 搜索结果
  962. curSite = DBSite.cs_rin_ru_search;
  963. }
  964. break;
  965. case 'crackhub.site': // < 游戏下载网站 >
  966. curSite = DBSite.fitgirl; document.lastElementChild.appendChild(document.createElement('style')).textContent = 'html.wp-dark-mode-active .inside-article {background-color: var(--wp-dark-mode-bg);}'
  967. break;
  968. case 'fitgirl-repacks.site': // < 游戏下载网站 >
  969. curSite = DBSite.fitgirl;
  970. break;
  971. }
  972. // < 所有 Discuz!论坛 >
  973. } else if (webType === 2) {
  974. if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾)
  975. if (location.pathname.indexOf('/forum-') > -1) { // 各版块帖子列表
  976. if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮
  977. curSite = DBSite.discuz_forum;
  978. } else {
  979. curSite = DBSite.discuz_guide;
  980. }
  981. } else if (location.pathname.indexOf('/thread-') > -1) { // 帖子内
  982. if (GM_getValue('menu_discuz_thread_page')) {
  983. curSite = DBSite.discuz_thread;
  984. hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮
  985. }
  986. } else if(location.pathname.indexOf('search') > -1) { // 搜索结果
  987. curSite = DBSite.discuz_search;
  988. }
  989. } else {
  990. if (location.search.indexOf('mod=forumdisplay') > -1 || location.pathname.indexOf('forumdisplay.php') > -1) { // 各版块帖子列表
  991. if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮
  992. curSite = DBSite.discuz_forum;
  993. } else {
  994. curSite = DBSite.discuz_guide;
  995. }
  996. } else if (location.search.indexOf('mod=viewthread') > -1 || location.pathname.indexOf('viewthread.php') > -1) { // 帖子内
  997. if (GM_getValue('menu_discuz_thread_page')) {
  998. curSite = DBSite.discuz_thread;
  999. hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮
  1000. }
  1001. } else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表
  1002. curSite = DBSite.discuz_guide;
  1003. } else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复
  1004. curSite = DBSite.discuz_youspace;
  1005. } else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表
  1006. curSite = DBSite.discuz_collection;
  1007. } else if (location.pathname.indexOf('search') > -1) { // 搜索结果
  1008. curSite = DBSite.discuz_search;
  1009. } else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的
  1010. curSite = DBSite.discuz_forum;
  1011. }
  1012. }
  1013. // < 所有 Flarum 论坛 >
  1014. } else if (webType === 3) {
  1015. curSite = DBSite.flarum;
  1016. // < 所有使用 WordPress DUX 主题的网站 >
  1017. } else if (webType === 4) {
  1018. if (location.pathname.indexOf('.html') === -1) curSite = DBSite.dux;
  1019. if (location.host === 'apphot.cc') curSite.pager.scrollDelta = 2500; // 对于速度慢的网站,需要增加翻页敏感度
  1020. }
  1021.  
  1022. pausePageEvent(); // 左键双击网页空白处暂停翻页
  1023. curSite.pageUrl = ''; // 下一页URL
  1024. //console.log(curSite);
  1025. pageLoading(); // 自动无缝翻页
  1026.  
  1027.  
  1028. // 隐藏帖子内的 [下一页] 按钮(Discuz! 论坛)
  1029. function hidePgbtn() {
  1030. document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}';
  1031. }
  1032.  
  1033.  
  1034. // dux 的插入前函数(加载图片)
  1035. function dux_functionBefore(pageElems) {
  1036. pageElems.forEach(function (one) {
  1037. let now = one.querySelector('img.thumb[data-src]')
  1038. if (now) {now.src = now.dataset.src;}
  1039. });
  1040. return pageElems
  1041. }
  1042.  
  1043.  
  1044. // 百度贴吧(发帖按钮点击事件)
  1045. function baidu_tieba_1() {
  1046. let button = document.querySelector('.tbui_aside_fbar_button.tbui_fbar_post > a');
  1047. if (button) {
  1048. button.remove();
  1049. document.querySelector('li.tbui_aside_fbar_button.tbui_fbar_down').insertAdjacentHTML(addTo(4), '<li class="tbui_aside_fbar_button tbui_fbar_post"><a href="javascript:void(0);" title="因为 [自动无缝翻页] 的原因,请点击该按钮发帖!"></a></li>')
  1050. button = document.querySelector('.tbui_aside_fbar_button.tbui_fbar_post > a');
  1051. if (button) {
  1052. button.onclick = function(){
  1053. let button2 = document.querySelector('div.edui-btn.edui-btn-fullscreen.edui-btn-name-portrait');
  1054. if (button2) {
  1055. button2.click();
  1056. } else {
  1057. alert('提示:登录后才能发帖!');
  1058. }
  1059. return false;
  1060. }
  1061. }
  1062. }
  1063. }
  1064.  
  1065.  
  1066. // 百度贴吧 的插入前函数(加载图片)
  1067. function baidu_tieba_functionBefore(pageElems) {
  1068. pageElems.forEach(function (one) {
  1069. one.querySelectorAll('img.threadlist_pic[data-original]').forEach(function (now) {
  1070. now.src = now.dataset.original;
  1071. now.style.display = 'inline';
  1072. })
  1073. });
  1074. return pageElems
  1075. }
  1076.  
  1077.  
  1078. // 58pic 的插入前函数(加载图片)
  1079. function _58pic_functionBefore(pageElems) {
  1080. let is_one = document.querySelector('.qtw-card.place-box.is-one');
  1081. if (is_one && is_one.style.display != 'none') {is_one.style.display = 'none';}
  1082. pageElems.forEach(function (one) {
  1083. let now = one.querySelector('img.lazy')
  1084. if (now && now.getAttribute('src') != now.dataset.original) {
  1085. now.src = now.dataset.original;
  1086. now.style.display = 'block';
  1087. }
  1088. });
  1089. return pageElems
  1090. }
  1091.  
  1092.  
  1093. // Pixabay 的插入前函数(加载图片)
  1094. function pixabay_functionBefore(pageElems) {
  1095. pageElems.forEach(function (one) {
  1096. let now = one.querySelector('img[data-lazy-src]')
  1097. if (now) {
  1098. now.src = now.dataset.lazySrc;
  1099. now.removeAttribute('data-lazy-src')
  1100. now.removeAttribute('data-lazy-srcset')
  1101. }
  1102. });
  1103. return pageElems
  1104. }
  1105.  
  1106.  
  1107. // 游民星空攻略 的插入前函数(移除下一页底部的 "更多相关内容请关注:xxx" 文字)
  1108. function gamersky_gl_functionBefore(pageElems) {
  1109. pageElems.forEach(function (one) {
  1110. if (one.tagName === 'P' && one.textContent.indexOf('更多相关内容请关注') > -1) {one.style.display = 'none';}
  1111. });
  1112. return pageElems
  1113. }
  1114.  
  1115.  
  1116. // iao.su 的插入前函数(加载图片)
  1117. function iao_su_functionBefore(pageElems) {
  1118. pageElems.forEach(function (one) {
  1119. let now = one.getElementsByClassName('post-card')[0]
  1120. if (now) {
  1121. now.getElementsByClassName('blog-background')[0].style.backgroundImage = 'url("' + now.getElementsByTagName('script')[0].textContent.split("'")[1] + '")';
  1122. //now.getElementsByClassName('blog-background')[0].style.backgroundImage = 'url("' + RegExp("(?<=loadBannerDirect\\(').*(?=', '',)").exec(now.getElementsByTagName('script')[0].textContent)[0]; + '")';
  1123. }
  1124. });
  1125. return pageElems
  1126. }
  1127.  
  1128.  
  1129. // iplaysoft 的插入前函数(加载图片)
  1130. function iplaysoft_postslist_functionBefore(pageElems) {
  1131. pageElems.forEach(function (one) {
  1132. let now = one.querySelector('img.lazyload')
  1133. if (now && !now.src) {
  1134. now.src = now.dataset.src;
  1135. now.setAttribute('srcset', now.dataset.src)
  1136. now.setAttribute('class', 'lazyloaded')
  1137. }
  1138. });
  1139. return pageElems
  1140. }
  1141.  
  1142.  
  1143. // cs_rin_ru 各版块帖子列表的插入前函数(过滤置顶帖子)
  1144. function cs_rin_ru_functionBefore(pageElems) {
  1145. for (let i = 0; i < pageElems.length; i++) {
  1146. if (pageElems[i].textContent.replace(/\n| /g,'') === 'Topics') {
  1147. pageElems.splice(0,i+1);
  1148. break;
  1149. }
  1150. }
  1151. return pageElems
  1152. }
  1153.  
  1154.  
  1155. // 漫画狂 获取下一页地址
  1156. function cartoonmad_functionNext() {
  1157. let nextXPAHT = '//a[@class="pages"][contains(text(),"下一頁")]',
  1158. nextPXPATH = '//a[@class="pages"][contains(string(),"下一話")]'
  1159. let url = getElementByXpath(nextXPAHT);
  1160. if (url) {
  1161. if (url.getAttribute('href') === 'thend.asp') {
  1162. url = getElementByXpath(nextPXPATH)
  1163. if (url) return url.href;
  1164. pausePage = false;
  1165. GM_notification({text: `注意:该网站早期漫画(如海贼王、柯南)因为网站自身问题而无法翻至下一话(仅限于显示为 [第 X 卷]/[下一卷] 的)。\n因此需要手动去 [目录页] 进入下一卷!`, timeout: 10000});
  1166. } else {
  1167. return url.href;
  1168. }
  1169. }
  1170. return '';
  1171. }
  1172.  
  1173.  
  1174. // manhuadb 初始化(将本话其余图片插入网页中)
  1175. function manhuadb_init() {
  1176. let _img = '',
  1177. data = document.querySelector('.vg-r-data'), imgDate;
  1178. if (!data) return
  1179. document.querySelectorAll(curSite.pager.pageElement.replace('css;', '')).forEach(function (one) {
  1180. if (one.tagName === 'SCRIPT' && one.textContent.indexOf('var img_data =') > -1) {
  1181. let json = JSON.parse(window.atob(one.textContent.split("'")[1]));
  1182. if (json) {
  1183. let _img = '';
  1184. for (let i = 0; i < json.length; i++) { // 遍历图片文件名数组,组合为 img 标签
  1185. let src = data.dataset.host + data.dataset.img_pre + json[i].img;
  1186. _img += `<img class="img-fluid show-pic" src="${src}">`
  1187. }
  1188. document.querySelector(curSite.pager.insertPosition[0].replace('css;', '')).insertAdjacentHTML(addTo(curSite.pager.insertPosition[1]), _img); // 将 img 标签插入到网页中
  1189. }
  1190. }
  1191. })
  1192. }
  1193. // manhuadb 获取下一页地址
  1194. function manhuadb_functionNext() {
  1195. let nextArr = document.querySelectorAll('a.fixed-a-es'), next;
  1196. if (nextArr.length == 0) return
  1197. curSite.pageUrl = '';
  1198. for (let i = 0; i < nextArr.length; i++) {
  1199. if (nextArr[i].className.indexOf('active') > -1) {
  1200. if (nextArr[i+1]) curSite.pageUrl = nextArr[i+1].href;
  1201. break;
  1202. }
  1203. }
  1204. if (curSite.pageUrl) getPageElems(curSite.pageUrl);
  1205. }
  1206. // manhuadb 插入数据
  1207. function manhuadb_insertElement(pageElems, type) {
  1208. if (!pageElems) return
  1209. let oriE = document.querySelectorAll(curSite.pager.pageElement.replace('css;', '')),
  1210. repE = getAllElements(curSite.pager.pageElement, pageElems, pageElems);
  1211. if (oriE.length === repE.length) {
  1212. for (let i = 0; i < oriE.length; i++) {
  1213. oriE[i].outerHTML = repE[i].outerHTML;
  1214. }
  1215. manhuadb_init(); // 将刚刚替换的图片插入网页中
  1216. }
  1217. }
  1218.  
  1219.  
  1220. // hicomic 初始化(将本话其余图片插入网页中)
  1221. function hicomic_init() {
  1222. let _img = '';
  1223. document.querySelectorAll('.chapter > section:not(:first-child) > section[val]').forEach(function (one) {
  1224. let src = one.getAttribute('val');
  1225. if (src.indexOf('!p_c_c_') === -1) src += '!p_c_c_h'
  1226. _img += `<img src="${src}">`
  1227. })
  1228. document.querySelector(curSite.pager.insertPosition[0].replace('css;', '')).insertAdjacentHTML(addTo(curSite.pager.insertPosition[1]), _img); // 将 img 标签插入到网页中
  1229. window.document.title = window.document.title.replace(/(\(第.+\))? - HiComic/, `(${document.querySelector('.chapter_name').textContent}) - HiComic`); // 修改网页标题(加上 第 X 话)
  1230. }
  1231. // hicomic 获取下一页地址
  1232. function hicomic_functionNext() {
  1233. let nextId;
  1234. nextId = document.querySelector('.next_chapter:not(.end)')
  1235. if (nextId && nextId.id && nextId.id != 'None') {
  1236. curSite.pageUrl = location.href;
  1237. getPageElems(`https://www.hicomic.net/api/web/chapter/${nextId.id}/contents`, 'json');
  1238. }
  1239. }
  1240. // hicomic 插入数据
  1241. function hicomic_insertElement(pageElems, type) {
  1242. if (!pageElems || pageElems.code != 200) return
  1243. if (pageElems.results.chapter.next) { // 写入下一页的 UUID
  1244. document.querySelector('.next_chapter').id = pageElems.results.chapter.next;
  1245. } else {
  1246. document.querySelector('.next_chapter').id = 'None';
  1247. document.querySelector('.next_chapter').classList.add('end');
  1248. }
  1249. document.querySelector('.chapter_name').textContent = pageElems.results.chapter.name; // 修改漫画标题
  1250. let title = window.document.title.replace(/(\(第.+\))? - HiComic/, `(${pageElems.results.chapter.name}) - HiComic`)
  1251. window.history.pushState(`{title: ${document.title}, url: ${location.href}}`, title, curSite.pageUrl); // 添加历史记录
  1252. window.document.title = title; // 修改当前网页标题为下一话的标题
  1253. let _img = '';
  1254. for (let i = 0; i < pageElems.results.chapter.contents.length; i++) { // 遍历图片文件名数组,组合为 img 标签
  1255. let src = pageElems.results.chapter.contents[i].url;
  1256. if (src.indexOf('!p_c_c_') === -1) src += '!p_c_c_h';
  1257. _img += `<img src="${src}">`
  1258. }
  1259. document.querySelector(curSite.pager.insertPosition[0].replace('css;', '')).insertAdjacentHTML(addTo(curSite.pager.insertPosition[1]), _img); // 将 img 标签插入到网页中
  1260. }
  1261.  
  1262.  
  1263. // gufengmh8 获取下一页地址
  1264. function gufengmh8_functionNext() {
  1265. let pageElems = document.querySelector(curSite.pager.pageElement.replace('css;', '')); // 寻找数据所在元素
  1266. if (pageElems) {
  1267. let comicUrl, nextId;
  1268. pageElems.textContent.split(';').forEach(function (one){ // 分号 ; 分割为数组并遍历
  1269. //console.log(one)
  1270. if (one.indexOf('comicUrl') > -1) { // 下一页 URL 前半部分
  1271. comicUrl = one.split('"')[1];
  1272. } else if (one.indexOf('nextChapterData') > -1) { // 下一页 URL 的后半部分 ID
  1273. nextId = one.split('"id":')[1].split(',')[0];
  1274. }
  1275. })
  1276. if (comicUrl && nextId && nextId != 'null') { // 组合到一起就是下一页 URL
  1277. curSite.pageUrl = comicUrl + nextId + '.html'
  1278. getPageElems(curSite.pageUrl); // 访问下一页 URL 获取
  1279. }
  1280. }
  1281. }
  1282. // gufengmh8 插入数据
  1283. function gufengmh8_insertElement(pageElems, type) {
  1284. if (pageElems) {
  1285. let url = curSite.pageUrl;
  1286. pageElems = getAllElements(curSite.pager.pageElement, pageElems, pageElems)[0];
  1287. let chapterImages, chapterPath;
  1288. document.querySelector(curSite.pager.pageElement.replace('css;', '')).innerText = pageElems.textContent; // 将当前网页内的数据所在元素内容改为刚刚获取的下一页数据内容,以便循环获取下一页 URL
  1289. pageElems.textContent.split(';').forEach(function (one){ // 分号 ; 分割为数组并遍历
  1290. //console.log(one)
  1291. if (one.indexOf('chapterImages') > -1) { // 图片文件名数组
  1292. chapterImages = one.replace(/^.+\[/, '').replace(']', '').replaceAll('"', '').split(',')
  1293. } else if (one.indexOf('chapterPath') > -1) { // 图片文件路径
  1294. chapterPath = one.split('"')[1];
  1295. } else if (one.indexOf('pageTitle') > -1) { // 网页标题
  1296. let title = one.split('"')[1];
  1297. window.history.pushState(`{title: ${document.title}, url: ${location.href}}`, title, url); // 添加历史记录
  1298. window.document.title = title; // 修改当前网页标题为下一页的标题
  1299. }
  1300. })
  1301. if (chapterImages && chapterPath) {
  1302. let _img = '';
  1303. chapterImages.forEach(function (one2){ // 遍历图片文件名数组,组合为 img 标签
  1304. _img += '<img src="https://res.xiaoqinre.com/' + chapterPath + one2 + '" data-index="0" style="display: inline-block;">'
  1305. })
  1306. document.querySelector(curSite.pager.insertPosition[0].replace('css;', '')).insertAdjacentHTML(addTo(curSite.pager.insertPosition[1]), _img); // 将 img 标签插入到网页中
  1307. }
  1308. }
  1309. }
  1310.  
  1311.  
  1312. // szcdmj 的插入前函数(加载图片)
  1313. function szcdmj_functionBefore(pageElems) {
  1314. pageElems.forEach(function (one) {
  1315. if (one.tagName === 'TITLE') {
  1316. let title = one.textContent;
  1317. window.history.pushState(`{title: ${document.title}, url: ${location.href}}`, title, curSite.pageUrl); // 添加历史记录
  1318. window.document.title = title; // 修改当前网页标题为下一页的标题
  1319. one.style.display = 'none';
  1320. } else {
  1321. let now = one.querySelector('img[data-original]')
  1322. if (now) {
  1323. now.src = now.dataset.original;
  1324. now.style.display = 'inline';
  1325. }
  1326. }
  1327. });
  1328. return pageElems
  1329. }
  1330.  
  1331.  
  1332. // 自动无缝翻页
  1333. function pageLoading() {
  1334. if (curSite.SiteTypeID > 0) {
  1335. windowScroll(function (direction, e) {
  1336. if (direction === 'down' && pausePage === true) { // 下滑/没有暂停翻页时,才准备翻页
  1337. let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop,
  1338. scrollHeight = window.innerHeight || document.documentElement.clientHeight,
  1339. scrollDelta = curSite.pager.scrollDelta;
  1340. if (curSite.pager.type === 3) { // <<<<< 翻页类型 3(依靠元素距离可视区域底部的距离来触发翻页)>>>>>
  1341. let scrollElement = document.querySelector(curSite.pager.scrollElement);
  1342. //console.log(scrollElement.offsetTop - (scrollTop + scrollHeight), scrollDelta, curSite.SiteTypeID)
  1343. if (scrollElement.offsetTop - (scrollTop + scrollHeight) <= scrollDelta) {
  1344. if (curSite.SiteTypeID === SiteType.GAMERSKY_GL) curSite.pager.scrollDelta -= 800 // 游民星空 gl 的比较奇葩,需要特殊处理下
  1345. ShowPager.loadMorePage();
  1346. }
  1347. } else {
  1348. if (document.documentElement.scrollHeight <= scrollHeight + scrollTop + scrollDelta) {
  1349. if (curSite.pager.type === 2) { // <<<<< 翻页类型 2(网站自带了自动无缝翻页功能,只需要点击下一页按钮即可)>>>>>
  1350. if (curSite.SiteTypeID > 0) { // 如果指定了间隔时间,那么就依靠这个判断时间到了没有~
  1351. let autopbn = document.querySelector(curSite.pager.nextLink);
  1352. if (autopbn) { // 寻找下一页链接
  1353. if (!curSite.pager.nextText && !curSite.pager.nextTextOf && !curSite.pager.nextHTML) { // 如果没有指定按钮文字就直接点击
  1354. autopbn.click();
  1355. // 对于没有按钮文字变化的按钮,可以手动指定间隔时间
  1356. if (curSite.pager.intervals) {
  1357. let _SiteTypeID = curSite.SiteTypeID; curSite.SiteTypeID = 0;
  1358. setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals)
  1359. }
  1360. } else { // 避免重复点击翻页按钮
  1361. if (curSite.pager.nextText) { // 按钮文本,当按钮文本 = 该文本时,才会点击按钮加载下一页
  1362. if (autopbn.innerText === curSite.pager.nextText) autopbn.click();
  1363. } else if (curSite.pager.nextTextOf) { // 按钮文本的一部分,当按钮文本包含该文本时,才会点击按钮加载下一页
  1364. if (autopbn.innerText.indexOf(curSite.pager.nextTextOf) > -1) autopbn.click();
  1365. } else if (curSite.pager.nextHTML) { // 按钮内元素,当按钮内元素 = 该元素内容时,才会点击按钮加载下一页
  1366. if (autopbn.innerHTML === curSite.pager.nextHTML) autopbn.click();
  1367. }
  1368. }
  1369. }
  1370. }
  1371. } else if (curSite.pager.type === 1) { // <<<<< 翻页类型 1(由脚本实现自动无缝翻页)>>>>>
  1372. // 为百度贴吧的发帖考虑...
  1373. if (!(document.documentElement.scrollHeight <= scrollHeight + scrollTop + 200 && curSite.SiteTypeID === SiteType.BAIDU_TIEBA)) {
  1374. ShowPager.loadMorePage();
  1375. }
  1376. } else if (curSite.pager.type === 4) { // <<<<< 翻页类型 4(部分简单的动态加载类网站)>>>>>
  1377. if (curSite.SiteTypeID > 0) {
  1378. curSite.pager.nextLink();
  1379. if (curSite.pager.intervals) {
  1380. let _SiteTypeID = curSite.SiteTypeID;
  1381. curSite.SiteTypeID = 0;
  1382. setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals)
  1383. }
  1384. }
  1385. }
  1386. }
  1387. }
  1388. }
  1389. });
  1390. }
  1391. }
  1392.  
  1393.  
  1394. // 启用/禁用 (当前网站)
  1395. function menu_disable(type) {
  1396. switch(type) {
  1397. case 'check':
  1398. if(check()) {return true;} else {return false;}; break;
  1399. case 'add':
  1400. add(); break;
  1401. case 'del':
  1402. del(); break;
  1403. }
  1404.  
  1405. function check() { // 存在返回真,不存在返回假
  1406. let list = GM_getValue('menu_disable'); // 读取网站列表
  1407. if (list.indexOf(location.host) === -1) return false // 不存在返回假
  1408. return true
  1409. }
  1410.  
  1411. function add() {
  1412. if (check()) return
  1413. let list = GM_getValue('menu_disable'); // 读取网站列表
  1414. list.push(location.host); // 追加网站域名
  1415. GM_setValue('menu_disable', list); // 写入配置
  1416. location.reload(); // 刷新网页
  1417. }
  1418.  
  1419. function del() {
  1420. if (!check()) return
  1421. let list = GM_getValue('menu_disable'), // 读取网站列表
  1422. index = list.indexOf(location.host);
  1423. list.splice(index, 1); // 删除网站域名
  1424. GM_setValue('menu_disable', list); // 写入配置
  1425. location.reload(); // 刷新网页
  1426. }
  1427. }
  1428.  
  1429.  
  1430. // 左键双击网页空白处暂停翻页
  1431. function pausePageEvent() {
  1432. if (!GM_getValue('menu_pause_page')) return
  1433. if (curSite.SiteTypeID === 0) return
  1434. document.body.addEventListener('dblclick', function (e) {
  1435. if (pausePage) {
  1436. pausePage = false;
  1437. GM_notification({text: `❌ 已暂停本页 [自动无缝翻页]\n (再次双击可恢复)`, timeout: 2500});
  1438. } else {
  1439. pausePage = true;
  1440. GM_notification({text: `✅ 已恢复本页 [自动无缝翻页]\n (再次双击可暂停)`, timeout: 2500});
  1441. }
  1442. });
  1443. }
  1444.  
  1445.  
  1446. // 菜单开关
  1447. function menu_switch(menu_status, Name, Tips) {
  1448. if (menu_status === true){
  1449. GM_setValue(`${Name}`, false);
  1450. } else {
  1451. GM_setValue(`${Name}`, true);
  1452. }
  1453. location.reload();
  1454. };
  1455.  
  1456.  
  1457. // 生成 ID
  1458. function generateID() {
  1459. let num = 0
  1460. for (let val in DBSite) {
  1461. DBSite[val].SiteTypeID = num = num + 1;
  1462. }
  1463. }
  1464.  
  1465.  
  1466. // 类型 4 专用
  1467. function getPageElems(url, type = 'text', method = 'GET', data = '', type2) {
  1468. //console.log(url, data)
  1469. GM_xmlhttpRequest({
  1470. url: url,
  1471. method: method,
  1472. data: data,
  1473. responseType: type,
  1474. headers: {
  1475. 'Content-Type': (method === 'POST') ? 'application/x-www-form-urlencoded':''
  1476. },
  1477. timeout: 5000,
  1478. onload: function (response) {
  1479. try {
  1480. //console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText)
  1481. switch (type) {
  1482. case 'json':
  1483. curSite.pager.insertElement(response.response, type2);
  1484. break;
  1485. default:
  1486. curSite.pager.insertElement(ShowPager.createDocumentByString(response.responseText), type2)
  1487. }
  1488. } catch (e) {
  1489. console.log(e);
  1490. }
  1491. }
  1492. });
  1493. }
  1494.  
  1495.  
  1496. // 插入位置
  1497. function addTo(num) {
  1498. switch (num) {
  1499. case 1:
  1500. return 'beforebegin'; break;
  1501. case 2:
  1502. return 'afterbegin'; break;
  1503. case 3:
  1504. return 'beforeend'; break;
  1505. case 4:
  1506. return 'afterend'; break;
  1507. }
  1508. }
  1509.  
  1510.  
  1511. // 滚动条事件
  1512. function windowScroll(fn1) {
  1513. var beforeScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  1514. fn = fn1 || function () {};
  1515. setTimeout(function () { // 延时 1 秒执行,避免刚载入到页面就触发翻页事件
  1516. window.addEventListener('scroll', function (e) {
  1517. var afterScrollTop = document.documentElement.scrollTop || document.body.scrollTop,
  1518. delta = afterScrollTop - beforeScrollTop;
  1519. if (delta == 0) return false;
  1520. fn(delta > 0 ? 'down' : 'up', e);
  1521. beforeScrollTop = afterScrollTop;
  1522. }, false);
  1523. }, 1000)
  1524. }
  1525.  
  1526.  
  1527. // 修改自 https://greasyfork.org/scripts/14178 , https://github.com/machsix/Super-preloader
  1528. var ShowPager = {
  1529. getFullHref: function (e) {
  1530. if (e != null && e.nodeType === 1 && e.href && e.href.slice(0,4) === 'http') return e.href;
  1531. return '';
  1532. },
  1533. createDocumentByString: function (e) {
  1534. if (e) {
  1535. if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml');
  1536. var t;
  1537. try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {}
  1538. if (t) return t;
  1539. if (document.implementation.createHTMLDocument) {
  1540. t = document.implementation.createHTMLDocument('ADocument');
  1541. } else {
  1542. 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) {}
  1543. }
  1544. if (t) {
  1545. var r = document.createRange(),
  1546. n = r.createContextualFragment(e);
  1547. r.selectNodeContents(document.body);
  1548. t.body.appendChild(n);
  1549. 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);
  1550. return t;
  1551. }
  1552. } else console.error('没有找到要转成 DOM 的字符串');
  1553. },
  1554. loadMorePage: function () {
  1555. if (curSite.pager) {
  1556. var url;
  1557. if (typeof curSite.pager.nextLink == 'function') {
  1558. url = curSite.pager.nextLink();
  1559. } else {
  1560. let curPageEle = getElementByXpath(curSite.pager.nextLink);
  1561. url = this.getFullHref(curPageEle);
  1562. }
  1563. //let curPageEle = getElementByXpath(curSite.pager.nextLink);
  1564. //var url = this.getFullHref(curPageEle);
  1565. console.log(url, curSite.pageUrl);
  1566. if (url === '') return;
  1567. if (curSite.pageUrl === url) return;// 避免重复加载相同的页面
  1568. curSite.pageUrl = url;
  1569. if (curSite.SiteTypeID === SiteType.BAIDU_TIEBA) {
  1570. url = url + '&pagelets=frs-list%2Fpagelet%2Fthread&pagelets_stamp=' + new Date().getTime();
  1571. }
  1572. let mimeType = '';
  1573. if (curSite.pager.mimeType) mimeType = curSite.pager.mimeType;
  1574. // 读取下一页的数据
  1575. GM_xmlhttpRequest({
  1576. url: url,
  1577. method: 'GET',
  1578. overrideMimeType: mimeType,
  1579. headers: {
  1580. "Referer": location.href
  1581. },
  1582. timeout: 5000,
  1583. onload: function (response) {
  1584. try {
  1585. console.log('最终 URL:' + response.finalUrl, '返回内容:' + response.responseText)
  1586. var newBody = ShowPager.createDocumentByString(response.responseText);
  1587. let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody),
  1588. toElement = getAllElements(curSite.pager.insertPosition[0])[0];
  1589. console.log(curSite.pager.pageElement, pageElems)
  1590.  
  1591. if (pageElems.length >= 0) {
  1592. // 如果有插入前函数就执行函数
  1593. if (curSite.function && curSite.function.before) {
  1594. if (curSite.function.parameter) { // 如果指定了参数
  1595. pageElems = curSite.function.before(curSite.function.parameter);
  1596. } else {
  1597. pageElems = curSite.function.before(pageElems);
  1598. }
  1599. }
  1600.  
  1601. // 插入位置
  1602. let addTo1 = addTo(curSite.pager.insertPosition[1]);
  1603.  
  1604. // 插入新页面元素
  1605. if (curSite.SiteTypeID === SiteType.STEAMCOMMUNITY) {
  1606. pageElems.forEach(function (one) {
  1607. if (one.tagName === 'SCRIPT') { // 对于 <script> 需要用另一种方式插入网页,以便正常运行
  1608. toElement.appendChild(document.createElement('script')).innerHTML = one.textContent;
  1609. } else {
  1610. toElement.insertAdjacentElement(addTo1, one); // 继续插入网页主体元素
  1611. }
  1612. });
  1613. } else if (curSite.SiteTypeID != SiteType.BAIDU_TIEBA) {
  1614. pageElems.forEach(function (one) {toElement.insertAdjacentElement(addTo1, one);});
  1615. }
  1616.  
  1617. // 对于 <script> 需要用另一种方式插入网页,以便正常运行
  1618. if (curSite.SiteTypeID === SiteType.GOOGLE) {
  1619. const scriptElems = getAllElements('//script', newBody, newBody);
  1620. let scriptText = '';
  1621. scriptElems.forEach(function (one) {scriptText += one.innerHTML;});
  1622. toElement.appendChild(document.createElement('script')).innerHTML = scriptText;
  1623. }
  1624.  
  1625. // 对于百度贴吧这种动态加载内容的网站需要单独处理
  1626. if (curSite.SiteTypeID === SiteType.BAIDU_TIEBA) {
  1627. const scriptElems = getAllElements('//script', newBody, newBody);
  1628. let scriptText = '';
  1629. for (let i = 0; i < scriptElems.length; i++) {
  1630. if (scriptElems[i].textContent.indexOf('Bigpipe.register("frs-list/pagelet/thread_list"') > -1) {
  1631. scriptText = scriptElems[i].textContent.replace('Bigpipe.register("frs-list/pagelet/thread_list", ','');
  1632. break
  1633. }
  1634. }
  1635. if (scriptText) {
  1636. scriptText = scriptText.slice(0, scriptText.indexOf(').')) // 获取主体内容
  1637. let scriptJSON = JSON.parse(scriptText).content; // 字符串转 JSON
  1638. var temp_baidu_tieba = document.createElement('div'); temp_baidu_tieba.innerHTML = scriptJSON; // 字符串转 Element 元素
  1639. pageElems = curSite.function.before(getAllElements(curSite.pager.pageElement, temp_baidu_tieba, temp_baidu_tieba)); // 插入前执行函数
  1640. pageElems.forEach(function (one) {toElement.insertAdjacentElement(addTo1, one);}); // 插入元素
  1641. }
  1642. //toElement.appendChild(document.createElement('script')).innerHTML = scriptText;
  1643. }
  1644.  
  1645. // 替换待替换元素
  1646. try {
  1647. let oriE = getAllElements(curSite.pager.replaceE), repE;
  1648. if (curSite.SiteTypeID === SiteType.BAIDU_TIEBA) {
  1649. repE = getAllElements(curSite.pager.replaceE, temp_baidu_tieba, temp_baidu_tieba);
  1650. } else {
  1651. repE = getAllElements(curSite.pager.replaceE, newBody, newBody);
  1652. }
  1653. if (oriE.length === repE.length) {
  1654. for (let i = 0; i < oriE.length; i++) {
  1655. oriE[i].outerHTML = repE[i].outerHTML;
  1656. }
  1657. }
  1658. } catch (e) {
  1659. console.log(e);
  1660. }
  1661. // 如果有插入后函数就执行函数
  1662. if (curSite.function && curSite.function.after) {
  1663. if (curSite.function.parameter) { // 如果指定了参数
  1664. curSite.function.after(curSite.function.parameter);
  1665. } else {
  1666. curSite.function.after();
  1667. }
  1668. }
  1669. }
  1670. } catch (e) {
  1671. console.log(e);
  1672. }
  1673. }
  1674. });
  1675. }
  1676. },
  1677. };
  1678.  
  1679. function getElementByCSS(css, contextNode = document) {
  1680. return contextNode.querySelector(css);
  1681. }
  1682. function getAllElementsByCSS(css, contextNode = document) {
  1683. return [].slice.call(contextNode.querySelectorAll(css));
  1684. }
  1685. function getElementByXpath(xpath, contextNode, doc = document) {
  1686. contextNode = contextNode || doc;
  1687. try {
  1688. const result = doc.evaluate(xpath, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  1689. // 应该总是返回一个元素节点
  1690. return result.singleNodeValue && result.singleNodeValue.nodeType === 1 && result.singleNodeValue;
  1691. } catch (err) {
  1692. throw new Error(`Invalid xpath: ${xpath}`);
  1693. }
  1694. }
  1695. function getAllElementsByXpath(xpath, contextNode, doc = document) {
  1696. contextNode = contextNode || doc;
  1697. const result = [];
  1698. try {
  1699. const query = doc.evaluate(xpath, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1700. for (let i = 0; i < query.snapshotLength; i++) {
  1701. const node = query.snapshotItem(i);
  1702. // 如果是 Element 节点
  1703. if (node.nodeType === 1) result.push(node);
  1704. }
  1705. } catch (err) {
  1706. throw new Error(`无效 Xpath: ${xpath}`);
  1707. }
  1708. return result;
  1709. }
  1710. function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) {
  1711. if (!selector) return [];
  1712. contextNode = contextNode || doc;
  1713. if (typeof selector === 'string') {
  1714. if (selector.search(/^css;/i) === 0) {
  1715. return getAllElementsByCSS(selector.slice(4), contextNode);
  1716. } else {
  1717. return getAllElementsByXpath(selector, contextNode, doc);
  1718. }
  1719. } else {
  1720. const query = selector(doc, win, _cplink);
  1721. if (!Array.isArray(query)) {
  1722. throw new Error('getAllElements 返回错误类型');
  1723. } else {
  1724. return query;
  1725. }
  1726. }
  1727. }
  1728. })();