From a0a453084a397591a4de1245e2b53ca027d2f153 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sun, 26 Nov 2023 15:57:16 +0700 Subject: [PATCH] Add patches to block ApplicationInsights.track() and WebRTC stats collector --- better-xcloud.user.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/better-xcloud.user.js b/better-xcloud.user.js index 8948a21..e810e86 100644 --- a/better-xcloud.user.js +++ b/better-xcloud.user.js @@ -3299,7 +3299,7 @@ class PreloadedState { return this._state; }, - set: (state) => { + set: state => { this._state = state; APP_CONTEXT = structuredClone(state.appContext); @@ -4091,6 +4091,31 @@ class Patcher { return funcStr.replace(text, 'this.trackEvent=e=>{},this.uwuwu='); }, + // Disable ApplicationInsights.track() function + disableAiTrack: PREFS.get(Preferences.BLOCK_TRACKING) && function(funcStr) { + const text = '.track=function('; + const index = funcStr.indexOf(text); + if (index === -1) { + return false; + } + + if (funcStr.substring(0, index + 200).includes('"AppInsightsCore')) { + return false; + } + + return funcStr.substring(0, index) + '.track=function(e){},!!function(' + funcStr.substring(index + text.length); + }, + + // Block WebRTC stats collector + blockWebRtcStatsCollector: PREFS.get(Preferences.BLOCK_TRACKING) && function(funcStr) { + const text = 'this.intervalMs=0,'; + if (!funcStr.includes(text)) { + return false; + } + + return funcStr.replace(text, 'false,' + text); + }, + // Set TV layout tvLayout: PREFS.get(Preferences.UI_LAYOUT) === 'tv' && function(funcStr) { const text = '?"tv":"default"'; @@ -4113,7 +4138,7 @@ class Patcher { } return funcStr; - } + }, }; static #patchFunctionBind() {