-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (31 loc) · 808 Bytes
/
script.js
File metadata and controls
33 lines (31 loc) · 808 Bytes
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
;(async (token) => {
const res = await fetch('https://analytics.stacc.cc/api/track', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
referrer: document.referrer,
token,
href: location.href,
language: navigator.language || navigator.userLanguage,
os: navigator.platform
})
})
if (!res.ok) throw new Error(await res.text())
const ws = new WebSocket('wss://aws.stacc.cc/client')
ws.addEventListener('open', () => {
ws.send(
JSON.stringify({
type: 'INIT',
payload: { token }
})
)
setInterval(() => {
ws.send(JSON.stringify({ type: 'PING' }))
}, 15000)
})
ws.addEventListener('message', (event) => {
console.warn(event.data)
})
})('${token}')