Filmtipset Custom Search Links

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

当前为 2014-10-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Filmtipset Custom Search Links
  3. // @namespace none
  4. // @description Adds custom search links on each movie page. Edit the code to add and remove links.
  5. // @version 0.1
  6. // @include http://www.filmtipset.se/film/*
  7. // @include http://nyheter24.se/filmtipset/film/*
  8. // ==/UserScript==
  9.  
  10.  
  11. //Some setup
  12. var menuTitle = "Mina anpassade";
  13.  
  14. var urlList = [
  15. {title: 'Yahoo Movies', url: 'http://movies.yahoo.com/mv/search?&p=%s'}, //%s is replace by the movie title
  16. {title: 'Youtube', url: 'http://www.youtube.com/results?search_query=%s'},
  17. {title: 'Google', url: 'https://www.google.com/search?q=%s'} //Last row no comma
  18. ];
  19.  
  20. //End Setup
  21.  
  22. var xpath = '//b[contains(.,"Originaltitel")]/../../td[2]';
  23. var title = document.evaluate(xpath, document, null, XPathResult.STRING_TYPE, null);
  24. var t = encodeURIComponent(title.stringValue.trim());
  25. var elMenuItem = document.querySelector("td > div.rightlinkheader");
  26. var elMenu = elMenuItem.parentNode;
  27. var elHeading = document.createElement("div");
  28. elHeading.innerHTML = menuTitle;
  29. elHeading.className = "rightlinkheader";
  30. elMenu.insertBefore(elHeading, elMenuItem);
  31. for(var i in urlList) {
  32. var a = document.createElement('a');
  33. a.href = urlList[i].url.replace('%s',t);
  34. a.innerHTML = ' - ' + urlList[i].title;
  35. var d = document.createElement('div');
  36. d.className = 'rightlink';
  37. d.appendChild(a);
  38. elMenu.insertBefore(d, elMenuItem);
  39. }