磁力链接提取器

提取该网页的所有磁力链接

  1. // ==UserScript==
  2. // @name 磁力链接提取器
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 提取该网页的所有磁力链接
  6. // @match http://*/*
  7. // @match https://*/*
  8. // @grant none
  9. // @license GPL-3.0 License
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 提取磁力链接并显示在弹出窗口中
  16. function extractMagnetLinks() {
  17. var magnetLinks = [];
  18.  
  19. // 遍历所有链接
  20. var linkElements = document.getElementsByTagName('a');
  21. for (var i = 0; i < linkElements.length; i++) {
  22. var linkElement = linkElements[i];
  23. var link = linkElement.href;
  24. if (link.startsWith('magnet:')) {
  25. magnetLinks.push(link);
  26. }
  27. }
  28.  
  29. // 遍历所有文本节点
  30. var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
  31. while (walker.nextNode()) {
  32. var node = walker.currentNode;
  33. var text = node.textContent.trim();
  34. if (text.startsWith('magnet:')) {
  35. magnetLinks.push(text);
  36. }
  37. }
  38.  
  39. return magnetLinks;
  40. }
  41.  
  42. function displayMagnetLinks(magnetLinks) {
  43. var popup = window.open('', 'magnetLinksPopup', 'width=800,height=600,scrollbars=yes,resizable=yes');
  44. popup.document.write('<html><head><title>磁力链接列表</title>');
  45. popup.document.write('<style>body {font-family: Arial, sans-serif; font-size: 14px; margin: 0; padding: 20px;}');
  46. popup.document.write('h1 {font-size: 24px; margin: 0 0 20px; padding: 0;}');
  47. popup.document.write('ul {margin: 0; padding: 0;}');
  48. popup.document.write('li {list-style-type: none; margin: 0 0 10px; padding: 0;}');
  49. popup.document.write('a {text-decoration: none; color: #333; font-weight: bold;}');
  50. popup.document.write('a:hover {color: #007bff;}</style>');
  51. popup.document.write('</head><body>');
  52. popup.document.write('<h1>磁力链接列表</h1>');
  53. popup.document.write('<ul>');
  54. magnetLinks.forEach(function(link) {
  55. popup.document.write('<li><a href="' + link + '">' + link + '</a></li>');
  56. });
  57. popup.document.write('</ul>');
  58. popup.document.write('</body></html>');
  59. popup.document.close();
  60. }
  61.  
  62. // 创建提取磁力链接按钮
  63. var button = document.createElement('button');
  64. button.innerHTML = '提取磁力链接';
  65. button.style.position = 'fixed';
  66. button.style.bottom = '20px';
  67. button.style.right = '20px';
  68. button.style.zIndex = 9999;
  69. button.style.padding = '10px';
  70. button.style.borderRadius = '50%';
  71. button.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
  72. button.style.backgroundColor = '#007bff';
  73. button.style.color = '#fff';
  74. button.style.fontFamily = 'Arial, sans-serif';
  75. button.style.fontSize = '14px';
  76. button.style.fontWeight = 'bold';
  77. button.style.cursor = 'pointer';
  78.  
  79. // 提取磁力链接按钮点击事件
  80. button.addEventListener('click', function() {
  81. var magnetLinks = extractMagnetLinks();
  82. displayMagnetLinks(magnetLinks);
  83. });
  84.  
  85. // 将按钮添加到页面中
  86. document.body.appendChild(button);
  87. })();

QingJ © 2025

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