FreeTV: IMDB search

By danmana Last update Feb 5, 2010 — Installed 332 times.

There are 2 previous versions of this script.

// ==UserScript==
// @name           FreeTV: IMDB search
// @version        1.0.0
// @author         danmana
// @namespace      http://userscripts.org/users/103443
// @description    Adds a small imdb search button next to each movie title.
// @include        http://www.free-tv-video-online.info/movies/*
// @exclude        http://www.free-tv-video-online.info/movies/
// @include        http://www.free-tv-video-online.info/internet/
// @include        http://www.free-tv-video-online.info/internet/index.html
// @include        http://www.free-tv-video-online.info/internet/index_status.html
// @include        http://www.free-tv-video-online.info/internet/index_rating.html
// @include        http://www.free-tv-video-online.info/internet/index_last.html
// ==/UserScript==

window.addEventListener('load', main, false);

function main(){
	try{
		//add the css styles needed
		var style = document.createElement('style');
		style.setAttribute('type','text/css');
		style.appendChild(document.createTextNode('.imdb{cursor:pointer;width:33px;height:16px;display:inline-block;margin-right:4px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAQCAMAAACvHOZVAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAMAUExURdW7O8eqMsOkLiYiI9/JPNPAS+/aPaecVLyqStK3OFNNODg0LunVOtrBNs2zNDItJvbiPBcUGvflQ72oRf7++dm9PN/EP+jTPda+OezaRpKHVOLJNunUPeLRT52SW9zEOM2zOGNeSl1VNeXNN25lRNC1M5aLU4N6Td3AOdK+SjUzMx4aG9fBNpmOVTk2M9S5MHVuTZmOW4+GTu7aTfHZOxoXGufROnxyS2tkTPLfQsmrMoN3RaSYYdK6Nt/INtnBOMuvM+zXPHFoPImBTeHMOwcFE2lfPu3bOs20NubRPObSOEVCO8uyNaOWXtnFSd7DPi0qK9K4PNG3NElFPFdSQufTOuPMPePMOuLMOGZePtrEOIyDTtO8NNS6NNO5NW1lO8+0Nc+1MsqxM8qsMY2CW/ThTeTPOuPOOuPLOeDKOuLJO9/GN93HN9fAOdW+NzEuLxAOFtG1NCgkJmBYOGlg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5/l5mwQDTAOHkZL4zDD+rLuhomld+e7Li2QFrjspF3ytLjpQ8PaTiZs5lPb/6PF81g99nFpcZ/mIzJPz/dTB4TA9UmBYYyHmCcdWqhnlWTA6q1ZsZ9n1iyJZ++xoYkby5uRJ5eR8/xnTb2v65W1hYmJAQxHTsHUNFxezlsbFxcUHNN29ev379qo9PUpKDg8O5ZCsrRsbG0/UVAAEGACc+x9n/0n9YAAAAAElFTkSuQmCC");}'));
		var head = document.head;
		if (head == null)
			head = document.getElementsByTagName('head')[0]; 
		head.appendChild(style);
		
		//create a search button
		var imdb = document.createElement('a');
		imdb.className = 'imdb';
		imdb.title = 'Search IMDB';
		
		//for each title add a copy of the search button, but with a different action
		var titles = getPatternResult('//td[@class="mnlcategorylist"]');
		for (var i=0;i<titles.snapshotLength;i++){
			var title = titles.snapshotItem(i);
			var href = 'http://www.imdb.com/find?s=all&q='+encodeURIComponent(title.firstChild.firstChild.firstChild.nodeValue);
			var copy = imdb.cloneNode(true);
			copy.setAttribute('href',href);
			title.insertBefore(copy,title.firstChild);
		}
	
	}catch(ex){
		alert('exception:\n'+ex);
	}
}

function getPatternResult(pattern, context){
    if (context == null) 
        context = document;
    return document.evaluate(pattern, context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
}