From a22946e34a9f00e90e2b4a1dbba49b2845de507b Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 4 Jun 2025 21:15:53 +0200 Subject: [PATCH] Fix: extract goatcounter to update hash --- 404.html | 4 +--- index.html | 4 +--- inspector.html | 4 +--- privacy.html | 4 +--- src/loadGoatcounter.js | 7 +++++++ statistics.html | 4 +--- status.html | 4 +--- studio.html | 4 +--- test/CodeQuality.spec.ts | 10 +++++++++- theme.html | 4 +--- 10 files changed, 24 insertions(+), 25 deletions(-) create mode 100644 src/loadGoatcounter.js diff --git a/404.html b/404.html index a7924c529..f0273dc52 100644 --- a/404.html +++ b/404.html @@ -41,9 +41,7 @@
- + diff --git a/index.html b/index.html index 0743235f0..626628eda 100644 --- a/index.html +++ b/index.html @@ -42,9 +42,7 @@
- + diff --git a/inspector.html b/inspector.html index 25d0712d7..0c458e944 100644 --- a/inspector.html +++ b/inspector.html @@ -12,9 +12,7 @@
Loading inspector...
- + diff --git a/privacy.html b/privacy.html index c6dc3b5bb..0e8ab8bdc 100644 --- a/privacy.html +++ b/privacy.html @@ -38,9 +38,7 @@
- + diff --git a/src/loadGoatcounter.js b/src/loadGoatcounter.js new file mode 100644 index 000000000..314639453 --- /dev/null +++ b/src/loadGoatcounter.js @@ -0,0 +1,7 @@ +const script = document.createElement("script") +script.async = true +script.dataset.goatcounter = "https://pietervdvn.goatcounter.com/count" +script.src = "https://gc.zgo.at/count.js" +script.crossOrigin = "anonymous" +script.integrity = "sha384-atnOLvQb9t+jTSipvd75X2yginT4PjVbqDdlJAmxMm+wYElFmeR6EmLP5bYeoRVQ" +document.head.appendChild(script) diff --git a/statistics.html b/statistics.html index 0e65fa043..935ad2a04 100644 --- a/statistics.html +++ b/statistics.html @@ -12,9 +12,7 @@
Loading statistics...
- + diff --git a/status.html b/status.html index b05d424fe..0f1d12732 100644 --- a/status.html +++ b/status.html @@ -13,9 +13,7 @@
- + diff --git a/studio.html b/studio.html index d4f04e41a..9624b3f0e 100644 --- a/studio.html +++ b/studio.html @@ -19,9 +19,7 @@
- + diff --git a/test/CodeQuality.spec.ts b/test/CodeQuality.spec.ts index c2939ef0f..2cafdcad7 100644 --- a/test/CodeQuality.spec.ts +++ b/test/CodeQuality.spec.ts @@ -158,6 +158,14 @@ describe("Code quality", () => { for (const htmlFile of htmlFiles) { await validateScriptIntegrityOf(htmlFile) } + const goatCounter = "https://gc.zgo.at/count.js" + const data: string = (await ScriptUtils.Download(goatCounter))["content"] + const hashed = await webcrypto.subtle.digest("SHA-384", new TextEncoder().encode(data)) + const hashedB64 = _arrayBufferToBase64(hashed) + const goatCounterScript = readFileSync("./src/loadGoatcounter.js", "utf-8") + if (goatCounterScript.indexOf(hashedB64) < 0) { + throw "Hash sha-384" + hashedB64 + " not found in 'loadGoatcounter.js'" + } }) /* itAsync( @@ -168,7 +176,7 @@ describe("Code quality", () => { ) ) /* - itAsync( + itAsync(int "should not contain '[\"default\"]'", detectInCode('\\[\\"default\\"\\]', "Possible leftover of faulty default import") )*/ diff --git a/theme.html b/theme.html index 05ceed9e7..1526f204b 100644 --- a/theme.html +++ b/theme.html @@ -92,9 +92,7 @@ - +