Add manifest URL field, reset keys when manifest changes, organize repo, update to Manifest v3 #3

Open
voldemort wants to merge 26 commits from voldemort/CDRM-Extension:main into main
2 changed files with 19 additions and 47 deletions
Showing only changes of commit 9e071365e3 - Show all commits

View File

@ -13,90 +13,75 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
switch (type) { switch (type) {
case "DRM_TYPE": case "DRM_TYPE":
logWithPrefix("DRM Type:", data); console.log("[CDRM-Extension] DRM Type:", data);
chrome.storage.local.set({ drmType: data }); chrome.storage.local.set({ drmType: data });
break; break;
case "PSSH_DATA": case "PSSH_DATA":
logWithPrefix("Storing PSSH:", data); console.log("[CDRM-Extension] Storing PSSH:", data);
chrome.storage.local.set({ latestPSSH: data }); chrome.storage.local.set({ latestPSSH: data });
break; break;
case "KEYS_DATA": case "KEYS_DATA":
logWithPrefix("Storing Decryption Keys:", data); console.log("[CDRM-Extension] Storing Decryption Keys:", data);
chrome.storage.local.set({ latestKeys: data }); chrome.storage.local.set({ latestKeys: data });
break; break;
case "LICENSE_URL": case "LICENSE_URL":
logWithPrefix("Storling License URL " + data); console.log("[CDRM-Extension] Storing License URL " + data);
chrome.storage.local.set({ licenseURL: data }); chrome.storage.local.set({ licenseURL: data });
break; break;
case "MANIFEST_URL": case "MANIFEST_URL":
logWithPrefix("Storing Manifest URL:", data); console.log("[CDRM-Extension] Storing Manifest URL:", data);
chrome.storage.local.set({ manifestURL: data }); chrome.storage.local.set({ manifestURL: data });
break; break;
default: 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 // Set initial config and injection type on install
chrome.runtime.onInstalled.addListener((details) => { 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") { if (details.reason === "install") {
chrome.storage.local.set({ valid_config: false }, () => { chrome.storage.local.set({ valid_config: false }, () => {
if (chrome.runtime.lastError) { 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 { } 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" }, () => { chrome.storage.local.set({ injection_type: "LICENSE" }, () => {
if (chrome.runtime.lastError) { 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 { } 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" }, () => { chrome.storage.local.set({ drm_override: "DISABLED" }, () => {
if (chrome.runtime.lastError) { 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 { } 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 }, () => { chrome.storage.local.set({ cdrm_instance: null }, () => {
if (chrome.runtime.lastError) { 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 { } else {
logWithPrefix("CDRM instance set to null."); console.log("[CDRM-Extension] CDRM instance set to null.");
} }
}); });
chrome.storage.local.set({ cdrm_api_key: null }, () => { chrome.storage.local.set({ cdrm_api_key: null }, () => {
if (chrome.runtime.lastError) { 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 { } else {
logWithPrefix("CDRM API Key set."); console.log("[CDRM-Extension] CDRM API Key set.");
} }
}); });
} }

View File

@ -68,19 +68,6 @@ window.addEventListener("message", function (event) {
} }
// Manifest header and URL // 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(); const seenManifestUrls = new Set();
@ -88,17 +75,17 @@ window.addEventListener("message", function (event) {
const url = event.data.data; const url = event.data.data;
if (seenManifestUrls.has(url)) return; if (seenManifestUrls.has(url)) return;
seenManifestUrls.add(url); seenManifestUrls.add(url);
logWithPrefix("✅ [Content] Unique manifest URL:", url); console.log("[CDRM-Extension] ✅ [content.js] Unique manifest URL:", url);
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
type: "MANIFEST_URL", type: "MANIFEST_URL_FOUND",
data: url, data: url,
}); });
} }
if (event.data?.type === "__MANIFEST_HEADERS__") { if (event.data?.type === "__MANIFEST_HEADERS__") {
const { url, headers } = event.data; 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({ chrome.runtime.sendMessage({
type: "MANIFEST_HEADERS", type: "MANIFEST_HEADERS",