Update inject.js

- Rollback EME interception
This commit is contained in:
TPD94 2025-06-02 13:44:57 -04:00
parent 55b5bf344d
commit 094f1edac2

View File

@ -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,21 +626,10 @@ 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) {
const messageInterceptor = function(event) {
const uint8View = new Uint8Array(event.message);
const base64String = btoa(String.fromCharCode(...uint8View));
if (base64String === "CAQ=") {
console.log("[CAQ] Detected - letting original message through.");
return; // Allow original message
}
if (!intercepted) {
intercepted = true;
event.stopImmediatePropagation(); event.stopImmediatePropagation();
console.log("[Intercepted EME Message] Injecting custom message."); console.log("[Intercepted EME Message] Injecting custom message.");
console.log(event.data);
const uint8 = base64ToUint8Array(customBase64); const uint8 = base64ToUint8Array(customBase64);
const arrayBuffer = uint8.buffer; const arrayBuffer = uint8.buffer;
@ -658,15 +645,10 @@ MediaKeySession.prototype.generateRequest = async function(initDataType, initDat
Object.defineProperty(syntheticEvent, "message", { Object.defineProperty(syntheticEvent, "message", {
get: () => arrayBuffer get: () => arrayBuffer
}); });
console.log(syntheticEvent);
setTimeout(() => session.dispatchEvent(syntheticEvent), 0); setTimeout(() => session.dispatchEvent(syntheticEvent), 0);
}, { once: true });
// 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
@ -806,7 +786,6 @@ window.fetch = async function(input, init = {}) {
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) {
const formData = {}; const 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)) {
@ -857,7 +835,6 @@ window.fetch = async function(input, init = {}) {
} }
} }
// 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;