自动无缝翻页

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