Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name reddit modqueue checker
- // @namespace reddit_listen2
- // @description checks modqueue, duh
- // @include *.reddit.com/*
- // ==/UserScript==
- (function(){
- function check(p) {
- if (checking)
- return;
- var last = JSON.parse(localStorage['modqueue_last_checked']||'{}');
- var t = new Date().getTime();
- if (t - last < p) {
- show(JSON.parse(localStorage['modqueue_last_count']||'{}'));
- } else {
- req = new XMLHttpRequest();
- req.onreadystatechange = display;
- req.open("GET", "/r/mod/about/modqueue.json", true);
- req.send(null);
- mqalert.innerText += "*";
- checking = true;
- }
- }
- //"/message/unread/.json?mark=false"
- function display() {
- if (req.readyState === 4) {
- checking = false;
- if (req.status === 200) {
- n = JSON.parse(req.responseText).data.children.length;
- var t = new Date().getTime();
- show(n);
- localStorage['modqueue_last_count'] = JSON.stringify(n);
- localStorage['modqueue_last_checked'] = JSON.stringify(t);
- } else {
- mqalert.innerText = "mq X";
- }
- }
- }
- function show(n) {
- if (n === 0) {
- mqalert.style.color = def_color;
- mqalert.style.fontWeight = def_weight;
- mqalert.innerText = "mq 0";
- } else {
- mqalert.style.color = "orangered";
- mqalert.style.fontWeight = "bold";
- mqalert.innerText = "mq " + n;
- }
- }
- var modmail = document.getElementById("modmail");
- var mqsep = document.createElement("span");
- mqsep.className = "separator";
- mqsep.innerText = "|";
- modmail.parentNode.insertBefore(mqsep, modmail.nextSibling);
- var mqalert = document.createElement("a");
- mqalert.id = "mqalert";
- mqalert.href = "/r/mod/about/modqueue";
- mqalert.innerText = "mq ";
- mqsep.parentNode.insertBefore(mqalert, mqsep.nextSibling);
- var def_color = mqalert.style.color;
- var def_weight = mqalert.style.fontWeight;
- var checking = false;
- mqalert.addEventListener("mouseOver", function(){check(30000)}); //30 seconds
- check(360000); //six minutes
- })();
Add Comment
Please, Sign In to add comment