Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

This is a very basic user script which does the following:

  • Checks the Review homepage if there's anything you can review

    • If so, it changes the title to (n) old_title where n is the number of review tasks you can perform
    • If not, it refreshes the page in 15 seconds

Install the script

This is the script:

// ==UserScript==
// @name        Review Stalker
// @namespace   http://camilstaps.nl
// @description Stalks the StackExchange review pages
// @include     http://*stackexchange.com/review
// @include     http://*stackexchange.com/review/
// @include     http://stackoverflow.com/review
// @include     http://stackoverflow.com/review/
// @include     http://serverfault.com/review
// @include     http://serverfault.com/review/
// @include     http://superuser.com/review
// @include     http://superuser.com/review/
// @include     http://askubuntu.com/review
// @include     http://askubuntu.com/review/
// @version     1.1
// @grant       
// ==/UserScript==

var RS_reviews_avail = 0;

function RS_parseInt(string) {
    var got_decimal_point = false;
    var divider = 10;
    var result = 0;
    for (var i = 0; i < string.length; i++) {
        var char = string.substring(i,i+1);
        if (char >= '0' && char <= '9') {
            if (!got_decimal_point) {
                result *= 10;
                result += parseInt(char);
            } else {
                result += parseInt(char) / divider;
                divider *= 10;
            }
        } else if (char == ',') {
        } else {
            return -1;
        }
    }
    return result;
}

function RS_hasClass(element, cls) {
    return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
}

var RS_numbers = document.getElementsByClassName("dashboard-num");
for (var RS_i = RS_numbers.length - 1; RS_i >= 0; RS_i--) {
    if (!RS_hasClass(RS_numbers[RS_i].parentNode, "dashboard-faded")) {
        var int = RS_parseInt(RS_numbers[RS_i].getAttribute('title'));
        RS_reviews_avail += int;
    }
}

if (RS_reviews_avail) {
    window.setTimeout(function(){
        document.title = "(" + RS_reviews_avail + ") " + document.title;
    }, 300);
} else {
    window.setTimeout(function(){
        window.location = window.location;
    }, 15000);
}

Install the script

share|improve this question
    
I'm having trouble with userscripts.org, mind mirroring it? I've copy/pasted from source, but still. –  jimsug May 17 at 19:14
    
@jimsug thanks for the notification, userscripts.org seems to be on port 8080 now. I updated the link. –  Camil Staps May 18 at 12:57
    
userscripts.org seems to throw a nasty server error ("Web application could not be started"); am I doing something wrong? –  Raphael Jun 5 at 7:32
    
@Raphael hm, it does the same for me. Then for now you can install the script from the source here. –  Camil Staps Jun 5 at 8:09

1 Answer 1

First of all, I like your script; it's nice and concise!

Just two small observations:

  1. It's incompatible with Google Chrome (unless Tampermonkey is installed) - due to the @require statement, requiring jQuery. You could rewrite the small bits of jQuery into vanilla JS to easily overcome this.

  2. When the review queues look like this:

    • Close Votes: 52.2k
    • First Posts: 10
    • Suggested Edits: 1

The window title shows (63), rather than (52.2k). This is because k is ignored when passed to parseInt().

share|improve this answer
    
Lol, I am mostly active on small sites; never seen a K in the review queue! I'll make a new version of the script, but, to be honest, it isn't the next thing on my list ;) –  Camil Staps May 15 '13 at 5:46
1  
Never mind. I fixed both things, thanks! The problem wasn't the K but a comma. The script gets the exact value from the title, but parseInt doesn't recognize the comma as a thousands delimiter. I updated the script. Thanks again for your comments! –  Camil Staps May 15 '13 at 13:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .