From b1bdc48769b6c923af9bbb4a3381cdf074d86f03 Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sun, 10 Sep 2023 13:51:45 +0100 Subject: [PATCH] fix: redundant padding character in usercss id --- src/utils/themes/usercss/compiler.ts | 4 ++++ src/utils/themes/usercss/index.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/themes/usercss/compiler.ts b/src/utils/themes/usercss/compiler.ts index 7f3329ce..d7ca3c9e 100644 --- a/src/utils/themes/usercss/compiler.ts +++ b/src/utils/themes/usercss/compiler.ts @@ -83,6 +83,10 @@ export async function compileUsercss(fileName: string) { // In default and USO, it has no special meaning, so we'll just leave it as a number. varsToPass[k] = varsToPass[k] === "1" ? "true" : "false"; } + + if (v.type === "range") { + varsToPass[k] = `${varsToPass[k]}${v.units ?? "px"}`; + } } try { diff --git a/src/utils/themes/usercss/index.ts b/src/utils/themes/usercss/index.ts index f83d293f..a7d49a60 100644 --- a/src/utils/themes/usercss/index.ts +++ b/src/utils/themes/usercss/index.ts @@ -34,5 +34,5 @@ export async function getUserCssId(header: UserstyleHeader): Promise { const idHash = await window.crypto.subtle.digest("SHA-256", new Uint8Array([...nameHash, ...namespaceHash])); - return window.btoa(String.fromCharCode(...new Uint8Array(idHash))); + return window.btoa(String.fromCharCode(...new Uint8Array(idHash))).substring(0, 43); // base64 adds one more padding character }