Filmtipset Custom Search Links

Adds custom search links on each movie page. Edit the code to add and remove links.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           Filmtipset Custom Search Links
// @namespace      none
// @description    Adds custom search links on each movie page. Edit the code to add and remove links.
// @version        0.1.1
// @include        http://www.filmtipset.se/film/*
// ==/UserScript==


//Some setup
var menuTitle = "Mina anpassade";

var urlList = [
    {title: 'Yahoo Movies', url: 'http://movies.yahoo.com/mv/search?&p=%s'},       //%s is replace by the movie title
    {title: 'Youtube',      url: 'http://www.youtube.com/results?search_query=%s'},
    {title: 'Google',       url: 'https://www.google.com/search?q=%s'}                  //Last row no comma
];

//End Setup

var xpath = '//b[contains(.,"Originaltitel")]/../../td[2]';
var title = document.evaluate(xpath, document, null, XPathResult.STRING_TYPE, null);
var t     = encodeURIComponent(title.stringValue.trim());
var elMenuItem   = document.querySelector("td > div.rightlinkheader");
var elMenu       = elMenuItem.parentNode;
var elHeading    = document.createElement("div");
elHeading.innerHTML = menuTitle;
elHeading.className = "rightlinkheader";
elMenu.insertBefore(elHeading, elMenuItem);
for(var i in urlList) {
    var a       = document.createElement('a');
    a.href      = urlList[i].url.replace('%s',t);
    a.innerHTML = ' - ' + urlList[i].title;
    var d       = document.createElement('div');
    d.className = 'rightlink';
    d.appendChild(a);
    elMenu.insertBefore(d, elMenuItem);
}