forked from Tiny-Giant/myuserscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuto-acknowledgeNegativeRep.user.js
45 lines (39 loc) · 1.33 KB
/
Auto-acknowledgeNegativeRep.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// ==UserScript==
// @name Auto-acknowledge Negative Rep
// @namespace http://github.com/Tiny-Giant
// @version 1.0.0.0
// @description Automatically marks negative reputation changes as read.
// @author @TinyGiant
// @include /^https?:\/\/.*?(stackoverflow.com|stackexchange.com|superuser.com|serverfault.com|askubuntu.com|stackapps.com|mathoverflow.net)/.*$/
// @grant GM_xmlhttpRequest
// ==/UserScript==
/* jshint -W097 */
'use strict';
let getUnreadCounts, triggerUpdate;
triggerUpdate = () => {
GM_xmlhttpRequest({
method: 'GET',
url: '/topbar/achievements',
onload: xhr => {
if (xhr.status !== 200) {
console.log(xhr.status, xhr.statusText, xhr.responseText);
return;
}
console.log('Marked negative reputation changes as read.');
}
});
}
getUnreadCounts = () => {
GM_xmlhttpRequest({
method: 'GET',
url: 'http://chat.stackoverflow.com/topbar/get-unread-counts',
onload: xhr => {
if (xhr.status !== 200) {
console.log(xhr.status, xhr.statusText, xhr.responseText);
return;
}
if (+JSON.parse(xhr.responseText).UnreadRepCount < 0) triggerUpdate();
}
});
}
getUnreadCounts();