From 9d0f4c380b4977eef14251d059f979eb1abec65d Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:50:59 +0700 Subject: [PATCH] Fix global vars --- src/index.ts | 25 ++++--------------------- src/modules/bx-event.ts | 2 ++ src/modules/bx-exposed.ts | 2 ++ src/modules/loading-screen.ts | 4 +--- src/modules/mkb/mkb-handler.ts | 11 +++++------ src/modules/mkb/mkb-remapper.ts | 2 +- src/modules/patcher.ts | 4 ++-- src/modules/preferences.ts | 3 ++- src/modules/remote-play.ts | 4 ++-- src/modules/screenshot.ts | 1 + src/modules/settings.ts | 6 +++--- src/modules/stream/stream-badges.ts | 3 ++- src/modules/stream/stream-stats.ts | 9 +++++---- src/modules/stream/stream-ui.ts | 3 +++ src/modules/touch-controller.ts | 5 ++++- src/modules/translation.ts | 2 ++ src/modules/ui/global-settings.ts | 8 ++++++-- src/modules/ui/header.ts | 1 + src/modules/ui/ui.ts | 3 ++- src/modules/vibration-manager.ts | 1 + src/types/index.d.ts | 9 --------- src/types/preferences.d.ts | 2 +- src/utils/css.ts | 12 ++++++------ src/utils/global.ts | 22 ++++++++++++++++++++++ src/utils/monkey-patches.ts | 1 + src/utils/network.ts | 4 +--- src/utils/region.ts | 3 ++- src/utils/titles-info.ts | 1 + src/utils/user-agent.ts | 2 +- src/utils/utils.ts | 1 + 30 files changed, 87 insertions(+), 69 deletions(-) create mode 100644 src/utils/global.ts diff --git a/src/index.ts b/src/index.ts index 3c71412..b5efa46 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,10 +14,11 @@ // ==/UserScript== 'use strict'; +import "./utils/global"; import { BxEvent } from "./modules/bx-event"; import { BX_FLAGS } from "./modules/bx-flags"; import { BxExposed } from "./modules/bx-exposed"; -import { getLocale, t } from "./modules/translation"; +import { t } from "./modules/translation"; import { CE } from "./utils/html"; import { showGamepadToast } from "./utils/gamepad"; import { MkbHandler } from "./modules/mkb/mkb-handler"; @@ -26,7 +27,7 @@ import { StreamStats } from "./modules/stream/stream-stats"; import { addCss } from "./utils/css"; import { Toast } from "./utils/toast"; import { setupBxUi, updateVideoPlayerCss } from "./modules/ui/ui"; -import { PrefKey, Preferences, getPref } from "./modules/preferences"; +import { PrefKey, getPref } from "./modules/preferences"; import { LoadingScreen } from "./modules/loading-screen"; import { MouseCursorHider } from "./modules/mkb/mouse-cursor-hider"; import { TouchController } from "./modules/touch-controller"; @@ -39,25 +40,7 @@ import { VibrationManager } from "./modules/vibration-manager"; import { PreloadedState } from "./utils/titles-info"; import { patchAudioContext, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "./utils/monkey-patches"; import { interceptHttpRequests } from "./utils/network"; - -globalThis.SCRIPT_VERSION = '3.5.3'; -globalThis.SCRIPT_HOME = 'https://github.com/redphx/better-xcloud'; - -globalThis.NATIVE_FETCH = window.fetch; - -globalThis.LOCALE = getLocale(); - -globalThis.AppInterface = window.AppInterface; -globalThis.States = { - isPlaying: false, - appContext: {}, - serverRegions: {}, - hasTouchSupport: ('ontouchstart' in window || navigator.maxTouchPoints > 0), - - currentStream: {}, - remotePlay: {}, -}; - +import { States } from "./utils/global"; /* ADDITIONAL CODE */ diff --git a/src/modules/bx-event.ts b/src/modules/bx-event.ts index 8c5e040..0733702 100644 --- a/src/modules/bx-event.ts +++ b/src/modules/bx-event.ts @@ -1,3 +1,5 @@ +import { AppInterface } from "../utils/global"; + export enum BxEvent { JUMP_BACK_IN_READY = 'bx-jump-back-in-ready', POPSTATE = 'bx-popstate', diff --git a/src/modules/bx-exposed.ts b/src/modules/bx-exposed.ts index 5d598a3..85ac374 100644 --- a/src/modules/bx-exposed.ts +++ b/src/modules/bx-exposed.ts @@ -1,3 +1,5 @@ +import { States } from "../utils/global"; + export const BxExposed = { onPollingModeChanged: (mode: 'All' | 'None') => { if (!States.isPlaying) { diff --git a/src/modules/loading-screen.ts b/src/modules/loading-screen.ts index bdc77a6..7d5bee6 100644 --- a/src/modules/loading-screen.ts +++ b/src/modules/loading-screen.ts @@ -1,7 +1,7 @@ import { CE } from "../utils/html"; import { getPreferredServerRegion } from "../utils/region"; import { TitlesInfo } from "../utils/titles-info"; -import { PrefKey, Preferences, getPref } from "./preferences"; +import { PrefKey, getPref } from "./preferences"; import { t } from "./translation"; export class LoadingScreen { @@ -112,8 +112,6 @@ export class LoadingScreen { endDateStr = endDateStr.substring(0, 10) + ' ' + endDateStr.substring(11, 19); endDateStr += ` (${LoadingScreen.#secondsToString(waitTime)})`; - let estimatedWaitTime = LoadingScreen.#secondsToString(waitTime); - let $waitTimeBox = LoadingScreen.#$waitTimeBox; if (!$waitTimeBox) { $waitTimeBox = CE('div', {'class': 'bx-wait-time-box'}, diff --git a/src/modules/mkb/mkb-handler.ts b/src/modules/mkb/mkb-handler.ts index 662f18f..0d6b3a5 100644 --- a/src/modules/mkb/mkb-handler.ts +++ b/src/modules/mkb/mkb-handler.ts @@ -126,7 +126,7 @@ export class MkbHandler { const virtualGamepad = this.#getVirtualGamepad(); if (buttonIndex >= 100) { - let [valueArr, axisIndex, fullValue] = this.#STICK_MAP[buttonIndex]; + let [valueArr, axisIndex] = this.#STICK_MAP[buttonIndex]; valueArr = valueArr as number[]; axisIndex = axisIndex as number; @@ -232,7 +232,6 @@ export class MkbHandler { const analog = mouseMapTo === MouseMapTo.LS ? GamepadStick.LEFT : GamepadStick.RIGHT; - const virtualGamepad = this.#getVirtualGamepad(); let { x, y } = this.#getStickAxes(analog); const length = this.#vectorLength(x, y); @@ -258,7 +257,7 @@ export class MkbHandler { } } - #onMouseStopped = (e: MouseEvent) => { + #onMouseStopped = () => { this.#allowStickDecaying = true; requestAnimationFrame(this.#decayStick); } @@ -273,7 +272,7 @@ export class MkbHandler { this.#allowStickDecaying = false; this.#detectMouseStoppedTimeout && clearTimeout(this.#detectMouseStoppedTimeout); - this.#detectMouseStoppedTimeout = setTimeout(this.#onMouseStopped.bind(this, e), 100); + this.#detectMouseStoppedTimeout = setTimeout(this.#onMouseStopped.bind(this), 100); const deltaX = e.movementX; const deltaY = e.movementY; @@ -326,7 +325,7 @@ export class MkbHandler { }); } - #onPointerLockChange = (e: Event) => { + #onPointerLockChange = () => { if (this.#enabled && !document.pointerLockElement) { this.stop(); this.#waitForPointerLock(true); @@ -458,7 +457,7 @@ export class MkbHandler { } static setupEvents() { - window.addEventListener(BxEvent.STREAM_PLAYING, e => { + window.addEventListener(BxEvent.STREAM_PLAYING, () => { // Enable MKB if (getPref(PrefKey.MKB_ENABLED)) { console.log('Emulate MKB'); diff --git a/src/modules/mkb/mkb-remapper.ts b/src/modules/mkb/mkb-remapper.ts index ddefa35..14c5557 100644 --- a/src/modules/mkb/mkb-remapper.ts +++ b/src/modules/mkb/mkb-remapper.ts @@ -10,7 +10,7 @@ import { MkbHandler } from "./mkb-handler"; import { LocalDb } from "../../utils/local-db"; import { Icon } from "../../utils/html"; import { SettingElement } from "../settings"; -import type { MkbConvertedPresetData, MkbPresetData, MkbStoredPresets } from "../../types/mkb"; +import type { MkbPresetData, MkbStoredPresets } from "../../types/mkb"; type MkbRemapperElements = { diff --git a/src/modules/patcher.ts b/src/modules/patcher.ts index 6b29d43..97329f1 100644 --- a/src/modules/patcher.ts +++ b/src/modules/patcher.ts @@ -1,5 +1,6 @@ +import { States } from "../utils/global"; import { BX_FLAGS } from "./bx-flags"; -import { getPref, Preferences, PrefKey } from "./preferences"; +import { getPref, PrefKey } from "./preferences"; import { VibrationManager } from "./vibration-manager"; const PATCHES = { @@ -492,7 +493,6 @@ export class Patcher { static patch(item: any) { // console.log('patch', '-----'); - let patchName; let appliedPatches; for (let id in item[1]) { diff --git a/src/modules/preferences.ts b/src/modules/preferences.ts index 8a65577..cd53627 100644 --- a/src/modules/preferences.ts +++ b/src/modules/preferences.ts @@ -3,7 +3,8 @@ import { t } from "./translation"; import { SettingElement, SettingElementType } from "./settings"; import { UserAgentProfile } from "../utils/user-agent"; import { StreamStat } from "./stream/stream-stats"; -import type { PreferenceSetting, PreferenceSettings } from "../types/preferences"; +import type { PreferenceSettings } from "../types/preferences"; +import { States } from "../utils/global"; export enum PrefKey { LAST_UPDATE_CHECK = 'version_last_check', diff --git a/src/modules/remote-play.ts b/src/modules/remote-play.ts index bf82d3f..f5bc6d0 100644 --- a/src/modules/remote-play.ts +++ b/src/modules/remote-play.ts @@ -1,7 +1,8 @@ +import { States, AppInterface } from "../utils/global"; import { CE, createButton, ButtonStyle, Icon } from "../utils/html"; import { Toast } from "../utils/toast"; import { BxEvent } from "./bx-event"; -import { getPref, Preferences, PrefKey, setPref } from "./preferences"; +import { getPref, PrefKey, setPref } from "./preferences"; import { t } from "./translation"; import { localRedirect } from "./ui/ui"; @@ -82,7 +83,6 @@ export class RemotePlay { }; static #$content: HTMLElement; - static #$consoles: HTMLElement; static #initialize() { if (RemotePlay.#$content) { diff --git a/src/modules/screenshot.ts b/src/modules/screenshot.ts index 51f762e..f7d904a 100644 --- a/src/modules/screenshot.ts +++ b/src/modules/screenshot.ts @@ -1,3 +1,4 @@ +import { States, AppInterface } from "../utils/global"; import { CE } from "../utils/html"; export function takeScreenshot(callback: any) { diff --git a/src/modules/settings.ts b/src/modules/settings.ts index 25662ea..495aff0 100644 --- a/src/modules/settings.ts +++ b/src/modules/settings.ts @@ -1,5 +1,5 @@ +import type { PreferenceSetting } from "../types/preferences"; import { CE } from "../utils/html"; -import type { PreferenceSetting } from "./preferences"; type MultipleOptionsParams = { size?: number; @@ -53,8 +53,8 @@ export class SettingElement { $control.setAttribute('size', params.size.toString()); } - for (let value in setting.multiple_options) { - const label = setting.multiple_options[value]; + for (let value in setting.multipleOptions) { + const label = setting.multipleOptions[value]; const $option = CE('option', {value: value}, label) as HTMLOptionElement; $option.selected = currentValue.indexOf(value) > -1; diff --git a/src/modules/stream/stream-badges.ts b/src/modules/stream/stream-badges.ts index 9c503c6..c2dd98c 100644 --- a/src/modules/stream/stream-badges.ts +++ b/src/modules/stream/stream-badges.ts @@ -1,6 +1,7 @@ import { t } from "../translation"; import { BxEvent } from "../bx-event"; import { CE } from "../../utils/html"; +import { States } from "../../utils/global"; enum StreamBadge { PLAYTIME = 'playtime', @@ -85,7 +86,7 @@ export class StreamBadges { } catch(e) {} } - const stats = await STREAM_WEBRTC.getStats(); + const stats = await States.currentStream.peerConnection?.getStats()!; let totalIn = 0; let totalOut = 0; stats.forEach(stat => { diff --git a/src/modules/stream/stream-stats.ts b/src/modules/stream/stream-stats.ts index ca636c0..e4273bb 100644 --- a/src/modules/stream/stream-stats.ts +++ b/src/modules/stream/stream-stats.ts @@ -1,9 +1,10 @@ -import { PrefKey, Preferences } from "../preferences" +import { PrefKey } from "../preferences" import { BxEvent } from "../bx-event" import { getPref } from "../preferences" import { StreamBadges } from "./stream-badges" import { CE } from "../../utils/html" import { t } from "../translation" +import { States } from "../../utils/global" export enum StreamStat { PING = 'ping', @@ -105,13 +106,13 @@ export class StreamStats { } static update() { - if (StreamStats.isHidden() || !STREAM_WEBRTC) { + if (StreamStats.isHidden() || !States.currentStream.peerConnection) { StreamStats.onStoppedPlaying(); return; } const PREF_STATS_CONDITIONAL_FORMATTING = getPref(PrefKey.STATS_CONDITIONAL_FORMATTING); - STREAM_WEBRTC.getStats().then(stats => { + States.currentStream.peerConnection.getStats().then(stats => { stats.forEach(stat => { let grade = ''; if (stat.type === 'inbound-rtp' && stat.kind === 'video') { @@ -213,7 +214,7 @@ export class StreamStats { } static getServerStats() { - STREAM_WEBRTC && STREAM_WEBRTC.getStats().then(stats => { + States.currentStream.peerConnection && States.currentStream.peerConnection.getStats().then(stats => { const allVideoCodecs: {[index: string]: RTCBasicStat} = {}; let videoCodecId; diff --git a/src/modules/stream/stream-ui.ts b/src/modules/stream/stream-ui.ts index 95f3e09..514c76b 100644 --- a/src/modules/stream/stream-ui.ts +++ b/src/modules/stream/stream-ui.ts @@ -1,3 +1,4 @@ +import { States } from "../../utils/global"; import { Icon } from "../../utils/html"; import { BxEvent } from "../bx-event"; import { PrefKey, getPref } from "../preferences"; @@ -44,6 +45,7 @@ class MouseHoldEvent { this.#$elm.addEventListener('touchend', this.#onMouseUp.bind(this)); } + /* #clearEventLiseners = () => { this.#$elm.removeEventListener('mousedown', this.#onMouseDown); this.#$elm.removeEventListener('click', this.#onMouseUp); @@ -51,6 +53,7 @@ class MouseHoldEvent { this.#$elm.removeEventListener('touchstart', this.#onMouseDown); this.#$elm.removeEventListener('touchend', this.#onMouseUp); } + */ constructor($elm: HTMLElement, callback: any, duration=1000) { this.#$elm = $elm; diff --git a/src/modules/touch-controller.ts b/src/modules/touch-controller.ts index f9fc4c4..e9226c9 100644 --- a/src/modules/touch-controller.ts +++ b/src/modules/touch-controller.ts @@ -1,8 +1,9 @@ +import { NATIVE_FETCH, States } from "../utils/global"; import { CE } from "../utils/html"; import { Toast } from "../utils/toast"; import { BxEvent } from "./bx-event"; import { BX_FLAGS } from "./bx-flags"; -import { getPref, Preferences, PrefKey } from "./preferences"; +import { getPref, PrefKey } from "./preferences"; import { t } from "./translation"; export class TouchController { @@ -11,10 +12,12 @@ export class TouchController { origin: 'better-xcloud', }); + /* static readonly #EVENT_HIDE_CONTROLLER = new MessageEvent('message', { data: '{"content":"","target":"/streaming/touchcontrols/hide","type":"Message"}', origin: 'better-xcloud', }); + */ static #$bar: HTMLElement; static #$style: HTMLStyleElement; diff --git a/src/modules/translation.ts b/src/modules/translation.ts index 17e8f23..d1b669e 100644 --- a/src/modules/translation.ts +++ b/src/modules/translation.ts @@ -1,3 +1,5 @@ +import { LOCALE } from "../utils/global"; + const Translations = { enUS: -1, diff --git a/src/modules/ui/global-settings.ts b/src/modules/ui/global-settings.ts index f202ae1..3ed0afb 100644 --- a/src/modules/ui/global-settings.ts +++ b/src/modules/ui/global-settings.ts @@ -1,8 +1,9 @@ +import { States, AppInterface, SCRIPT_HOME, SCRIPT_VERSION } from "../../utils/global"; import { CE, createButton, Icon, ButtonStyle } from "../../utils/html"; import { getPreferredServerRegion } from "../../utils/region"; import { UserAgent, UserAgentProfile } from "../../utils/user-agent"; import { getPref, Preferences, PrefKey, setPref, toPrefElement } from "../preferences"; -import { getLocale, t } from "../translation"; +import { t } from "../translation"; const SETTINGS_UI = { 'Better xCloud': { @@ -159,7 +160,7 @@ export function setupSettingsUi() { if ((e.target as HTMLElement).id === 'bx_setting_' + PrefKey.BETTER_XCLOUD_LOCALE) { // Update locale - LOCALE = getLocale(); + refreshLocale(); const $btn = $reloadBtnWrapper.firstElementChild! as HTMLButtonElement; $btn.textContent = t('settings-reloading'); @@ -345,3 +346,6 @@ export function setupSettingsUi() { const $pageContent = document.getElementById('PageContent'); $pageContent?.parentNode?.insertBefore($container, $pageContent); } +function refreshLocale() { + throw new Error("Function not implemented."); +} diff --git a/src/modules/ui/header.ts b/src/modules/ui/header.ts index 057ffe9..0b5d270 100644 --- a/src/modules/ui/header.ts +++ b/src/modules/ui/header.ts @@ -1,3 +1,4 @@ +import { SCRIPT_VERSION } from "../../utils/global"; import { createButton, Icon, ButtonStyle } from "../../utils/html"; import { getPreferredServerRegion } from "../../utils/region"; import { PrefKey, getPref } from "../preferences"; diff --git a/src/modules/ui/ui.ts b/src/modules/ui/ui.ts index 6d8523f..ac13b3a 100644 --- a/src/modules/ui/ui.ts +++ b/src/modules/ui/ui.ts @@ -1,8 +1,9 @@ +import { States } from "../../utils/global"; import { Icon, CE, createButton, ButtonStyle } from "../../utils/html"; import { UserAgent } from "../../utils/user-agent"; import { BxEvent } from "../bx-event"; import { MkbRemapper } from "../mkb/mkb-remapper"; -import { getPref, Preferences, PrefKey, toPrefElement } from "../preferences"; +import { getPref, PrefKey, toPrefElement } from "../preferences"; import { setupScreenshotButton } from "../screenshot"; import { StreamStats } from "../stream/stream-stats"; import { TouchController } from "../touch-controller"; diff --git a/src/modules/vibration-manager.ts b/src/modules/vibration-manager.ts index 88a8eff..cb2bb96 100644 --- a/src/modules/vibration-manager.ts +++ b/src/modules/vibration-manager.ts @@ -1,3 +1,4 @@ +import { AppInterface } from "../utils/global"; import { BxEvent } from "./bx-event"; import { PrefKey, getPref } from "./preferences"; diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 7a66489..de0c2f2 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -50,12 +50,3 @@ type BxStates = { } type DualEnum = {[index: string]: number} & {[index: number]: 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/types/preferences.d.ts b/src/types/preferences.d.ts index 005bb11..cf867dd 100644 --- a/src/types/preferences.d.ts +++ b/src/types/preferences.d.ts @@ -1,7 +1,7 @@ export type PreferenceSetting = { default: any; options?: {[index: string]: string}; - multiplOptions?: {[index: string]: string}; + multipleOptions?: {[index: string]: string}; unsupported?: string | boolean; note?: string | HTMLElement; type?: SettingElementType; diff --git a/src/utils/css.ts b/src/utils/css.ts index 68c8777..96fe6fb 100644 --- a/src/utils/css.ts +++ b/src/utils/css.ts @@ -1,5 +1,5 @@ import { CE, Icon } from "./html"; -import { Preferences, getPref } from "../modules/preferences"; +import { PrefKey, getPref } from "../modules/preferences"; export function addCss() { @@ -1273,7 +1273,7 @@ div[class*=NotFocusedDialog] { `; // Hide "Play with friends" section - if (getPref(Preferences.BLOCK_SOCIAL_FEATURES)) { + if (getPref(PrefKey.BLOCK_SOCIAL_FEATURES)) { css += ` div[class^=HomePage-module__bottomSpacing]:has(button[class*=SocialEmptyCard]), button[class*=SocialEmptyCard] { @@ -1283,7 +1283,7 @@ button[class*=SocialEmptyCard] { } // Reduce animations - if (getPref(Preferences.REDUCE_ANIMATIONS)) { + if (getPref(PrefKey.REDUCE_ANIMATIONS)) { css += ` div[class*=GameCard-module__gameTitleInnerWrapper], div[class*=GameCard-module__card], @@ -1294,7 +1294,7 @@ div[class*=ScrollArrows-module] { } // Hide the top-left dots icon while playing - if (getPref(Preferences.HIDE_DOTS_ICON)) { + if (getPref(PrefKey.HIDE_DOTS_ICON)) { css += ` div[class*=Grip-module__container] { visibility: hidden; @@ -1326,7 +1326,7 @@ div[class*=StreamMenu-module__menu] { min-width: 100vw !important; } `; - if (getPref(Preferences.STREAM_SIMPLIFY_MENU)) { + if (getPref(PrefKey.STREAM_SIMPLIFY_MENU)) { css += ` div[class*=Menu-module__scrollable] { --bxStreamMenuItemSize: 80px; @@ -1386,7 +1386,7 @@ body:not([data-media-type=tv]) div[class*=MenuItem-module__label] { } // Hide scrollbar - if (getPref(Preferences.UI_SCROLLBAR_HIDE)) { + if (getPref(PrefKey.UI_SCROLLBAR_HIDE)) { css += ` html { scrollbar-width: none; diff --git a/src/utils/global.ts b/src/utils/global.ts new file mode 100644 index 0000000..bf6e35e --- /dev/null +++ b/src/utils/global.ts @@ -0,0 +1,22 @@ +import { getLocale } from "../modules/translation"; + +export const AppInterface = window.AppInterface; +export const NATIVE_FETCH = window.fetch; +export const States: BxStates = { + isPlaying: false, + appContext: {}, + serverRegions: {}, + hasTouchSupport: ('ontouchstart' in window || navigator.maxTouchPoints > 0), + + currentStream: {}, + remotePlay: {}, +}; + +export const SCRIPT_VERSION = '3.5.3'; +export const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud'; + +export var LOCALE = getLocale(); + +export const refreshLocale = () => { + LOCALE = getLocale(); +} diff --git a/src/utils/monkey-patches.ts b/src/utils/monkey-patches.ts index 2f9602e..cf813c0 100644 --- a/src/utils/monkey-patches.ts +++ b/src/utils/monkey-patches.ts @@ -1,5 +1,6 @@ import { BxEvent } from "../modules/bx-event"; import { getPref, PrefKey } from "../modules/preferences"; +import { States } from "./global"; import { UserAgent } from "./user-agent"; export function patchVideoApi() { diff --git a/src/utils/network.ts b/src/utils/network.ts index f014d40..51e7087 100644 --- a/src/utils/network.ts +++ b/src/utils/network.ts @@ -1,11 +1,11 @@ import { BxEvent } from "../modules/bx-event"; import { BX_FLAGS } from "../modules/bx-flags"; import { LoadingScreen } from "../modules/loading-screen"; -import { MouseCursorHider } from "../modules/mkb/mouse-cursor-hider"; import { PrefKey, getPref } from "../modules/preferences"; import { RemotePlay } from "../modules/remote-play"; import { StreamBadges } from "../modules/stream/stream-badges"; import { TouchController } from "../modules/touch-controller"; +import { NATIVE_FETCH, States } from "./global"; import { getPreferredServerRegion } from "./region"; import { TitlesInfo } from "./titles-info"; @@ -549,8 +549,6 @@ export function interceptHttpRequests() { return nativeXhrSend.apply(this, arguments); }; - const PREF_UI_LOADING_SCREEN_GAME_ART = getPref(PrefKey.UI_LOADING_SCREEN_GAME_ART); - window.fetch = async (request: RequestInfo | URL, init?: RequestInit): Promise => { let url = (typeof request === 'string') ? request : (request as Request).url; diff --git a/src/utils/region.ts b/src/utils/region.ts index be39380..ba932a7 100644 --- a/src/utils/region.ts +++ b/src/utils/region.ts @@ -1,4 +1,5 @@ -import { getPref, Preferences, PrefKey } from "../modules/preferences"; +import { getPref, PrefKey } from "../modules/preferences"; +import { States } from "./global"; export function getPreferredServerRegion(shortName = false) { diff --git a/src/utils/titles-info.ts b/src/utils/titles-info.ts index 5eeff6a..15395e1 100644 --- a/src/utils/titles-info.ts +++ b/src/utils/titles-info.ts @@ -1,5 +1,6 @@ import { PrefKey } from "../modules/preferences"; import { getPref } from "../modules/preferences"; +import { States } from "./global"; import { UserAgent } from "./user-agent"; export class TitlesInfo { diff --git a/src/utils/user-agent.ts b/src/utils/user-agent.ts index 3081edb..6f4e609 100644 --- a/src/utils/user-agent.ts +++ b/src/utils/user-agent.ts @@ -1,4 +1,4 @@ -import { PrefKey, Preferences, getPref } from "../modules/preferences"; +import { PrefKey, getPref } from "../modules/preferences"; export enum UserAgentProfile { EDGE_WINDOWS = 'edge-windows', diff --git a/src/utils/utils.ts b/src/utils/utils.ts index a927637..2217dc8 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,4 +1,5 @@ import { PrefKey, getPref, setPref } from "../modules/preferences"; +import { SCRIPT_VERSION } from "./global"; import { UserAgent } from "./user-agent"; export function checkForUpdate() {