自动无缝翻页

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

当前为 2021-08-19 提交的版本,查看 最新版本

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