Greasemonkey user script: Better torrentz.com

Posted: December 25th, 2009 | Author: | Filed under: Greasemonkey scripts, Javascript | Tags: , | 2 Comments »

I recently started downloading a TV show using torrentz.com, and got really annoyed at how hard it is to download every episode.

You have to search for it, open the torrentz.com page for it, pick one of the trackers, go to the tracker site,  download the .torrent file from there, go back to torrentz.com page, click the “µTorrent compatible list” link, copy the trackers list from there to utorrent, and go back to search for the next episode.

I see no reason not to have everything directly on the torrentz.com page for the torrent, so I created a Greasemonkey script to to do just that.

The script changes (some of the) links to the trackers page in direct links to the .torrent file (while hiding the referrer, because some trackers didn’t like other sites linking directly to the .torrent file), the direct links to .torrent files are changed to be colored in black.

It also adds a big “download .torrent” link above the links to the trackers, with the first .torrent file it finds and changes the (useless) list of trackers URLs with a textarea that you can copy directly to uTorrent using some AJAX.

I find it quite useful and time saving, and thought someone out there might like it too:

Download / Install / View source

You need to be using Firefox and have the Greasemonkey extension installed (direct link to .xpi file) to use this.


How to create a link that doesn’t send a referrer header

Posted: December 25th, 2009 | Author: | Filed under: Javascript, Web Development | Tags: , , , , | 1 Comment »

I was looking for a way to create a link that won’t send a referrer header at all, for my torrentz.com greasemonkey script (some trackers didn’t like other sites linking directly to their .torrent file), and came up with that (with the help of a Christmas present from anonymous).

It should work on all browsers who supports the data: URI schema with navigable content, which means it won’t work on Internet Explorer 6, 7 (who doesn’t support the data URI at all), 8 (who doesn’t allow navigable content) or old versions of other browsers (one of the great things about writing a Greasemonkey script is that you don’t have to care about any browser other than Firefox). it might work with about: uri on IE6/7, but it wasn’t tested.

Tested on Firefox only, Chrome and Safari.

It works by linking to a data URI that creates a page with some HTML (<html><head><meta http-equiv=”refresh” content=”0;url=http://www.whatismyreferrer.com/”></head></html>) in it:

<a href='data:text/html;charset=utf-8,<html><head><meta http-equiv="refresh" content="0;url=http://www.whatismyreferrer.com/"></head></html>'>Click me</a>

What happens is that you link to a virtual page who redirects to the target URL, so the actual page that made the redirect is the virtual page and not your site (and the browsers doesn’t send the data: URI as the referrer).

Try it in comparison to a regular link

Here’s the function I used to create those links using  javascript:

var noreflink=function(href) {
	return 'data:text/html;charset=utf-8,'+encodeURIComponent('<html><head><meta http-equiv="refresh" content="0;url='+href.replace('"','&quot;')+'"></head></html>');
}

Also,

document.location=noreflink("http://www.google.com/");

can be used to redirect using javascript without sending a referrer, instead of using a link.

Update: This won’t work on Opera. when using a meta refresh it still uses the URL that linked to the page with the meta refresh as the referrer header. I tried using javscript redirect (document.location) instead, and even with a timer – it doesn’t work.

I did find a working solution for Opera eventually:

does the trick, and the link will look like:

Click me

Try it here

However, that works for Opera only. There’s a way to make a version that’ll work on all browsers (except IE), but because I only needed it for a Greasemonkey script and I don’t care about any browser other than Firefox, I’ll leave that for you. If anyone do write a cross-browser version, add it as a comment and I’ll update the post.