forked from jackmcdade/weird-wide-webring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
45 lines (34 loc) · 1.16 KB
/
functions.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
let urlParams = new URLSearchParams(window.location.search)
function getSites() {
return sites
}
function getReferringSite() {
if (urlParams.has('referrer')) {
return 'https://' + urlParams.get('referrer');
} else if (document.referrer !== '') {
return 'https://' + new URL(document.referrer).host
}
return getRandomSite()
}
function getNextSite() {
var index = sites.findIndex(element => element.url === getReferringSite())
var site = sites[index + 1] || sites[0]
return site.url
}
function getPreviousSite() {
var index = sites.findIndex(element => element.url === getReferringSite())
var site = (index - 1) < 0 ? sites[sites.length - 1] : sites[index - 1]
return site.url
}
function getRandomSite() {
return sites[Math.floor(Math.random() * sites.length)].url
}
function getCounterStats() {
fetch('https://app.usefathom.com/vip/jack-mcdade')
.then(response => response.json())
.then(function(data) {
document.querySelectorAll('#hit-counter')[0].innerHTML = zeroPad(data, 7);
})
}
getCounterStats()
const zeroPad = (num, places) => String(num).padStart(places, '0')