Advertisement
nickodemos

IMDB Namer

May 8th, 2015
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. // ==UserScript==
  2. // @name IMDB namer
  3. // @namespace http://userscripts.org/users/63868
  4. // ==/UserScript==
  5.  
  6. var imdbLinks = document.evaluate('//a[contains(@href, "imdb.com/title")]', document, null, 7, null);
  7. for (i=0; i<imdbLinks.snapshotLength; i++) {
  8. getMovieTitle(imdbLinks.snapshotItem(i));
  9. }
  10.  
  11. function getMovieTitle(link) {
  12. // GM_xmlhttpRequest({
  13. // url : link.href,
  14. // GM_xmlhttpRequest({
  15. // url : ((link.href.indexOf("?")!=-1) ? link.href.substring(link.href.lastIndexOf("http")) : link.href),
  16. link.href.match(/(http:\/\/(www|m)\.imdb\.com\/title\/tt\d+)/);
  17. GM_xmlhttpRequest({
  18. url : RegExp.$1,
  19. method : "GET",
  20. onload : function(response) {
  21. // if (/<meta name="title" content="([^"]+)">/.test(response.responseText)) {
  22. if (/<meta name="title" content="([^"]+) - IMDb" \/>/.test(response.responseText)) {
  23. span = document.createElement("span");
  24. span.innerHTML = " -- " + RegExp.$1;
  25. link.parentNode.insertBefore(span, link.nextSibling);
  26. }
  27. }
  28. });
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement