Last active
October 22, 2015 06:27
-
-
Save loadletter/ed6752a43e0c4da41de1 to your computer and use it in GitHub Desktop.
Add a link to torrent file for magnet only websites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Magnet2Torrent | |
// @namespace loadletter | |
// @match *://btdigg.org/search* | |
// @match *://btindex.org/* | |
// @version 2 | |
// @grant none | |
// ==/UserScript== | |
Array.forEach(document.getElementsByTagName('a'), change_links); | |
function change_links(a) | |
{ | |
if(!a.href.startsWith('magnet')) | |
return; | |
var mag = /magnet:\?xt=urn:btih:([A-Fa-f0-9]{40})/.exec(a.href); | |
a.href = 'http://torrage.com/torrent/' + String(mag[mag.length - 1]).toUpperCase() + '.torrent'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment