auto-open-sheet

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

  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.3
  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. // @match *://www.nicept.net/torrents.php*
  44. // @grant none
  45. // @description 自动打开当前页的种子!,配合auto-say-hello-plus插件有意想不到的效果!如果未匹配成功请联系我:960487551@qq.com
  46. // ==/UserScript==
  47.  
  48.  
  49. (function () {
  50. 'use strict';
  51.  
  52. // 配置参数
  53. const maxLinksToOpen = 10; // 最多同时打开的链接数
  54. const minIntervalTime = 1000; // 每次打开的最小间隔(毫秒)
  55. const maxIntervalTime = 3000; // 每次打开的最大间隔(毫秒)
  56. const storageKey = 'openedLinks'; // localStorage 键名,用于记录已打开的链接
  57. const userPromptKey = 'userPrompt'; // localStorage 键名,用于记录用户选择和时间
  58. const regex = /^details\.php\?id=(\d+)&hit=1$/; // 链接匹配规则
  59.  
  60. // 辅助函数:获取当前时间的时间戳
  61. function getCurrentTimestamp() {
  62. return new Date().getTime(); // 获取时间戳(毫秒)
  63. }
  64.  
  65. // 辅助函数:获取用户提示记录
  66. function getUserPromptRecord() {
  67. return JSON.parse(localStorage.getItem(userPromptKey));
  68. }
  69.  
  70. // 辅助函数:保存用户提示记录
  71. function saveUserPromptRecord(confirmed) {
  72. const record = {
  73. confirmed, // 用户选择:true 表示确认开启,false 表示取消
  74. timestamp: getCurrentTimestamp() // 当前时间
  75. };
  76. localStorage.setItem(userPromptKey, JSON.stringify(record));
  77. }
  78.  
  79. // 辅助函数:获取已打开链接记录
  80. function getOpenedLinks() {
  81. return JSON.parse(localStorage.getItem(storageKey)) || [];
  82. }
  83.  
  84. // 辅助函数:保存已打开链接记录
  85. function saveOpenedLinks(openedLinks) {
  86. localStorage.setItem(storageKey, JSON.stringify(openedLinks));
  87. }
  88.  
  89. // 辅助函数:在右上角显示提示信息
  90. function showNotification(message) {
  91. // 创建提示框容器
  92. const notification = document.createElement('div');
  93. notification.textContent = message;
  94. notification.style.position = 'fixed';
  95. notification.style.top = '20px';
  96. notification.style.right = '20px';
  97. notification.style.zIndex = '9999';
  98. notification.style.backgroundColor = '#007bff';
  99. notification.style.color = '#fff';
  100. notification.style.padding = '10px 20px';
  101. notification.style.borderRadius = '5px';
  102. notification.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
  103. notification.style.fontFamily = 'Arial, sans-serif';
  104. notification.style.fontSize = '14px';
  105.  
  106. // 添加到页面中
  107. document.body.appendChild(notification);
  108.  
  109. // 设置定时器,3秒后自动移除提示
  110. setTimeout(() => {
  111. notification.remove();
  112. }, 3000);
  113. }
  114.  
  115. // 主逻辑:后台打开符合条件的链接
  116. function startOpeningLinks() {
  117. const openedLinks = getOpenedLinks(); // 获取已打开的链接记录
  118. const links = document.querySelectorAll('a'); // 获取页面中所有的 <a> 标签
  119.  
  120. // 筛选出符合条件的链接
  121. const matchedLinks = [];
  122. links.forEach(link => {
  123. const href = link.getAttribute('href');
  124. if (href && regex.test(href)) {
  125. const match = href.match(regex);
  126. const id = match[1]; // 提取链接中的 ID
  127. const domainWithId = `${location.hostname}:${id}`; // 组合为 "域名:ID"
  128.  
  129. if (!openedLinks.includes(domainWithId)) {
  130. matchedLinks.push({ link, domainWithId }); // 存储符合条件的链接和 ID
  131. }
  132. }
  133. });
  134.  
  135. if (matchedLinks.length === 0) {
  136. // 当前页面所有链接都已访问过,右上角提示用户打开下一页
  137. showNotification('当前页面的所有链接都已打开,请打开下一页!');
  138. console.log('%c 当前页面的所有链接都已打开,请打开下一页!', 'color: orange;');
  139. return;
  140. }
  141.  
  142. console.log(`%c 找到 ${matchedLinks.length} 个符合条件的未访问链接,最多打开 ${maxLinksToOpen} 个。`, 'color: blue;');
  143. console.table(matchedLinks);
  144.  
  145. // 限制最多打开的链接数量
  146. const linksToOpen = matchedLinks.slice(0, maxLinksToOpen);
  147.  
  148. let index = 0;
  149.  
  150. // 递归方式逐一打开链接
  151. function openNextLink() {
  152. if (index >= linksToOpen.length) {
  153. console.log('%c 所有链接已按设置打开,任务完成。', 'color: green;');
  154. return; // 所有链接已打开,退出递归
  155. }
  156.  
  157. const { link, domainWithId } = linksToOpen[index];
  158.  
  159. try {
  160. // 使用 window.open 打开链接,并确保当前页面视角不切换
  161. window.open(link.href, '_blank', 'noopener,noreferrer');
  162. console.log(`%c 成功后台打开链接 (${index + 1}/${linksToOpen.length}): ${link.href}`, 'color: green;');
  163.  
  164. // 记录已打开链接
  165. openedLinks.push(domainWithId);
  166. saveOpenedLinks(openedLinks);
  167. } catch (error) {
  168. console.log(`%c 打开链接失败 (${index + 1}/${linksToOpen.length}): ${link.href}`, 'color: red;', error);
  169. }
  170.  
  171. index++; // 处理下一个链接
  172.  
  173. // 随机设置下一个打开的时间间隔
  174. const randomInterval = Math.floor(Math.random() * (maxIntervalTime - minIntervalTime + 1)) + minIntervalTime;
  175. console.log(`%c 下一个链接将在 ${randomInterval / 1000} 秒后尝试打开。`, 'color: orange;');
  176.  
  177. setTimeout(openNextLink, randomInterval); // 递归调用
  178. }
  179.  
  180. // 开始递归调用
  181. openNextLink();
  182. }
  183.  
  184. // 页面加载时执行主逻辑
  185. window.onload = function () {
  186. const record = getUserPromptRecord();
  187.  
  188. // 如果用户已开启功能,直接执行打开链接逻辑
  189. if (record && record.confirmed) {
  190. console.log('%c 功能已开启,直接执行打开链接逻辑。', 'color: green;');
  191. startOpeningLinks();
  192. } else {
  193. // 如果记录为 null,提示用户是否开启功能
  194. if (record === null) {
  195. const userResponse = confirm("是否开启自动打开链接的功能?");
  196. saveUserPromptRecord(userResponse); // 保存用户选择
  197.  
  198. if (userResponse) {
  199. console.log('%c 用户选择开启功能,直接执行打开链接逻辑。', 'color: green;');
  200. startOpeningLinks();
  201. } else {
  202. console.log('%c 用户选择不开启功能,跳过打开链接逻辑。', 'color: orange;');
  203. }
  204. } else {
  205. console.log('%c 功能未开启,跳过打开链接逻辑。', 'color: orange;');
  206. }
  207. }
  208. };
  209. })();
  210.  
  211.  
  212.  
  213.