Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name IMDB namer
- // @namespace http://userscripts.org/users/63868
- // ==/UserScript==
- var imdbLinks = document.evaluate('//a[contains(@href, "imdb.com/title")]', document, null, 7, null);
- for (i=0; i<imdbLinks.snapshotLength; i++) {
- getMovieTitle(imdbLinks.snapshotItem(i));
- }
- function getMovieTitle(link) {
- // GM_xmlhttpRequest({
- // url : link.href,
- // GM_xmlhttpRequest({
- // url : ((link.href.indexOf("?")!=-1) ? link.href.substring(link.href.lastIndexOf("http")) : link.href),
- link.href.match(/(http:\/\/(www|m)\.imdb\.com\/title\/tt\d+)/);
- GM_xmlhttpRequest({
- url : RegExp.$1,
- method : "GET",
- onload : function(response) {
- // if (/<meta name="title" content="([^"]+)">/.test(response.responseText)) {
- if (/<meta name="title" content="([^"]+) - IMDb" \/>/.test(response.responseText)) {
- span = document.createElement("span");
- span.innerHTML = " -- " + RegExp.$1;
- link.parentNode.insertBefore(span, link.nextSibling);
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement