From 9e071365e372dda6424041f37eff597be50819cb Mon Sep 17 00:00:00 2001 From: voldemort <5692900+yell0wsuit@users.noreply.github.com> Date: Mon, 21 Jul 2025 17:18:18 +0700 Subject: [PATCH] use regular prefix instead of adding color. fixes not storing to `chrome.storage.local` --- src/background.js | 47 ++++++++++++++++------------------------------- src/content.js | 19 +++---------------- 2 files changed, 19 insertions(+), 47 deletions(-) diff --git a/src/background.js b/src/background.js index b5f70fc..03c5e12 100644 --- a/src/background.js +++ b/src/background.js @@ -13,90 +13,75 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { switch (type) { case "DRM_TYPE": - logWithPrefix("DRM Type:", data); + console.log("[CDRM-Extension] DRM Type:", data); chrome.storage.local.set({ drmType: data }); break; case "PSSH_DATA": - logWithPrefix("Storing PSSH:", data); + console.log("[CDRM-Extension] Storing PSSH:", data); chrome.storage.local.set({ latestPSSH: data }); break; case "KEYS_DATA": - logWithPrefix("Storing Decryption Keys:", data); + console.log("[CDRM-Extension] Storing Decryption Keys:", data); chrome.storage.local.set({ latestKeys: data }); break; case "LICENSE_URL": - logWithPrefix("Storling License URL " + data); + console.log("[CDRM-Extension] Storing License URL " + data); chrome.storage.local.set({ licenseURL: data }); break; case "MANIFEST_URL": - logWithPrefix("Storing Manifest URL:", data); + console.log("[CDRM-Extension] Storing Manifest URL:", data); chrome.storage.local.set({ manifestURL: data }); break; default: - console.warn("Unknown message type received:", type); + console.warn("[CDRM-Extension] Unknown message type received:", type); } }); // Set initial config and injection type on install chrome.runtime.onInstalled.addListener((details) => { - const EXTENSION_PREFIX = "[CDRM EXTENSION]"; - const PREFIX_COLOR = "black"; - const PREFIX_BACKGROUND_COLOR = "yellow"; - - const logWithPrefix = (...args) => { - const style = `color: ${PREFIX_COLOR}; background: ${PREFIX_BACKGROUND_COLOR}; font-weight: bold; padding: 2px 4px; border-radius: 2px;`; - if (typeof args[0] === "string") { - // If the first arg is a string, prepend the prefix - console.log(`%c${EXTENSION_PREFIX}%c ${args[0]}`, style, "", ...args.slice(1)); - } else { - // If not, just log the prefix and the rest - console.log(`%c${EXTENSION_PREFIX}`, style, ...args); - } - }; - if (details.reason === "install") { chrome.storage.local.set({ valid_config: false }, () => { if (chrome.runtime.lastError) { - console.error("Error setting valid_config:", chrome.runtime.lastError); + console.error("[CDRM-Extension] Error setting valid_config:", chrome.runtime.lastError); } else { - logWithPrefix("valid_config set to false on first install."); + console.log("[CDRM-Extension] valid_config set to false on first install."); } }); chrome.storage.local.set({ injection_type: "LICENSE" }, () => { if (chrome.runtime.lastError) { - console.error("Error setting Injection Type:", chrome.runtime.lastError); + console.error("[CDRM-Extension] Error setting Injection Type:", chrome.runtime.lastError); } else { - logWithPrefix("Injection type set to LICENSE on first install."); + console.log("[CDRM-Extension] Injection type set to LICENSE on first install."); } }); chrome.storage.local.set({ drm_override: "DISABLED" }, () => { if (chrome.runtime.lastError) { - console.error("Error setting DRM Override type:", chrome.runtime.lastError); + console.error("[CDRM-Extension] Error setting DRM Override type:", chrome.runtime.lastError); } else { - logWithPrefix("DRM Override type set to DISABLED on first install."); + console.log("[CDRM-Extension] DRM Override type set to DISABLED on first install."); } }); chrome.storage.local.set({ cdrm_instance: null }, () => { if (chrome.runtime.lastError) { - console.error("Error setting CDRM instance:", chrome.runtime.lastError); + console.error("[CDRM-Extension] Error setting CDRM instance:", chrome.runtime.lastError); } else { - logWithPrefix("CDRM instance set to null."); + console.log("[CDRM-Extension] CDRM instance set to null."); } }); chrome.storage.local.set({ cdrm_api_key: null }, () => { if (chrome.runtime.lastError) { - console.error("Error setting CDRM API Key:", chrome.runtime.lastError); + console.error("[CDRM-Extension] Error setting CDRM API Key:", chrome.runtime.lastError); } else { - logWithPrefix("CDRM API Key set."); + console.log("[CDRM-Extension] CDRM API Key set."); } }); } diff --git a/src/content.js b/src/content.js index 221035d..85e397e 100644 --- a/src/content.js +++ b/src/content.js @@ -68,19 +68,6 @@ window.addEventListener("message", function (event) { } // Manifest header and URL - const EXTENSION_PREFIX = "[CDRM EXTENSION]"; - const PREFIX_COLOR = "black"; - const PREFIX_BACKGROUND_COLOR = "yellow"; - const logWithPrefix = (...args) => { - const style = `color: ${PREFIX_COLOR}; background: ${PREFIX_BACKGROUND_COLOR}; font-weight: bold; padding: 2px 4px; border-radius: 2px;`; - if (typeof args[0] === "string") { - // If the first arg is a string, prepend the prefix - console.log(`%c${EXTENSION_PREFIX}%c ${args[0]}`, style, "", ...args.slice(1)); - } else { - // If not, just log the prefix and the rest - console.log(`%c${EXTENSION_PREFIX}`, style, ...args); - } - }; const seenManifestUrls = new Set(); @@ -88,17 +75,17 @@ window.addEventListener("message", function (event) { const url = event.data.data; if (seenManifestUrls.has(url)) return; seenManifestUrls.add(url); - logWithPrefix("✅ [Content] Unique manifest URL:", url); + console.log("[CDRM-Extension] ✅ [content.js] Unique manifest URL:", url); chrome.runtime.sendMessage({ - type: "MANIFEST_URL", + type: "MANIFEST_URL_FOUND", data: url, }); } if (event.data?.type === "__MANIFEST_HEADERS__") { const { url, headers } = event.data; - logWithPrefix("[Content.js] Manifest Headers:", url, headers); + console.log("[CDRM-Extension] [content.js] Manifest headers:", url, headers); chrome.runtime.sendMessage({ type: "MANIFEST_HEADERS",