Last active
September 1, 2015 20:04
-
-
Save nuved/8b5c676a7498da0e9d0d to your computer and use it in GitHub Desktop.
Show Movies information from IMDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @encoding UTF-8 | |
// @name Pardis_Gholhak | |
// @description Show Movies information from IMDB | |
// @namespace http://novid.ir | |
// @include http://wwww.pardis-gholhak.com/teque/* | |
// @include http://pardis-gholhak.com/teque/* | |
// @version 1 | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setTimeout(function () { | |
Array.prototype.forEach.call(document.querySelectorAll('h2 > a, a.cinema-movie-title'), function (element) { | |
var title = element.textContent; | |
fetch("http://www.imdbapi.com/?t=" + title).then(function (res) { | |
return res.text(); | |
}).then(function(body) { | |
var data = JSON.parse(body); | |
if (data.Year) { | |
element.innerHTML = element.innerHTML + ' <bdi style="font-family: serif">(' + data.Year + ')(' + data.imdbRating + ')(' | |
+ data.Awards + ')(' + data.Runtime + ')(' + data.Genre + ')</bdi> <bdi><a style="color: blue"' | |
+ 'href="http://www.imdb.com/title/' + data.imdbID + '/">(IMDb)</a></bdi>'; | |
} | |
}).then(undefined, function (e) { console.error(e); }); | |
}); | |
}, 3000); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you man.
We're redesigning Pardis's website and we'll use it 👍