Anime torrent search links

Adds links to torrent searches and stuff to anidb, anime-planet, animenfo, myanimelist & animenewsnetwork

// ==UserScript==
// @name           Anime torrent search links
// @namespace      http://www.google.com/search?q=brtkrbzhnv
// @description    Adds links to torrent searches and stuff to anidb, anime-planet, animenfo, myanimelist & animenewsnetwork
// @include        http://anidb.net/perl-bin/animedb.pl?show=anime&aid=*
// @include        http://www.anime-planet.com/anime/*
// @include        http://www.animenfo.com/animetitle*
// @include        http://myanimelist.net/anime*
// @include        http://www.animenewsnetwork.com/encyclopedia/anime.php?id=*
// @version        1.0.11
// ==/UserScript==
// 2009-03-22 update: MAL changed some stuff, so I had to change some stuff.
// 2009-04-14 update: Added Binsearch, Google Image Search & Tokyo Tosho
// 2009-07-21 update: Changed Tokyo Tosho to .info and refplaced BoxTorrents with BakaBT.
// 2010-04-05 update: Redesign of code (which happened to fix some bugs).
// 2010-07-13 update: Added KickAssTorrents and RapidOK.
// 2010-07-17 update: Added CRC searches to AniDB episode lists.
// 2011-01-01 update: Added YouTube.
// 2011-09-01 update: Added ability to disable/enable search links from the Greasemonkey menu + http://userscripts.org/topics/86243 stuff
// 2011-09-19 update: Fixed bug with dummy entries in Opera menu
// 2012-10-14 update: Various small fixes suggested in http://userscripts.org/topics/117301
// 2015-09-12 update: MAL changed some stuff, so I had to change some stuff.

