mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-03 06:07:19 +02:00
Refactor
This commit is contained in:
parent
79ebb1a817
commit
de7bf3edc7
5
dist/better-xcloud.lite.user.js
vendored
5
dist/better-xcloud.lite.user.js
vendored
@ -5742,10 +5742,7 @@ function patchHistoryMethod(type) {
|
||||
}
|
||||
function onHistoryChanged(e) {
|
||||
if (e && e.arguments && e.arguments[0] && e.arguments[0].origin === "better-xcloud") return;
|
||||
window.setTimeout(RemotePlayManager.detect, 10);
|
||||
let $settings = document.querySelector(".bx-settings-container");
|
||||
if ($settings) $settings.classList.add("bx-gone");
|
||||
NavigationDialogManager.getInstance().hide(), LoadingScreen.reset(), window.setTimeout(HeaderSection.watchHeader, 2000), EventBus.Stream.emit("stateStopped", {});
|
||||
window.setTimeout(RemotePlayManager.detect, 10), NavigationDialogManager.getInstance().hide(), LoadingScreen.reset(), window.setTimeout(HeaderSection.watchHeader, 2000), EventBus.Stream.emit("stateStopped", {});
|
||||
}
|
||||
function setCodecPreferences(sdp, preferredCodec) {
|
||||
let h264Pattern = /a=fmtp:(\d+).*profile-level-id=([0-9a-f]{6})/g, profilePrefix = preferredCodec === "high" ? "4d" : preferredCodec === "low" ? "420" : "42e", preferredCodecIds = [], matches = sdp.matchAll(h264Pattern) || [];
|
||||
|
5
dist/better-xcloud.user.js
vendored
5
dist/better-xcloud.user.js
vendored
@ -8087,10 +8087,7 @@ function patchHistoryMethod(type) {
|
||||
}
|
||||
function onHistoryChanged(e) {
|
||||
if (e && e.arguments && e.arguments[0] && e.arguments[0].origin === "better-xcloud") return;
|
||||
window.setTimeout(RemotePlayManager.detect, 10);
|
||||
let $settings = document.querySelector(".bx-settings-container");
|
||||
if ($settings) $settings.classList.add("bx-gone");
|
||||
NavigationDialogManager.getInstance().hide(), LoadingScreen.reset(), window.setTimeout(HeaderSection.watchHeader, 2000), EventBus.Stream.emit("stateStopped", {});
|
||||
window.setTimeout(RemotePlayManager.detect, 10), NavigationDialogManager.getInstance().hide(), LoadingScreen.reset(), window.setTimeout(HeaderSection.watchHeader, 2000), EventBus.Stream.emit("stateStopped", {});
|
||||
}
|
||||
function setCodecPreferences(sdp, preferredCodec) {
|
||||
let h264Pattern = /a=fmtp:(\d+).*profile-level-id=([0-9a-f]{6})/g, profilePrefix = preferredCodec === "high" ? "4d" : preferredCodec === "low" ? "420" : "42e", preferredCodecIds = [], matches = sdp.matchAll(h264Pattern) || [];
|
||||
|
@ -160,7 +160,7 @@ document.addEventListener('readystatechange', e => {
|
||||
return;
|
||||
}
|
||||
|
||||
STATES.isSignedIn = !!((window as any).xbcUser?.isSignedIn);
|
||||
STATES.isSignedIn = !!window.xbcUser?.isSignedIn;
|
||||
|
||||
if (STATES.isSignedIn) {
|
||||
// Preload Remote Play
|
||||
|
@ -268,7 +268,7 @@ export class TouchController {
|
||||
|
||||
static setup() {
|
||||
// Function for testing touch control
|
||||
(window as any).testTouchLayout = (layout: any) => {
|
||||
window.testTouchLayout = (layout: any) => {
|
||||
const { touchLayoutManager } = window.BX_EXPOSED;
|
||||
|
||||
touchLayoutManager && touchLayoutManager.changeLayoutForScope({
|
||||
|
@ -442,7 +442,7 @@ export class NavigationDialogManager {
|
||||
BxEvent.dispatch(window, BxEvent.XCLOUD_DIALOG_SHOWN);
|
||||
|
||||
// Stop xCloud's navigation polling
|
||||
(window as any).BX_EXPOSED.disableGamepadPolling = true;
|
||||
window.BX_EXPOSED.disableGamepadPolling = true;
|
||||
|
||||
// Lock scroll bar
|
||||
document.body.classList.add('bx-no-scroll');
|
||||
@ -504,7 +504,7 @@ export class NavigationDialogManager {
|
||||
this.unmountCurrentDialog();
|
||||
|
||||
// Enable xCloud's navigation polling
|
||||
(window as any).BX_EXPOSED.disableGamepadPolling = false;
|
||||
window.BX_EXPOSED.disableGamepadPolling = false;
|
||||
|
||||
// Show the last dialog in dialogs stack
|
||||
if (this.dialogsStack.length) {
|
||||
|
@ -24,4 +24,4 @@ export function localRedirect(path: string) {
|
||||
$anchor.click();
|
||||
}
|
||||
|
||||
(window as any).localRedirect = localRedirect;
|
||||
window.localRedirect = localRedirect;
|
||||
|
19
src/types/global.d.ts
vendored
19
src/types/global.d.ts
vendored
@ -2,6 +2,8 @@ import type { BxExposed } from "@/utils/bx-exposed";
|
||||
import type { AllPresets, ControllerShortcutPresetRecord } from "./presets";
|
||||
import type { PrefKey } from "@/enums/pref-keys";
|
||||
import type { StreamSettings, type StreamSettingsData } from "@/utils/stream-settings";
|
||||
import type { BxEvent } from "@/utils/bx-event";
|
||||
import type { BxLogger } from "@/utils/bx-logger";
|
||||
|
||||
export {};
|
||||
|
||||
@ -24,5 +26,22 @@ declare global {
|
||||
|
||||
BX_REMOTE_PLAY_CONFIG: BxStates.remotePlay.config;
|
||||
BX_STREAM_SETTINGS: StreamSettingsData;
|
||||
|
||||
BX_FETCH: typeof window['fetch'];
|
||||
|
||||
BxEvent: typeof BxEvent;
|
||||
BxLogger: typeof BxLogger;
|
||||
localRedirect: (path: stringn) => void;
|
||||
testTouchLayout: (layout: any) => void;
|
||||
|
||||
chrome?: any;
|
||||
|
||||
// xCloud properties
|
||||
xbcUser?: {
|
||||
isSignedIn: boolean;
|
||||
};
|
||||
MSA: any;
|
||||
MeControl: any;
|
||||
adobe: any;
|
||||
}
|
||||
}
|
||||
|
@ -67,4 +67,4 @@ export namespace BxEvent {
|
||||
}
|
||||
}
|
||||
|
||||
(window as any).BxEvent = BxEvent;
|
||||
window.BxEvent = BxEvent;
|
||||
|
@ -16,4 +16,4 @@ export class BxLogger {
|
||||
}
|
||||
}
|
||||
|
||||
(window as any).BxLogger = BxLogger;
|
||||
window.BxLogger = BxLogger;
|
||||
|
@ -2,8 +2,8 @@ import { BxEvent } from "@utils/bx-event";
|
||||
import { LoadingScreen } from "@modules/loading-screen";
|
||||
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||
import { HeaderSection } from "@/modules/ui/header";
|
||||
import { NavigationDialogManager } from "@/modules/ui/dialog/navigation-dialog";
|
||||
import { EventBus } from "./event-bus";
|
||||
import { NavigationDialogManager } from "@/modules/ui/dialog/navigation-dialog";
|
||||
|
||||
export function patchHistoryMethod(type: 'pushState' | 'replaceState') {
|
||||
const orig = window.history[type];
|
||||
@ -27,12 +27,6 @@ export function onHistoryChanged(e: PopStateEvent) {
|
||||
|
||||
window.setTimeout(RemotePlayManager.detect, 10);
|
||||
|
||||
// Hide Global settings
|
||||
const $settings = document.querySelector('.bx-settings-container');
|
||||
if ($settings) {
|
||||
$settings.classList.add('bx-gone');
|
||||
}
|
||||
|
||||
// Hide Navigation dialog
|
||||
NavigationDialogManager.getInstance().hide();
|
||||
|
||||
|
@ -201,8 +201,8 @@ export function patchMeControl() {
|
||||
},
|
||||
};
|
||||
|
||||
(window as any).MSA = new Proxy(MSA, MsaHandler);
|
||||
(window as any).MeControl = new Proxy(MeControl, MeControlHandler);
|
||||
window.MSA = new Proxy(MSA, MsaHandler);
|
||||
window.MeControl = new Proxy(MeControl, MeControlHandler);
|
||||
}
|
||||
|
||||
|
||||
@ -210,7 +210,7 @@ export function patchMeControl() {
|
||||
* Disable Adobe Audience Manager (AAM)
|
||||
*/
|
||||
export function disableAdobeAudienceManager() {
|
||||
(window as any).adobe = Object.freeze({});
|
||||
window.adobe = Object.freeze({});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,7 +189,7 @@ export function interceptHttpRequests() {
|
||||
'2c06dea3f26c40c69b8456d319791fd0@o427368.ingest.sentry.io',
|
||||
];
|
||||
|
||||
(window as any).BX_FETCH = window.fetch = async (request: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
||||
window.BX_FETCH = window.fetch = async (request: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
||||
let url = (typeof request === 'string') ? request : (request as Request).url;
|
||||
|
||||
// Check blocked URLs
|
||||
|
@ -10,7 +10,7 @@ type UserAgentConfig = {
|
||||
const SMART_TV_UNIQUE_ID = 'FC4A1DA2-711C-4E9C-BC7F-047AF8A672EA';
|
||||
|
||||
let CHROMIUM_VERSION = '125.0.0.0';
|
||||
if (!!(window as any).chrome || window.navigator.userAgent.includes('Chrome')) {
|
||||
if (!!window.chrome || window.navigator.userAgent.includes('Chrome')) {
|
||||
// Get Chromium version in the original User-Agent value
|
||||
const match = window.navigator.userAgent.match(/\s(?:Chrome|Edg)\/([\d\.]+)/);
|
||||
if (match) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user