自动无缝翻页

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