Check for instance at the very beginning
This commit is contained in:
parent
5f0e28e506
commit
445908b34a
1 changed files with 24 additions and 25 deletions
49
src/count.js
49
src/count.js
|
@ -32,32 +32,31 @@
|
||||||
|
|
||||||
// Check if the default GC URL resolves
|
// Check if the default GC URL resolves
|
||||||
// This allows us to not track people with ad blockers
|
// This allows us to not track people with ad blockers
|
||||||
fetch("//gc.zgo.at/", { method: "HEAD" })
|
|
||||||
.then((result) => {
|
|
||||||
if (!result.ok) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
window.location.host !== "toot.kytta.dev" &&
|
window.location.host === "toot.kytta.dev" ||
|
||||||
window.location.host !== "s2f.kytta.dev" &&
|
window.location.host === "s2f.kytta.dev" ||
|
||||||
window.location.host !== "share2fedi.kytta.dev"
|
window.location.host === "share2fedi.kytta.dev"
|
||||||
) {
|
) {
|
||||||
return;
|
fetch("//gc.zgo.at/", { method: "HEAD" })
|
||||||
}
|
.then((result) => {
|
||||||
|
if (!result.ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const screen = encodeURIComponent(
|
const screen = encodeURIComponent(
|
||||||
[
|
[
|
||||||
window.screen.width,
|
window.screen.width,
|
||||||
window.screen.height,
|
window.screen.height,
|
||||||
window.devicePixelRatio || 1,
|
window.devicePixelRatio || 1,
|
||||||
].join(",")
|
].join(",")
|
||||||
);
|
);
|
||||||
|
|
||||||
const random = encodeURIComponent(Math.random().toString(36).slice(2));
|
const random = encodeURIComponent(Math.random().toString(36).slice(2));
|
||||||
|
|
||||||
navigator.sendBeacon(
|
navigator.sendBeacon(
|
||||||
`https://share2fedi.goatcounter.com/count?p=%2F&s=${screen}&b=0&rnd=${random}`
|
`https://share2fedi.goatcounter.com/count?p=%2F&s=${screen}&b=0&rnd=${random}`
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch((_) => {});
|
.catch((_) => {});
|
||||||
|
}
|
||||||
|
|
Reference in a new issue