自动无缝翻页

无缝拼接下一页内容,目前支持:[所有使用「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-23 提交的版本,查看 最新版本

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