imdb ratings adder.

By znerp Last update Mar 31, 2009 — Installed 2,405 times. Daily Installs: 3, 1, 1, 1, 0, 2, 1, 2, 2, 1, 2, 3, 4, 5, 3, 0, 1, 1, 1, 3, 1, 2, 2, 0, 0, 5, 2, 4, 1, 1, 0, 3

There are 5 previous versions of this script.

// ==UserScript==
// @name           imdb ratings adder.
// @description    adds ratings to titles on imdb search results.
// @namespace      znerp
// @include        http://www.imdb.tld/find?q=*
// @include        http://www.imdb.tld/find?s=*&q=*
// @include        http://imdb.tld/find?q=*
// @include        http://imdb.tld/find?s=*&q=*
// @include        http://imdb.tld/name/nm*
// @include        http://www.imdb.tld/name/nm*
// ==/UserScript==

var links = document.links;
for (i = 0; i < links.length; i++) {
  if (/\/title\/tt\d+\/$/.test(links[i].href) &&
      links[i].textContent != "") {
    GM_xmlhttpRequest({
      method: 'get',
      headers: {
        'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
        'Content-type': 'application/x-www-form-urlencoded'
      },
      url: links[i].href,
      onload: function (i) {return function(result) {
        rating = result.responseText.match(/<b>(\d+[\.,]\d\/10)<\/b>/);
        links[i].parentNode.insertBefore(document.createElement("b"), links[i]).innerHTML = (rating ? "[" + rating[1] + "] " : "[??/10] ");
      }}(i)
    });
  }
}