自动无缝翻页

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

QingJ © 2025

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