Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (43 loc) · 1.53 KB
/
Copy pathscript.js
File metadata and controls
47 lines (43 loc) · 1.53 KB
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
// Stats declarations
const scrapes = document.querySelector(".totalScrapes");
const articles = document.querySelector(".articles");
const subscribers = document.querySelector(".servers");
const last = document.querySelector(".last");
// Discord Embed Declerations
const title = document.querySelector(".discordTitle");
const content = document.querySelector(".discordContentText");
const img = document.querySelector(".discordimg");
const titleLink = document.querySelector(".discordTitleLink");
// request stats from main server
function stats() {
fetch("https://genshinnews.com/statsJSON", {
mode: "no-cors",
})
.then((response) => response.json())
.then((data) => {
(scrapes.textContent = data.totalScrapes),
(articles.textContent = data.totalSuccessful),
(subscribers.textContent = data.totalWebhooks),
(last.textContent = Date(data.lastPosted).toLocaleString("en-US"));
});
}
// request article from main server and generates embed on website
function discordMessage() {
fetch("https://genshinnews.com/article", {
mode: "no-cors",
})
.then((response) => response.json())
.then((data) => {
(title.textContent = data.news[0].title),
(titleLink.href = data.news[0].link),
(content.textContent = data.description[0].content
.replaceAll("〓", "")
.replaceAll("●", "")),
(img.src = data.news[0].image);
});
}
// Refreshes stats in real time on website
discordMessage();
setInterval(discordMessage, 6000);
stats();
setInterval(stats, 6000);