diff --git a/src/index.ts b/src/index.ts index e8f675a..3c71412 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,15 +40,15 @@ import { PreloadedState } from "./utils/titles-info"; import { patchAudioContext, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "./utils/monkey-patches"; import { interceptHttpRequests } from "./utils/network"; -const SCRIPT_VERSION = '3.5.3'; -const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud'; +globalThis.SCRIPT_VERSION = '3.5.3'; +globalThis.SCRIPT_HOME = 'https://github.com/redphx/better-xcloud'; -const NATIVE_FETCH = window.fetch; +globalThis.NATIVE_FETCH = window.fetch; -let LOCALE = getLocale(); +globalThis.LOCALE = getLocale(); -const AppInterface = window.AppInterface; -let States: BxStates = { +globalThis.AppInterface = window.AppInterface; +globalThis.States = { isPlaying: false, appContext: {}, serverRegions: {}, diff --git a/src/modules/bx-exposed.ts b/src/modules/bx-exposed.ts index b5cfe86..5d598a3 100644 --- a/src/modules/bx-exposed.ts +++ b/src/modules/bx-exposed.ts @@ -1,5 +1,3 @@ -declare var States: BxStates; - export const BxExposed = { onPollingModeChanged: (mode: 'All' | 'None') => { if (!States.isPlaying) { diff --git a/src/types/index.d.ts b/src/types/index.d.ts index acd267f..7a66489 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -51,11 +51,11 @@ type BxStates = { type DualEnum = {[index: string]: number} & {[index: number]: string}; -declare const window: Window & typeof globalThis; -declare const AppInterface: any; -declare const STREAM_WEBRTC: RTCPeerConnection; -declare let States: BxStates; -declare const NATIVE_FETCH: typeof window.fetch; -declare const SCRIPT_VERSION: string; -declare const SCRIPT_HOME: string; +declare var SCRIPT_VERSION: string; +declare var window: Window & typeof globalThis; +declare var AppInterface: any; +declare var STREAM_WEBRTC: RTCPeerConnection; +declare var States: BxStates; +declare var NATIVE_FETCH: typeof window.fetch; +declare var SCRIPT_HOME: string; declare var LOCALE: number; diff --git a/src/utils/region.ts b/src/utils/region.ts index db29738..be39380 100644 --- a/src/utils/region.ts +++ b/src/utils/region.ts @@ -1,8 +1,6 @@ import { getPref, Preferences, PrefKey } from "../modules/preferences"; -declare var States: BxStates; - export function getPreferredServerRegion(shortName = false) { let preferredRegion = getPref(PrefKey.SERVER_REGION); if (preferredRegion in States.serverRegions) {