自动无缝翻页

无缝拼接下一页内容,目前支持:[所有使用「Discuz!、Flarum、DUX(WordPress)」的网站]、百度、谷歌、必应、贴吧、豆瓣、微博、V2EX、超能网、IT之家、千图网、Pixabay、3DM、游侠网、游民星空、Steam 创意工坊、小霸王其乐无穷、片库、音范丝、爱恋动漫、SrkBT、RARBG、423Down、不死鸟、小众软件、极简插件、乐软博客、不忘初心、果核剥壳、六音软件、微当下载、th-sjy汉化、异次元软件、老殁殁漂遥、异星软件空间、动漫狂、漫画DB、HiComic(嗨漫画)、古风漫画网、砂之船动漫家、PubMed、AfreecaTV、GreasyFork、CS.RIN.RU、Crackhub213、FitGirl Repacks...

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

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

QingJ © 2025

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