Created
April 7, 2012 05:56
-
-
Save dcadenas/2325686 to your computer and use it in GitHub Desktop.
Javascript de bookmarklet para poner ratings IMDB y rotten tomatoes en cartelera.com.uy
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
(function(){ | |
var putRatings = function($){ | |
$('.peli_izq .cinesala').each(function(_,link){ | |
var escapedTitle = escape(link.text.trim()); | |
if(escapedTitle !== ""){ | |
$.getJSON("http://www.imdbapi.com/?t=" + escapedTitle + "&tomatoes=true&y=" + (new Date().getFullYear()) + "&callback=?", function(d){ | |
if(d.imdbRating) { | |
$(link).after('<div style="float:right; background:yellow; line-height:8px; border:solid; padding:3px">\ | |
<p>Búsqueda en IMDB<\p>\ | |
<p>Título: ' + d.Title + ' (' + d.Year + ')<\p>\ | |
<p>Rating: ' + d.imdbRating + '<\p>\ | |
<p>Rating en Rotten Tomatoes: ' + d.tomatoRating + '<\p>\ | |
</div>'); | |
} | |
}); | |
} | |
}); | |
} | |
var withJQuery = function (e, a, g, h, f, c, b, d) { | |
if (!(f = e.jQuery) || g > f.fn.jquery || h(f)) { | |
c = a.createElement("script"); | |
c.type = "text/javascript"; | |
c.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + g + "/jquery.min.js"; | |
c.onload = c.onreadystatechange = function () { | |
if (!b && (!(d = this.readyState) || d == "loaded" || d == "complete")) { | |
h((f = e.jQuery).noConflict(1), b = 1); | |
f(c).remove() | |
} | |
}; | |
a.documentElement.childNodes[0].appendChild(c) | |
} | |
} | |
withJQuery(window, document, "1.7.2", function ($, L) { | |
putRatings($); | |
}); | |
})(); |
Author
dcadenas
commented
Oct 21, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment