From 8fb1787222e72953a969b8cd4a1360c70d2e8354 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sun, 5 May 2024 18:04:20 +0700 Subject: [PATCH] Disable telemetry flags in meversion.js --- src/index.ts | 7 +++--- src/utils/monkey-patches.ts | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 09396fe..6b2dd4d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,7 @@ import { RemotePlay } from "@modules/remote-play"; import { onHistoryChanged, patchHistoryMethod } from "@utils/history"; import { VibrationManager } from "@modules/vibration-manager"; import { PreloadedState } from "@utils/titles-info"; -import { patchAudioContext, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "@utils/monkey-patches"; +import { patchAudioContext, patchMeControl, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "@utils/monkey-patches"; import { STATES } from "@utils/global"; import { injectStreamMenuButtons } from "@modules/stream/stream-ui"; import { BxLogger } from "@utils/bx-logger"; @@ -216,9 +216,8 @@ function main() { interceptHttpRequests(); patchVideoApi(); - if (getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL)) { - patchAudioContext(); - } + getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && patchAudioContext(); + getPref(PrefKey.BLOCK_TRACKING) && patchMeControl(); PreloadedState.override(); diff --git a/src/utils/monkey-patches.ts b/src/utils/monkey-patches.ts index 81ad97e..262e602 100644 --- a/src/utils/monkey-patches.ts +++ b/src/utils/monkey-patches.ts @@ -130,3 +130,53 @@ export function patchAudioContext() { return ctx; } } + +/** + * Disable telemetry flags in meversion.js + */ +export function patchMeControl() { + const overrideConfigs = { + enableAADTelemetry: false, + enableTelemetry: false, + telEvs: '', + oneDSUrl: '', + }; + + const MSA = { + MeControl: {}, + }; + const MeControl = {}; + + const MsaHandler: ProxyHandler = { + get(target, prop, receiver) { + return target[prop]; + }, + + set(obj, prop, value) { + if (prop === 'MeControl' && value.Config) { + value.Config = Object.assign(value.Config, overrideConfigs); + } + + obj[prop] = value; + return true; + }, + }; + + const MeControlHandler: ProxyHandler = { + get(target, prop, receiver) { + return target[prop]; + }, + + set(obj, prop, value) { + if (prop === 'Config') { + value = Object.assign(value, overrideConfigs); + } + + obj[prop] = value; + return true; + }, + }; + + (window as any).MSA = new Proxy(MSA, MsaHandler); + (window as any).MeControl = new Proxy(MeControl, MeControlHandler); +}