auto open link from the list

auto open link from the list for carpt

  1. // ==UserScript==
  2. // @name auto open link from the list
  3. // @namespace https://carpt.net/
  4. // @version 2024-01-31
  5. // @description auto open link from the list for carpt
  6. // @author Cccor
  7. // @match https://carpt.net/torrents.php*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=carpt.net
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. window.onbeforeunload = function() {
  16. return "确定要离开当前页面吗?";
  17. };
  18.  
  19. // 创建并添加按钮
  20. const createButton = (start, end) => {
  21. const button = document.createElement('button');
  22. button.textContent = `${start + 1}~${end}`;
  23. button.addEventListener('click', () => openPageRange(start, end));
  24. return button;
  25. };
  26.  
  27. // 在页面上添加所有的按钮
  28. const addButtonToPage = () => {
  29. const searchButton = document.querySelector('input[value="给我搜"]');
  30. const container = searchButton.closest('td');
  31.  
  32. for (let i = 0; i < 10; i++) {
  33. const start = i * 10;
  34. const end = (i + 1) * 10 - 1;
  35. const button = createButton(start, end);
  36. container.appendChild(button);
  37. }
  38. };
  39.  
  40. // 打开指定范围内的链接
  41. const openPageRange = (start, end) => {
  42. const tables = document.querySelectorAll('table.torrentname');
  43. const downloadImgs = Array.from(tables).slice(start, end + 1).flatMap(table =>
  44. Array.from(table.querySelectorAll('img[title="下载本种"]'))
  45. );
  46.  
  47. downloadImgs.forEach(img => {
  48. const downloadLink = img.closest('a');
  49. if (downloadLink && downloadLink.href) {
  50. window.open(downloadLink.href, '_blank');
  51. }
  52. });
  53. };
  54.  
  55. addButtonToPage();
  56. })();

QingJ © 2025

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