-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathobconstant.js
80 lines (64 loc) · 3.89 KB
/
obconstant.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
72
73
74
75
76
77
78
79
80
/*
* Oldbanana - The Gamebanana Enhancement Project, for Firefox
* Copyright (C) 2021 bonkmaykr
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function obHttpGet(url)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", url, false ); // false for synchronous request
xmlHttp.send( null );
obReportInfo("Sending GET request to " + url);
return xmlHttp.responseText;
}
function obReportInfo(string) {
window.console.info("[OldBanana] " + string);
}
// are these names overkill?
var obDeveloperIconsSheetBuffer = "/*Adds indicators to avatars of every Oldbanana developer*/\n"; //hold entire css until completed
var obDeveloperIconsSelectorBuffer = ""; //use to calculate result per user
var obDeveloperIconsData = JSON.parse(obHttpGet("https://oldbanana-official.github.io/auto-web-content/developers.json")); //get actual json data from server
var obDeveloperIconsDataIndex = 0; //count where we are in the json array
while(obDeveloperIconsData.users.length > obDeveloperIconsDataIndex) {
if(obDeveloperIconsSheetBuffer.endsWith("::before")) {
obDeveloperIconsSheetBuffer = obDeveloperIconsSheetBuffer.concat(",\n");
}
if(obDeveloperIconsData.users[obDeveloperIconsDataIndex].role == "developer") {
obDeveloperIconsSelectorBuffer = ".Avatar[href=\"https://gamebanana.com/members/"; //initialize the variable
obDeveloperIconsSelectorBuffer = obDeveloperIconsSelectorBuffer.concat(obDeveloperIconsData.users[obDeveloperIconsDataIndex].id.toString());
obDeveloperIconsSelectorBuffer = obDeveloperIconsSelectorBuffer.concat("\"]::before");
}
obDeveloperIconsSheetBuffer = obDeveloperIconsSheetBuffer.concat(obDeveloperIconsSelectorBuffer); //save our results to the buffer
obDeveloperIconsDataIndex++;
}
obDeveloperIconsSheetBuffer = obDeveloperIconsSheetBuffer.concat("\n{content: url(https://images.gamebanana.com/img/flags/studios/61a197d40641e.png);width: 20px;height: 10px;position: absolute;bottom: -3px;right: -3px;filter: drop-shadow(0 0 2px black) drop-shadow(0 0 2px black);}\n\n");
obDeveloperIconsDataIndex = 0;
while(obDeveloperIconsData.users.length > obDeveloperIconsDataIndex) {
if(obDeveloperIconsSheetBuffer.endsWith("::before")) {
obDeveloperIconsSheetBuffer = obDeveloperIconsSheetBuffer.concat(",\n");
}
if(obDeveloperIconsData.users[obDeveloperIconsDataIndex].role == "developer") {
obDeveloperIconsSelectorBuffer = ".Avatar[href=\"https://gamebanana.com/members/"; //initialize the variable
obDeveloperIconsSelectorBuffer = obDeveloperIconsSelectorBuffer.concat(obDeveloperIconsData.users[obDeveloperIconsDataIndex].id.toString());
obDeveloperIconsSelectorBuffer = obDeveloperIconsSelectorBuffer.concat("\"].Online::before");
}
obDeveloperIconsSheetBuffer = obDeveloperIconsSheetBuffer.concat(obDeveloperIconsSelectorBuffer); //save our results to the buffer
obDeveloperIconsDataIndex++;
}
obDeveloperIconsSheetBuffer = obDeveloperIconsSheetBuffer.concat("\n{content: url(https://images.gamebanana.com/img/flags/studios/61a197d40641e.png);width: 20px;height: 10px;position: absolute;bottom: -3px;right: 10px;filter: drop-shadow(0 0 2px black) drop-shadow(0 0 2px black);}");
var obDeveloperIconsSheet = document.createElement("style");
obDeveloperIconsSheet.innerHTML = obDeveloperIconsSheetBuffer;
document.head.appendChild(obDeveloperIconsSheet);
//todo: donors and testers