forked from tpd94/CDRM-Extension
Update inject.js
- Rollback EME interception
This commit is contained in:
parent
55b5bf344d
commit
094f1edac2
61
inject.js
61
inject.js
@ -11,8 +11,6 @@ let originalChallenge = null;
|
|||||||
let widevineDeviceInfo = null;
|
let widevineDeviceInfo = null;
|
||||||
let playreadyDeviceInfo = null;
|
let playreadyDeviceInfo = null;
|
||||||
let drmOveride = "DISABLED"
|
let drmOveride = "DISABLED"
|
||||||
let serviceCertificate = null;
|
|
||||||
|
|
||||||
|
|
||||||
window.postMessage({ type: "__GET_DRM_OVERRIDE__" }, "*");
|
window.postMessage({ type: "__GET_DRM_OVERRIDE__" }, "*");
|
||||||
|
|
||||||
@ -628,45 +626,29 @@ MediaKeySession.prototype.generateRequest = async function(initDataType, initDat
|
|||||||
|
|
||||||
// === Intercept License or EME Messages ===
|
// === Intercept License or EME Messages ===
|
||||||
if (!messageSuppressed && interceptType === 'EME') {
|
if (!messageSuppressed && interceptType === 'EME') {
|
||||||
let intercepted = false;
|
session.addEventListener("message", function originalMessageInterceptor(event) {
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
console.log("[Intercepted EME Message] Injecting custom message.");
|
||||||
|
console.log(event.data);
|
||||||
|
|
||||||
const messageInterceptor = function(event) {
|
const uint8 = base64ToUint8Array(customBase64);
|
||||||
const uint8View = new Uint8Array(event.message);
|
const arrayBuffer = uint8.buffer;
|
||||||
const base64String = btoa(String.fromCharCode(...uint8View));
|
|
||||||
|
|
||||||
if (base64String === "CAQ=") {
|
const syntheticEvent = new MessageEvent("message", {
|
||||||
console.log("[CAQ] Detected - letting original message through.");
|
data: event.data,
|
||||||
return; // Allow original message
|
origin: event.origin,
|
||||||
}
|
lastEventId: event.lastEventId,
|
||||||
|
source: event.source,
|
||||||
|
ports: event.ports
|
||||||
|
});
|
||||||
|
|
||||||
if (!intercepted) {
|
Object.defineProperty(syntheticEvent, "message", {
|
||||||
intercepted = true;
|
get: () => arrayBuffer
|
||||||
event.stopImmediatePropagation();
|
});
|
||||||
console.log("[Intercepted EME Message] Injecting custom message.");
|
console.log(syntheticEvent);
|
||||||
|
setTimeout(() => session.dispatchEvent(syntheticEvent), 0);
|
||||||
|
}, { once: true });
|
||||||
|
|
||||||
const uint8 = base64ToUint8Array(customBase64);
|
|
||||||
const arrayBuffer = uint8.buffer;
|
|
||||||
|
|
||||||
const syntheticEvent = new MessageEvent("message", {
|
|
||||||
data: event.data,
|
|
||||||
origin: event.origin,
|
|
||||||
lastEventId: event.lastEventId,
|
|
||||||
source: event.source,
|
|
||||||
ports: event.ports
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.defineProperty(syntheticEvent, "message", {
|
|
||||||
get: () => arrayBuffer
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => session.dispatchEvent(syntheticEvent), 0);
|
|
||||||
|
|
||||||
// Remove after interception
|
|
||||||
session.removeEventListener("message", messageInterceptor);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
session.addEventListener("message", messageInterceptor);
|
|
||||||
messageSuppressed = true;
|
messageSuppressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,8 +692,6 @@ MediaKeySession.prototype.update = function(response) {
|
|||||||
|
|
||||||
// Handle Service Certificate
|
// Handle Service Certificate
|
||||||
if (base64Response.startsWith("CAUS") && !firstValidServiceCertificate) {
|
if (base64Response.startsWith("CAUS") && !firstValidServiceCertificate) {
|
||||||
console.log("[Service Certificate] Found:", base64Response);
|
|
||||||
serviceCertificate = base64Response;
|
|
||||||
const base64ServiceCertificateData = {
|
const base64ServiceCertificateData = {
|
||||||
type: "__CERTIFICATE_DATA__",
|
type: "__CERTIFICATE_DATA__",
|
||||||
data: base64Response
|
data: base64Response
|
||||||
@ -805,7 +785,6 @@ window.fetch = async function(input, init = {}) {
|
|||||||
if (method === "POST") {
|
if (method === "POST") {
|
||||||
const url = typeof input === "string" ? input : input.url;
|
const url = typeof input === "string" ? input : input.url;
|
||||||
let body = init.body;
|
let body = init.body;
|
||||||
|
|
||||||
|
|
||||||
// If the body is FormData, convert it to an object (or JSON)
|
// If the body is FormData, convert it to an object (or JSON)
|
||||||
if (body instanceof FormData) {
|
if (body instanceof FormData) {
|
||||||
@ -828,7 +807,6 @@ window.fetch = async function(input, init = {}) {
|
|||||||
|
|
||||||
// Handle body based on its type
|
// Handle body based on its type
|
||||||
if (typeof body === 'string') {
|
if (typeof body === 'string') {
|
||||||
|
|
||||||
if (isJson(body)) {
|
if (isJson(body)) {
|
||||||
const parsed = JSON.parse(body);
|
const parsed = JSON.parse(body);
|
||||||
if (jsonContainsValue(parsed, customBase64)) {
|
if (jsonContainsValue(parsed, customBase64)) {
|
||||||
@ -856,7 +834,6 @@ window.fetch = async function(input, init = {}) {
|
|||||||
sendToBackground({ url, method, headers, body: modifiedBody });
|
sendToBackground({ url, method, headers, body: modifiedBody });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Ensure the modified body is used and passed to the original fetch call
|
// Ensure the modified body is used and passed to the original fetch call
|
||||||
init.body = modifiedBody;
|
init.body = modifiedBody;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user