-
Notifications
You must be signed in to change notification settings - Fork 0
/
bannerInfo.js
69 lines (60 loc) · 2.04 KB
/
bannerInfo.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
// CONFIGURATION
const username = "dimden";
// THE MAGIC SAUCE
// (be careful when touching)
function fetchSiteTitle() {
// const request = await fetch(`https://nekoweb.org/api/site/info/${username}`);
var siteInfoJson;
const url = "https://nekoweb.org/api/site/info/" + username;
const request = new XMLHttpRequest();
request.overrideMimeType("application/json");
request.open("GET", url, true);
console.log(request.responseText);
request.onload = function () {
siteInfoJson = JSON.parse(request.responseText);
if (document.getElementById("NOTUSEDONNEKOWEBsitetitle")) {
document.getElementById(
"NOTUSEDONNEKOWEBsitetitle"
).innerHTML = `${siteInfoJson.title}`;
}
};
// Try ES6 fallback
if (request.responseText == false) {
const es6Req = async function () {
const request = await fetch(
`https://nekoweb.org/api/site/info/${username}`
);
const siteInfoJson = await request.json();
if (document.getElementById("NOTUSEDONNEKOWEBsitetitle")) {
document.getElementById(
"NOTUSEDONNEKOWEBsitetitle"
).innerHTML = `${siteInfoJson.title}`;
}
};
es6Req();
}
}
function fillUserSiteboxData() {
document.getElementById("NOTUSEDONNEKOWEBsitelink").innerHTML =
username +
'.nekoweb.org <span style="position: relative !important" class="follow">[+]</span>';
document.getElementById("NOTUSEDONNEKOWEBanchor").href =
"https://" + username + ".nekoweb.org/";
document.getElementById("NOTUSEDONNEKOWEBsitescreenshot").src =
"https://nekoweb.org/screenshots/" + username + "/index_large.jpg";
}
function fillSiteboxCSS() {
const stylesheet =
"https://nekoweb.org/site/" + username + "/files/elements.css";
const cssId = "userCss";
if (!document.getElementById(cssId)) {
const link = document.createElement("link");
link.id = cssId;
link.rel = "stylesheet";
link.href = stylesheet;
document.getElementsByTagName("head")[0].appendChild(link);
}
}
fetchSiteTitle();
fillUserSiteboxData();
fillSiteboxCSS();