-
Notifications
You must be signed in to change notification settings - Fork 0
/
anonymous_feedback.user.js
71 lines (70 loc) · 2.97 KB
/
anonymous_feedback.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// ==UserScript==
// @name Load Anonymous feedback
// @namespace https://github.com/danthe1st/
// @version 1.1.1
// @description Loads anonymous feedback of StackOverflow posts
// @author danthe1st
// @updateURL https://raw.githubusercontent.com/danthe1st/SO-Userscripts/master/anonymous_feedback.user.js
// @downloadURL https://raw.githubusercontent.com/danthe1st/SO-Userscripts/master/anonymous_feedback.user.js
// @match *://*.stackexchange.com/questions/*
// @match *://*.stackoverflow.com/questions/*
// @match *://*.superuser.com/questions/*
// @match *://*.serverfault.com/questions/*
// @match *://*.askubuntu.com/questions/*
// @match *://*.stackapps.com/questions/*
// @match *://*.mathoverflow.net/questions/*
// @connect data.stackexchange.com
// @icon https://www.google.com/s2/favicons?sz=64&domain=stackexchange.com
// @grant GM.xmlHttpRequest
// ==/UserScript==
(function() {
'use strict';
let votingContainers=$('.js-voting-container')
for (let votingContainer of votingContainers){
let postId = votingContainer.getAttribute("data-post-id")
let siteName = window.location.hostname
siteName = siteName.substring(0,siteName.lastIndexOf("."))
if(siteName != "meta.stackexchange"){
siteName = siteName.replace(".stackexchange","")
}
if(siteName.endsWith(".meta")){
siteName = "meta."+siteName.substring(0,siteName.length-".meta".length)
}
let dataExplorerURL=`https://data.stackexchange.com/${siteName}/csv/1973758?postId=${postId}`
GM.xmlHttpRequest( {
url: dataExplorerURL,
onload: res=>{
if(res.status==200){
let content=res.response.split("\n")
content.shift()
let data={}
for(let line of content){
let splittedLine=line.split('"')
data[splittedLine[1]]=splittedLine[3]
}
for(let type in data){
let div=document.createElement('div')
let text=data[type]
let colorClass
if(!text){
continue
}else if(type=="UpMod"){
text=`+ ${text}`
colorClass="fc-green-600"
}else if(type=="DownMod"){
text=`- ${text}`
colorClass="fc-red-600"
}else{
text=`${type}=${text}`
}
div.innerText=text
if(colorClass){
div.classList.add(colorClass)
}
votingContainer.appendChild(div)
}
}
}
} )
}
})();