// Converted with http://www.greywyvern.com/code/php/binary2base64:
var abimg= "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAACMuAAAjLgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAIbhcwCG5PMAhuejAIbncwCG5LMAhuLDAIbk8wCG56MAhuhzAIbocwCG6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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAD/DwAAgAMAAIABAACAAQAAgAEAAIABAADAAQAAwAEAAOABAADgAQAA4AEAAPADAAD8DwAA//8AAA%3D%3D";
var ytimg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABTElEQVR4nJ2SMUjDUBCGvxeLIDhI4+JsQGc3B9GhpdBRcHLPWJzEzdU6dunk4lSl1KGL2sVF1EEURaklTgUnYycFoe05vCQmNq3Rf7n/7r377967Q0TkoVaQ7fykiIhk7Krsn7clKQgISOdA278guP14VBAgqH5aygkgdvEqKBC2AwLvL4cCSLPblw+P+wnNbn+ogEFC7G2YPPVkIJ7yiVJKExEmZtY4KeVQSmEXL5kbU/SW15lPGWTsakRAeW39GylaLcgv+npAQj0Bji9QMpsWHPf7wDLDDYLz+iMWhf5Eazom2S8zGkbk4sISOK52HVf7eLxc0bxcgetnqJ0BoSlE4E/Eh2Vqkc0dyGa9YHuEwG+tB09VMQKNBpFPvbnVfr0Ou1tgKO3f3cPqip5C5/Mt6HzYVoT2DKWLMzWeRokIWGYobdguxMQdV30Bqesirj55WZIAAAAASUVORK5CYII%3D"; 
var rokimg = "data:image/gif;base64,R0lGODlhEAAQALMPAOWXDI+crff39N3OopqtU3mTN+S5b+3o2M7S04OOoIymPHmEm4KBd6q7bKu3wf///yH5BAEAAA8ALAAAAAAQABAAAARr8MmHnJgYC4HC2cIHTkdgnkQTNs0knGaSDgMxSAiS7PxOpJdHYkFkMIZGxa/1OCAWDACAsSgorleXUWpMNRQsknQMGAgahY+YXH6gEZrDYGy4hYISuUFq2GTWZDd/DwJsbYMge2Z4gw+KjREAOw%3D%3D";
var katimg = "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAABMLAAATCwAAAAAA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VoSAAAAADZTXBJkmqr+a6W2/2ultv9rpbb/a6W2/2ultv9rpbb/a6W2/2ultv9rpbb/a6W2/2ultv9SfovlAAAAAAAAAAAAAAAAS3J9xG+ouf9vqLn/XIuZ9GGTovpvqLn/b6i5/2+ouf9gkqD5Zpqp/W+ouf9vqLn/QWJsdwAAAAAAAAAAAAAAADtZYhdbipfxQWJrbgAAAAAAAAAAR2t2p2CRn/dBYmtuAAAAAAAAAABGanSgVH6L3wAAAAAAAAAA/j8AAPgPAADwBwAA4AMAAMADAADAAQAAgAEAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIABAADAAQAAxjMAAA%3D%3D";
var bbtimg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAG1BMVEUAAADu0NXxqrD42+C6c3X1ytL0vcPwnqFYTk4v302HAAAAAXRSTlMAQObYZgAAAE1JREFUeF6tjlkKwEAIQxvX3v/EdTL7f4Mg7yHB57cYc6AyUxGHOhgcWwIvatQGw6HNKIzCRYInLl1EpngriVwXAq2E2O7oe7bej+wUf8jMAiOXX3BzAAAAAElFTkSuQmCC"
var ntimg = "data:image/x-icon;base64,AAABAAEAEBAQAAAAAAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA/wD/AP//AAD///8A//////////////////////////////////8AAAAA////////////////////////////////////////////////////////D///D/D///Dw//D//w//D/8PD///8PD///D/////D/////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
var ttimg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAF0lEQVR42mNggIE/9TDkyPCn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iomQEhxIcEKDjmHmiABAgQKDVszoFixYuiJESA2YNgAQsRWtipUjKig4ECBvhLKQiDRVoDhBxYsfPBwgMKIDxI+tK1wwAOIix4wCMiwIoOECjFHtKyAwcOGAw1AlCAgQUIGkh4gNND4lwSJDAQqVFiAYcSKFCZA0FxBAoPHBA4WMGCwYcSJE2M9OGBggMCA6gSyZ0egvXtAADs%3D";
var animg = "data:image/x-icon;base64,AAABAAIAEBAQAAAAAAAoAQAAJgAAABAQAAAAAAAAaAUAAE4BAAAoAAAAEAAAACAAAAABAAQAAAAAAMAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AP+Id4d4h4h0/0iIUIgYWPT/RYh3eIiE9v9If///d4SE+AiIf/eIgAD3GDF/+BCAGP8YAH/4AAAEdwh4f/eAAAQEAIB/iIAABAQBAHgAAAAEBABEeEREBEhEQFSIRFRUWERURFREVIRESIQERERERESIhERERERERIiEREREREREAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//ygAAAAQAAAAIAAAAAEACAAAAAAAQAEAAAAAAAAAAAAAAAAAAAAAAAD///8A9vb2AOHx/wDu7u4A5eXlANvt/wDW6f8A0uT/AM/h/gDf3eAAydr/AMTX/wDB0fIA39/fANHR0QDEwcgA0LfxAMyr/wC+z/8AscXyAL/P7gCwwesArr7tAKq75AClrtMAmKjmAI+k6QCAlNEAvaypAKyqqACshbgAr52bAKGamgCth4oAnJyxAJKVowCNmr0Ai5S9AIGTvgCOkaUAjY64AIaNpgCDh5IAjIaNAIqGhgCKcuIAk3SZAKd3cQCkUFsAqkRVAKJCTwCDeX0Al19oAJ5BSwCRR00AjkdGAIdDRQCcPVAAmz5MAJE9QwCLOkIAgDo2AIM2PgB0i8gAdISqAHuAnQB0fbgAa3mqAG1sqgB7e5wAcHyeAHJ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BFmCglRgoKBxhTQ0KelpQAIo8niZAUBwUjjqdLoIpWAAGMQaiqDAgCKq6uqKyrfA4dlVkPWhcHBQkzsbGgpYWRhKSZTpMWCEcsK6+tn6J3nYGji5+dEimloZafn5+dbJeCn5x6eRlNiICHhpuDZTh+bXOaOWpTT3JnOmQ6Pjs4bD08eHFoYXVucDw8NWNjZmsyMXuecIKDbnBwbm5wbno2MTVtgXBwgXBwcHBwboGEIDA3XFxpbFxsbGxsXG9+dAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8%3D";
var malimg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAElBMVEUHRJ1ccbK8yONEYaz+//ysu9uh6UifAAAAMklEQVQYlWNgGCSAGQRgJEiAFQRgJFgAAoEKmBiYQAIsEAgCQBohAGExMjKiCoCUEQQATVUA3Xgr/coAAAAASUVORK5CYII="
var annimg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABKElEQVR42mNgoCaYeYZhDhD/h+Jfs84wVBKtecYZhk9ImsF41lkgPsNwk7DNpxmmIGtccJHhUNd+UQlSnP4bpnnxZYZSsGDCwi0MqbP/g3Hy7G0M9fUs+AyA2XwLLJA66z9D2kxMjMsQoOY3IAP6DvHYM8QvXolVMwgnT1sLVMyFGYBnGYJABuRuU2FnSJ73HbcBU38yTD4iBQy0C9hcsbRyq5IaQ+L8z3hc8JVh0gkZoOL/QFsLsBnCypCwaBJOA1KmTWKYdbYNYsDpL7ijJW3mByy2f4Ta8h+O8YLkaY1A/BSMU2fUgMVmnX2DZMB3/AbMPcLLMPmkDxC7M8w+vxzFZogXaohIYadXYGgEaz5zk/gcNuOsB9CgW0CN/4D4BcOsM1lUzcEAhCb+AkCTgVsAAAAASUVORK5CYII%3D";
var nrimg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAFVBMVEUAAADKtkkAAgD53FTv6/HVlbFxDjyt5SniAAAAAXRSTlMAQObYZgAAAEtJREFUeF5tzTESAjAMA8FIDvz/ycCOoeIaj7ZIjqojc/SlWiKdjLLS3H7IqQ32FNyACzqJRxwgLeT56y+QzbcLj3eABMQmjWqrMl4/TgJ7rPhjygAAAABJRU5ErkJggg==";
var ftimg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAYFBMVEUAAAADWY4GXZIKYZcOZpwTa6IYcaged64jfbQog7suicEzj8c4lM08mdJAnddDodtGpN5Wl79am8ReoMhhpM1mqNJprdaIv+HB2ejD2+nE3OvG3u3H4O7J4fDk8fj////78W6fAAAAQElEQVQYlWOShwIBKGBigIL/UECUwEMgAApwCQGBIFgF0EigwJc33/+9eYvdDIgWJAGIFlKslYcJfHlLrBYCAgCaWXohalhKKgAAAABJRU5ErkJggg==";

