Lojic Technologies

Greasemonkey Script for Netflix Half Star Ratings

with 3 comments

I wrote an article back in May about a way to give half star ratings on Netflix. It had the advantage of working in any browser and not requiring any software installation, but it wasn’t very user friendly.

Since then, I’ve been doing a lot of JavaScript coding, so I thought I’d give Greasemonkey a try. I found a script here to give half-star ratings, but I didn’t care for the hover captions and JSLint pointed out a few issues, so I cleaned it up a little:

Code

// ==UserScript==
// @name Netflix Half Stars
// @description allows half star user ratings on Netflix
// @include http://*netflix.com/*
// ==/UserScript==
// http://userscripts.org/scripts/review/8118
// Modified by Brian Adkins

if (!unsafeWindow.sbHandler) { return; }

var sbHandler = unsafeWindow.sbHandler;
sbHandler.sbOffsets = [8,18,27,37,46,56,65,75,84,94];

sbHandler.displayStrings[0.5] = ".5 stars";
sbHandler.displayStrings[1.5] = "1.5 stars";
sbHandler.displayStrings[2.5] = "2.5 stars";
sbHandler.displayStrings[3.5] = "3.5 stars";
sbHandler.displayStrings[4.5] = "4.5 stars";

sbHandler.sbImages[0.5] = new Image();
sbHandler.sbImages[0.5].src = sbHandler.imageRoot+"stars_2_5.gif";

for(var i = 2; i < 11; i++) {
sbHandler.sbImages[i/2] = new Image();
sbHandler.sbImages[i/2].src = sbHandler.imageRoot + "stars_2_" +
(Math.floor(i/2)) + (i % 2 === 0 ? "0" : "5") + ".gif";
}

sbHandler.getStarCount = function (evt) {
var x = unsafeWindow.getElementMouseCoordinate(evt, this.element);

for(var ii = 0; ii < 10; ii++) {
if(x <= this.sbOffsets[ii]) { return (ii + 1) / 2; }
}

return 0;
};

Installation

Save the JavaScript code with .user.js extension e.g. netflix_halfstar.user.js and then open that file in Firefox and Greasemonkey should prompt you to install it.

Written by Brian Adkins

August 27, 2007 at 4:38 pm

3 Responses

Subscribe to comments with RSS.

  1. This script does not work.

    Jim

    May 14, 2009 at 7:35 pm

  2. @Jim, it’s quite possible the script no longer works. It was written in August of 2007, so Netflix may have made some changes that made the script incompatible. I haven’t needed the script in quite a while, but if I get some time, I may debug it if it’s no longer working.

    Brian Adkins

    May 14, 2009 at 8:41 pm

  3. Yup, looks like the original script has been updated 5 times. http://userscripts.org/topics/20828

    Brian Adkins

    May 14, 2009 at 8:49 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: