-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrtagger.js
50 lines (46 loc) · 1.44 KB
/
rtagger.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
46
47
48
49
50
// ==UserScript==
// @name rtagger
// @namespace http://localhost/
// @description Tag people according to https://github.com/NotCompsky/rscraper
// @copyright 2019+, Adam Gray (GPLv3.0)
// @include https://www.reddit.com/*
// @include https://old.reddit.com/*
// @version 0.0.1
// @grant GM_xmlhttpRequest
// ==/UserScript==
var userIds = [];
for (var t of document.getElementsByClassName("author")){
var s = t.classList[2];
if (s[0] == 'm'){
s = t.classList[3];
}
userIds.push(s);
}
function main(d){
for (var t of document.getElementsByClassName("author")){
var s = t.classList[2];
if (s[0] === 'm'){
s = t.classList[3];
}
var tpls = d[s];
// NOTE: Thread starter has additional (non-ID) tag in 2nd index.
// TODO: Account for this
if (tpls === undefined){
continue;
}
for (var tpl of tpls){
var tagstrtag = document.createElement("div");
tagstrtag.innerText = tpl[1];
tagstrtag.style.background = tpl[0];
tagstrtag.style.display = "inline";
t.appendChild(tagstrtag);
}
}
}
GM_xmlhttpRequest({
method: "GET",
url: "http://104.197.15.19:8080/" + userIds.join(","), // <-- You can customise the url to point to your server
onload: function(response){
main(JSON.parse(response.responseText));
}
});