var searches = new Array();
searches.push({alt:"AnimeBytes", template:"http://animebytes.tv/series.php?name=%title%", img:abimg});
searches.push({alt:"BakaBT", template:"http://www.bakabt.me/browse.php?q=%title%", img:bbtimg});
searches.push({alt:"NyaaTorrents", template:"http://www.nyaa.eu/?page=search&sort=5&term=%title%", img:ntimg});
searches.push({alt:"Tokyo Toshokan", template:"http://www.tokyotosho.info/search.php?terms=%title%", img:ttimg});
searches.push({alt:"KickAssTorrents", template:"http://www.kat.ph/search/%title%/", img:katimg});
searches.push({alt:"Binsearch", template:"http://binsearch.info/index.php?m=&max=100&adv_g=&adv_age=240&adv_sort=date&minsize=&maxsize=&font=&postdate=&q=%title%", img:bsimg});
searches.push({alt:"RapidOK", template:"http://rapidok.com/search/all/1/%title%", img:rokimg});
searches.push({alt:"#NEWS@rizon", template:"http://news.is-fabulo.us/?search=%title%", img:nrimg});
searches.push({alt:"YouTube", template:"http://www.youtube.com/results?search_query=%title%", img:ytimg});
searches.push({alt:"FilesTube", template:"http://www.filestube.com/search.html?q=%title%", img:ftimg});

searches.push({alt:"Wikipedia", template:"http://en.wikipedia.org/wiki/Special:Search?search=%title%", img:wpimg});
searches.push({alt:"Google", template:'http://google.com/search?q="%title%"', img:gimg});
searches.push({alt:"Google Image Search", template:'http://images.google.com/images?q="%title%"', img:giimg});
searches.push({alt:"Amazon", template:"http://www.amazon.com/s/?search-alias=popular&field-keywords=%title%", img:amazonimg});
searches.push({alt:"IMDB", template:"http://www.imdb.com/find?s=all&q=%title%", img:imimg});
var anidb, ap, an, man, ann;
searches.push(anidb = {alt:"AniDB", template:"http://anidb.net/perl-bin/animedb.pl?show=animelist&adb.search=%title%", img:adimg});
searches.push(ap = {alt:"Anime-Planet", template:"http://www.anime-planet.com/search.php?search_type=all&search=%title%", img:apimg});
searches.push(an = {alt:"AnimeNfo", template:"http://www.animenfo.com/search.php?&queryin=anime_titles&option=keywords&query=%title%", img:animg});
searches.push(man = {alt:"MyAnimeList", template:"http://myanimelist.net/anime.php?q=%title%", img:malimg});
searches.push(ann = {alt:"Anime News Network", template:"http://www.animenewsnetwork.com/search?type=all&q=%title%", img:annimg});

