camporez / TPB2RSS

// ==UserScript==
// @name        TPB2RSS
// @description A RSS feed generator for The Pirate Bay
// @copyright   2014, Camporez
// @icon        https://raw.githubusercontent.com/camporez/tpb2rss/master/chrome/icon.png
// @license     Apache 2.0
// @homepageURL http://tpb.camporez.com
// @supportURL  https://github.com/camporez/tpb2rss
// @oujs:author camporez
// @namespace   https://github.com/camporez/tpb2rss
// @include     *://*thepiratebay.*/*
// @version     1
// @grant       none
// ==/UserScript==

if (/^((http)s{0,1}:\/\/(www.){0,1}){0,1}thepiratebay\.[a-z]+\/(search\/(.)+|browse\/[0-9]+|recent)+/.test(location.href)) {
	if (/^((http)s{0,1}:\/\/(www.){0,1}){0,1}thepiratebay\.[a-z]+\/browse\/[0-9]+/.test(location.href)) {
		var url = "http://rss.thepiratebay.se/" + window.location.pathname.split("/")[2]
	} else {
		var url = document.URL;
		var url = url.replace(/^((http)s{0,1}:\/\/(www.){0,1}){0,1}thepiratebay\.[a-z]{1,}\//gi, "http://tpb.camporez.com/");
	}
	var content = document.getElementsByTagName("h2")[0].innerHTML;
	document.getElementsByTagName("h2")[0].innerHTML = content + "&nbsp;<a class=\"rss\" href=\"" + url + "\" title=\"Subscribe to this page\"><img src=\"/static/img/rss_small.gif\" alt=\"RSS\" border=\"0\" /></a>";
}