auto-open-sheet

自动打开当前页的种子!,配合auto-say-hello-plus插件有意想不到的效果!如果未匹配成功请联系我:960487551@qq.com

目前为 2025-02-04 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name auto-open-sheet
  3. // @namespace http://tampermonkey.net/
  4. // @description:zh-CN 自动打开当前页的种子!,配合auto-say-hello-plus插件有意想不到的效果!如果未匹配成功请联系我:960487551@qq.com
  5. // @description:en Automatically open the torrent on the current page! Combined with the auto-say-hello-plus plugin, it delivers unexpected results! If it fails to match successfully, please contact me: 960487551@qq.com
  6. // @license MIT
  7. // @author wiiii
  8. // @version 1.0.1
  9. // @email 960487551@qq.com
  10. // @copyright (c) 2025-01-01
  11. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  12. // @match *://pt.m-team.cc/*torrents.php*
  13. // @match *://kp.m-team.cc/*torrents.php*
  14. // @match *://xp.m-team.io/*torrents.php*
  15. // @match *://pt.btschool.club/torrents.php*
  16. // @match *://www.haidan.video/torrents.php*
  17. // @match *://www.hddolby.com/torrents.php*
  18. // @match *://www.hdarea.co/torrents.php*
  19. // @match *://hdatmos.club/torrents.php*
  20. // @match *://hdhome.org/torrents.php*
  21. // @match *://hdsky.me/torrents.php*
  22. // @match *://hdtime.org/torrents.php*
  23. // @match *://hhanclub.top/torrents.php*
  24. // @match *://lemonhd.org/details*
  25. // @match *://pt.soulvoice.club/torrents.php*
  26. // @match *://avgv.cc/torrents.php*
  27. // @match *://ptsbao.club/torrents.php*
  28. // @match *://www.beitai.pt/torrents.php*
  29. // @match *://et8.org/torrents.php*
  30. // @match *://pt.eastgame.org/torrents.php*
  31. // @match *://pthome.net/torrents.php*
  32. // @match *://pterclub.com/torrents.php*
  33. // @match *://ourbits.club/torrents.php*
  34. // @match *://hdzone.me/torrents.php*
  35. // @match *://pt.msg.vg/torrents.php*
  36. // @match *://hdfans.org/torrents.php*
  37. // @match *://rousi.zip/torrents.php*
  38. // @match *://carpt.net/torrents.php*
  39. // @match *://www.tjupt.org/torrents.php*
  40. // @match *://yingk.com/torrents.php*
  41. // @match *://www.dragonhd.xyz/torrents.php*
  42. // @match *://chdbits.co/torrents.php*
  43. // @grant none
  44. // @description 自动打开当前页的种子!,配合auto-say-hello-plus插件有意想不到的效果!如果未匹配成功请联系我:960487551@qq.com
  45. // ==/UserScript==
  46.  
  47.  
  48. (function () {
  49. 'use strict';
  50.  
  51. // 配置参数
  52. const maxLinksToOpen = 10; // 最多同时打开的链接数
  53. const minIntervalTime = 3000; // 每次打开的最小间隔(毫秒)
  54. const maxIntervalTime = 10000; // 每次打开的最大间隔(毫秒)
  55. const storageKey = 'openedLinks'; // localStorage 键名,用于记录已打开的链接
  56. const userPromptKey = 'userPrompt'; // localStorage 键名,用于记录用户选择和时间
  57. const regex = /^details\.php\?id=(\d+)&hit=1$/; // 链接匹配规则
  58.  
  59. // 辅助函数:获取当前时间的时间戳
  60. function getCurrentTimestamp() {
  61. return new Date().getTime(); // 获取时间戳(毫秒)
  62. }
  63.  
  64. // 辅助函数:获取用户提示记录
  65. function getUserPromptRecord() {
  66. return JSON.parse(localStorage.getItem(userPromptKey));
  67. }
  68.  
  69. // 辅助函数:保存用户提示记录
  70. function saveUserPromptRecord(confirmed) {
  71. const record = {
  72. confirmed, // 用户选择:true 表示确认开启,false 表示取消
  73. timestamp: getCurrentTimestamp() // 当前时间
  74. };
  75. localStorage.setItem(userPromptKey, JSON.stringify(record));
  76. }
  77.  
  78. // 辅助函数:获取已打开链接记录
  79. function getOpenedLinks() {
  80. return JSON.parse(localStorage.getItem(storageKey)) || [];
  81. }
  82.  
  83. // 辅助函数:保存已打开链接记录
  84. function saveOpenedLinks(openedLinks) {
  85. localStorage.setItem(storageKey, JSON.stringify(openedLinks));
  86. }
  87.  
  88. // 辅助函数:在右上角显示提示信息
  89. function showNotification(message) {
  90. // 创建提示框容器
  91. const notification = document.createElement('div');
  92. notification.textContent = message;
  93. notification.style.position = 'fixed';
  94. notification.style.top = '20px';
  95. notification.style.right = '20px';
  96. notification.style.zIndex = '9999';
  97. notification.style.backgroundColor = '#007bff';
  98. notification.style.color = '#fff';
  99. notification.style.padding = '10px 20px';
  100. notification.style.borderRadius = '5px';
  101. notification.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
  102. notification.style.fontFamily = 'Arial, sans-serif';
  103. notification.style.fontSize = '14px';
  104.  
  105. // 添加到页面中
  106. document.body.appendChild(notification);
  107.  
  108. // 设置定时器,3秒后自动移除提示
  109. setTimeout(() => {
  110. notification.remove();
  111. }, 3000);
  112. }
  113.  
  114. // 主逻辑:后台打开符合条件的链接
  115. function startOpeningLinks() {
  116. const openedLinks = getOpenedLinks(); // 获取已打开的链接记录
  117. const links = document.querySelectorAll('a'); // 获取页面中所有的 <a> 标签
  118.  
  119. // 筛选出符合条件的链接
  120. const matchedLinks = [];
  121. links.forEach(link => {
  122. const href = link.getAttribute('href');
  123. if (href && regex.test(href)) {
  124. const match = href.match(regex);
  125. const id = match[1]; // 提取链接中的 ID
  126. const domainWithId = `${location.hostname}:${id}`; // 组合为 "域名:ID"
  127.  
  128. if (!openedLinks.includes(domainWithId)) {
  129. matchedLinks.push({ link, domainWithId }); // 存储符合条件的链接和 ID
  130. }
  131. }
  132. });
  133.  
  134. if (matchedLinks.length === 0) {
  135. // 当前页面所有链接都已访问过,右上角提示用户打开下一页
  136. showNotification('当前页面的所有链接都已打开,请打开下一页!');
  137. console.log('%c 当前页面的所有链接都已打开,请打开下一页!', 'color: orange;');
  138. return;
  139. }
  140.  
  141. console.log(`%c 找到 ${matchedLinks.length} 个符合条件的未访问链接,最多打开 ${maxLinksToOpen} 个。`, 'color: blue;');
  142. console.table(matchedLinks);
  143.  
  144. // 限制最多打开的链接数量
  145. const linksToOpen = matchedLinks.slice(0, maxLinksToOpen);
  146.  
  147. let index = 0;
  148.  
  149. // 递归方式逐一打开链接
  150. function openNextLink() {
  151. if (index >= linksToOpen.length) {
  152. console.log('%c 所有链接已按设置打开,任务完成。', 'color: green;');
  153. return; // 所有链接已打开,退出递归
  154. }
  155.  
  156. const { link, domainWithId } = linksToOpen[index];
  157.  
  158. try {
  159. // 使用 window.open 打开链接,并确保当前页面视角不切换
  160. window.open(link.href, '_blank', 'noopener,noreferrer');
  161. console.log(`%c 成功后台打开链接 (${index + 1}/${linksToOpen.length}): ${link.href}`, 'color: green;');
  162.  
  163. // 记录已打开链接
  164. openedLinks.push(domainWithId);
  165. saveOpenedLinks(openedLinks);
  166. } catch (error) {
  167. console.log(`%c 打开链接失败 (${index + 1}/${linksToOpen.length}): ${link.href}`, 'color: red;', error);
  168. }
  169.  
  170. index++; // 处理下一个链接
  171.  
  172. // 随机设置下一个打开的时间间隔
  173. const randomInterval = Math.floor(Math.random() * (maxIntervalTime - minIntervalTime + 1)) + minIntervalTime;
  174. console.log(`%c 下一个链接将在 ${randomInterval / 1000} 秒后尝试打开。`, 'color: orange;');
  175.  
  176. setTimeout(openNextLink, randomInterval); // 递归调用
  177. }
  178.  
  179. // 开始递归调用
  180. openNextLink();
  181. }
  182.  
  183. // 页面加载时执行主逻辑
  184. window.onload = function () {
  185. const record = getUserPromptRecord();
  186.  
  187. // 如果用户已开启功能,直接执行打开链接逻辑
  188. if (record && record.confirmed) {
  189. console.log('%c 功能已开启,直接执行打开链接逻辑。', 'color: green;');
  190. startOpeningLinks();
  191. } else {
  192. console.log('%c 功能未开启,跳过打开链接逻辑。', 'color: orange;');
  193. }
  194. };
  195. })();
  196.  
  197.  
  198.  
  199.