var crcSearches = new Array();
crcSearches.push({alt:"Tokyo Toshokan", template:"http://www.tokyotosho.info/search.php?terms=%crc%", img:ttimg});
crcSearches.push({alt:"KickAssTorrents", template:"http://www.kickasstorrents.com/search/%crc%/", img:katimg});
crcSearches.push({alt:"Binsearch", template:"http://binsearch.info/index.php?m=&max=100&adv_g=&adv_age=240&adv_sort=date&minsize=&maxsize=&font=&postdate=&q=%crc%", img:bsimg});
crcSearches.push({alt:"RapidOK", template:"http://rapidok.com/search/all/1/%crc%", img:rokimg});
crcSearches.push({alt:"Google", template:'http://google.com/search?q="%crc%"', img:gimg});

var sites = new Array();
sites.push({alt:"AniDB", path:"//h1", url:"anidb", titlePath:"//tr[@class='g_odd romaji']/td[@class='value']", pattern:/Anime: (.*)/, titlePattern:/(.*)/, search:anidb, postProcess:crcFunction});
sites.push({alt:"Anime-Planet", path:"//h1", url:"anime-planet", pattern:/(.*)/, search:ap});
sites.push({alt:"AnimeNfo", path:"//h1", pattern:/Anime : (.*)/, url:"animenfo", search:an});
sites.push({alt:"MyAnimeList", path:"//div[@id='contentWrapper']/h1/span[@itemprop='name']", pattern:/(.*)/, url:"myanimelist", search:man});
sites.push({alt:"Anime News Network", path:"//h1[@id='page_header']", pattern:/(.*)\s\(.*?\)/, url:"animenewsnetwork", search:ann});

function main() {
	for(i = 0; site = sites[i]; ++i) if (location.href.match(site.url)) doSite(site);
	populateMenu();
}
function populateMenu()	{
	for(var i = 0; i < searches.length; ++i) GM_registerMenuCommand("Toggle " + searches[i].alt + " link", toggleSearchFunction(searches[i]));	
}
function toggleSearchFunction(search)	{
	return function() {
		var disabled = GM_getValue(alt = search.alt, false);
		if(disabled) GM_deleteValue(search.alt); else GM_setValue(search.alt, true);
		search.imgElement.style.display = disabled ? "inline" : "none";
	}
}
function doSite(site) {
  x(site.path).appendChild(makeLinks(site));
  if(f = site.postProcess) f();
}
// add some links for the crc on anidb
function crcFunction() {
  var episodeDiv = x("//div[@class='g_section episodes']");
  episodeDiv.addEventListener("DOMNodeInserted", crcHandler, false);
}
function crcHandler(event) {
  if(event.target.getAttribute("class") != "filelist") return;
  spans = xpath(".//span[@class='i_icon i_crc_yes']", event.target);
  for(var i = 0; s = spans.snapshotItem(i); ++i) {
    if(xpath("./span[@class='linkContainer']", s).snapshotLength > 0) return;
    crc = s.getAttribute("title").match(/\((.*)\)/)[1];
    s.parentNode.appendChild(document.createTextNode(" _ "));
    s.parentNode.appendChild(makeLinks({}, crcSearches, crc));
  }
}
// Create all the links and return a span containing them
function makeLinks(site, _searches, _crc) {
	var container = document.createElement("span");
	container.setAttribute("class", "linkContainer");
	var parameters = {title:getTitle(site), crc:_crc};
	for(j = 0; search = (if2(_searches, searches))[j]; ++j) if(search != site.search) addLink(container, search, parameters);
	return container;
}
// Return the title of the series in question.
function getTitle(site) {
	return extract(if2(site.titlePath, site.path)).match(site.titlePath ? site.titlePattern : site.pattern)[1].replace(/`/g,"'").replace(/\?/g,"").replace(/\s/g,"+");
}

// Put the specified link in container. 
function addLink(container, search, parameters) {
	var a = document.createElement("a"); a.href = makeUrl(search, parameters);
	var img = document.createElement("img"); img.src = search.img; img.alt = search.alt;
	a.appendChild(img);
	img.style.border = "none"; img.style.display = "inline"; a.style.border = "none";
	container.appendChild(document.createTextNode(" "));
	container.appendChild(a);
	search.imgElement = img;
	search.aElement = a;
	if (GM_getValue(search.alt, false)) img.style.display = "none";
}
function makeUrl(search, parameters) {
	var url = search.template;
	for(p in parameters) url = url.replace('%'+p+'%', parameters[p])
	return url;
}
function if2(x, y) {
  return x ? x : y;
}
// Extract innerHTML of path and replace some URI-unfriendly stuff.
function extract(path, e) {
	return x(path, e).innerHTML.replace("&amp;","%26");
}
function x(query, element) { 
  return document.evaluate(query, if2(element, document), null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue; 
}
// From Dive Into Greasemonkey:
function xpath(query, element) {
	return document.evaluate(query, if2(element, document), null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
}
main();