I wasn't satisfied with Simon's alert on the orange alert. I wanted to know if even 1 review item was available, so I made some modifications to the userscript so that it runs on the Review page, and only alerts you when there are reviews that show a positive number.
This is Simon's version, and here is my version:
/** @preserve
// ==UserScript==
// @name Review Queue Notification
// @author Malachi Edited Simon Forsberg Created
// @description Shows a desktop notification when there review items in the queue.
// @namespace https://github.com/Zomis/SE-Scripts
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_notification
// @match *://*.stackexchange.com/review*
// @match *://*.stackoverflow.com/review*
// @match *://*.superuser.com/review*
// @match *://*.serverfault.com/review*
// @match *://*.askubuntu.com/review*
// @match *://*.stackapps.com/review*
// @match *://*.mathoverflow.net/review*
// ==/UserScript==
*/
var KEY_NEXT = 'NextReload';
var DELAY = 60 * 1000; //60,000 milliseconds
var currentTime = Date.now ? Date.now() : new Date().getTime();
var lastTime = GM_getValue(KEY_NEXT, 0);
var nextTime = currentTime + DELAY;
GM_setValue(KEY_NEXT, nextTime);
var timeDiff = Math.abs(lastTime - currentTime);
setTimeout(function(){
window.location.reload();
}, DELAY);
var title = document.title.split(' - '); // keep the site name
document.title = 'Desktop Notifications - ' + title[1];
// a way to detect that the script is being executed because of an automatic script reload, not by the user.
if (timeDiff <= DELAY * 2) {
var notifications = [];
var reviewCount = 0;
var reviewItems = document.getElementsByClassName('dashboard-num');
for (var i = 0; i < reviewItems.length; i++){
reviewCount += parseInt((reviewItems[i].getAttribute("title")).replace(',',''), 10);
console.log(reviewItems[i]);
}
console.log(reviewCount);
if (reviewCount > 0) {
notifications.push(reviewCount + ' Review Items');
}
if (notifications.length) {
var details = {
title: document.title,
text: notifications.join('\n'),
timeout: 0
};
GM_notification(details, null);
}
}
This is also available on my GitHub as a userscript.