Created
June 27, 2012 11:54
-
-
Save thomasbrus/3003624 to your computer and use it in GitHub Desktop.
dotjs script that turns torrentz.eu search results into magnet uri's.
This file contains 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
class MagnetURI | |
@compile: (hash, title) -> | |
'magnet:?' + [ | |
"xt=urn:btih:#{hash}" | |
"dn=#{encodeURIComponent(title)}", | |
"tr=#{encodeURIComponent('udp://tracker.openbittorrent.com:80/announce')}", | |
"tr=#{encodeURIComponent('udp://tracker.1337x.org:80/announce')}", | |
"tr=#{encodeURIComponent('http://tracker.publicbt.com/announce')}" | |
].join '&' | |
class Magnify | |
constructor: (links) -> | |
links.each -> | |
$link = $(this) | |
hash = $link.attr('href').substr(1) | |
title = $link.text() | |
$link.before $('<a>✓ Download</a>') | |
.attr(href: MagnetURI.compile(hash, title)) | |
.css(color: '#79CC53', marginRight: 8) | |
# Remove sponsored links | |
$('.sponsored').remove() | |
# Wait for ajax content to load | |
$('body > div').each -> | |
if /r[a-z0-9]{32}|popular/.test $(this).attr('id') | |
$(this).one 'DOMNodeInserted', (event) -> | |
new Magnify $(event.target).find('dl > dt > a') | |
new Magnify $('.results > dl > dt > a') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment