Greasy Fork

来自缓存

Greasy Fork is available in English.

Magnet Hash Autolinker

Converts 40-char hex hashes into clickable magnet links

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
chimez
日安装量
0
总安装量
4
评分
0 0 0
版本
1.0
创建于
2026-01-07
更新于
2026-01-07
大小
4.6 KB
许可证
MIT
适用于
所有网站

🧲 Magnet Hash Autolinker

Turn plain text 40-character hexadecimal hashes into clickable Magnet links automatically.


📖 Overview

Have you ever browsed a forum, tracker, or pastebin where users share BitTorrent info hashes as plain text (e.g., eae4e4eeaf7096dad1e876efd894125e4a1baa3b) instead of clickable links?

This script solves that problem. It scans the webpage, detects valid SHA-1 hashes, and converts them into clickable magnet: links instantly.

✨ Features

  • Smart Detection: Uses Regex to strictly match 40-character hexadecimal strings (case-insensitive).
  • Safe Replacement:
    • It ignores hashes inside <input>, <textarea>, <script>, <style>, and existing <a> tags to prevent breaking page functionality.
    • It uses a TreeWalker to modify text nodes directly, preserving event listeners on parent elements.
  • Dynamic Support: Includes a MutationObserver. If you scroll down on a page with "Infinite Scroll" or load content via AJAX, the new hashes will be autolinked automatically.
  • Visual Cues: Converted links are styled (Green + Bold) so you can easily spot them.

🔍 Example

Before:

Here is the hash for the file: 5b3267325e3d233c675f3243f234567890abcdef

After:

Here is the hash for the file: 5b3267325e3d233c675f3243f234567890abcdef

⚙️ How it works

  1. The script runs immediately when the page loads.
  2. It identifies text patterns matching \b[a-fA-F0-9]{40}\b.
  3. It wraps the hash in an anchor tag: magnet:?xt=urn:btih:[HASH].

🛠️ Installation

  1. Install a userscript manager like Tampermonkey (Chrome/Edge/Safari) or Violentmonkey (Firefox).
  2. Click the green "Install this script" button on this page.
  3. Visit any page containing plain text hashes and enjoy!

🎨 Customization

If you want to change the color of the generated links, look for this section in the code:

a.style.color = 'green'; // Change 'green' to 'red', '#ff0000', etc.
a.style.fontWeight = 'bold';