Update better-xcloud.user.js

This commit is contained in:
redphx 2024-08-03 17:20:27 +07:00
parent fb123e00d7
commit 619d70d3cb

View File

@ -149,7 +149,7 @@ var userAgent = window.navigator.userAgent.toLowerCase(), isTv = userAgent.inclu
var BxEvent; var BxEvent;
((BxEvent) => { ((BxEvent) => {
BxEvent.JUMP_BACK_IN_READY = "bx-jump-back-in-ready", BxEvent.POPSTATE = "bx-popstate", BxEvent.TITLE_INFO_READY = "bx-title-info-ready", BxEvent.SETTINGS_CHANGED = "bx-settings-changed", BxEvent.STREAM_LOADING = "bx-stream-loading", BxEvent.STREAM_STARTING = "bx-stream-starting", BxEvent.STREAM_STARTED = "bx-stream-started", BxEvent.STREAM_PLAYING = "bx-stream-playing", BxEvent.STREAM_STOPPED = "bx-stream-stopped", BxEvent.STREAM_ERROR_PAGE = "bx-stream-error-page", BxEvent.STREAM_WEBRTC_CONNECTED = "bx-stream-webrtc-connected", BxEvent.STREAM_WEBRTC_DISCONNECTED = "bx-stream-webrtc-disconnected", BxEvent.STREAM_SESSION_READY = "bx-stream-session-ready", BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED = "bx-custom-touch-layouts-loaded", BxEvent.TOUCH_LAYOUT_MANAGER_READY = "bx-touch-layout-manager-ready", BxEvent.REMOTE_PLAY_READY = "bx-remote-play-ready", BxEvent.REMOTE_PLAY_FAILED = "bx-remote-play-failed", BxEvent.XCLOUD_SERVERS_READY = "bx-servers-ready", BxEvent.XCLOUD_SERVERS_UNAVAILABLE = "bx-servers-unavailable", BxEvent.DATA_CHANNEL_CREATED = "bx-data-channel-created", BxEvent.GAME_BAR_ACTION_ACTIVATED = "bx-game-bar-action-activated", BxEvent.MICROPHONE_STATE_CHANGED = "bx-microphone-state-changed", BxEvent.CAPTURE_SCREENSHOT = "bx-capture-screenshot", BxEvent.POINTER_LOCK_REQUESTED = "bx-pointer-lock-requested", BxEvent.POINTER_LOCK_EXITED = "bx-pointer-lock-exited", BxEvent.NAVIGATION_FOCUS_CHANGED = "bx-nav-focus-changed", BxEvent.XCLOUD_DIALOG_SHOWN = "bx-xcloud-dialog-shown", BxEvent.XCLOUD_DIALOG_DISMISSED = "bx-xcloud-dialog-dismissed", BxEvent.XCLOUD_GUIDE_MENU_SHOWN = "bx-xcloud-guide-menu-shown", BxEvent.XCLOUD_POLLING_MODE_CHANGED = "bx-xcloud-polling-mode-changed", BxEvent.XCLOUD_RENDERING_COMPONENT = "bx-xcloud-rendering-page"; BxEvent.JUMP_BACK_IN_READY = "bx-jump-back-in-ready", BxEvent.POPSTATE = "bx-popstate", BxEvent.TITLE_INFO_READY = "bx-title-info-ready", BxEvent.SETTINGS_CHANGED = "bx-settings-changed", BxEvent.STREAM_LOADING = "bx-stream-loading", BxEvent.STREAM_STARTING = "bx-stream-starting", BxEvent.STREAM_STARTED = "bx-stream-started", BxEvent.STREAM_PLAYING = "bx-stream-playing", BxEvent.STREAM_STOPPED = "bx-stream-stopped", BxEvent.STREAM_ERROR_PAGE = "bx-stream-error-page", BxEvent.STREAM_WEBRTC_CONNECTED = "bx-stream-webrtc-connected", BxEvent.STREAM_WEBRTC_DISCONNECTED = "bx-stream-webrtc-disconnected", BxEvent.STREAM_SESSION_READY = "bx-stream-session-ready", BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED = "bx-custom-touch-layouts-loaded", BxEvent.TOUCH_LAYOUT_MANAGER_READY = "bx-touch-layout-manager-ready", BxEvent.REMOTE_PLAY_READY = "bx-remote-play-ready", BxEvent.REMOTE_PLAY_FAILED = "bx-remote-play-failed", BxEvent.XCLOUD_SERVERS_READY = "bx-servers-ready", BxEvent.XCLOUD_SERVERS_UNAVAILABLE = "bx-servers-unavailable", BxEvent.DATA_CHANNEL_CREATED = "bx-data-channel-created", BxEvent.GAME_BAR_ACTION_ACTIVATED = "bx-game-bar-action-activated", BxEvent.MICROPHONE_STATE_CHANGED = "bx-microphone-state-changed", BxEvent.CAPTURE_SCREENSHOT = "bx-capture-screenshot", BxEvent.POINTER_LOCK_REQUESTED = "bx-pointer-lock-requested", BxEvent.POINTER_LOCK_EXITED = "bx-pointer-lock-exited", BxEvent.NAVIGATION_FOCUS_CHANGED = "bx-nav-focus-changed", BxEvent.XCLOUD_DIALOG_SHOWN = "bx-xcloud-dialog-shown", BxEvent.XCLOUD_DIALOG_DISMISSED = "bx-xcloud-dialog-dismissed", BxEvent.XCLOUD_GUIDE_MENU_SHOWN = "bx-xcloud-guide-menu-shown", BxEvent.XCLOUD_POLLING_MODE_CHANGED = "bx-xcloud-polling-mode-changed", BxEvent.XCLOUD_RENDERING_COMPONENT = "bx-xcloud-rendering-page", BxEvent.XCLOUD_ROUTER_HISTORY_READY = "bx-xcloud-router-history-ready";
function dispatch(target, eventName, data) { function dispatch(target, eventName, data) {
if (!target) if (!target)
return; return;
@ -4055,6 +4055,16 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
if (index = str.indexOf("return", index - 40), index < 0) if (index = str.indexOf("return", index - 40), index < 0)
return !1; return !1;
return str = str.substring(0, index) + 'BxEvent.dispatch(window, BxEvent.XCLOUD_RENDERING_COMPONENT, {component: "product-details"});' + str.substring(index), str; return str = str.substring(0, index) + 'BxEvent.dispatch(window, BxEvent.XCLOUD_RENDERING_COMPONENT, {component: "product-details"});' + str.substring(index), str;
},
detectBrowserRouterReady(str) {
if (!str.includes("BrowserRouter:()=>"))
return !1;
let index = str.indexOf("{history:this.history,");
if (index < 0)
return !1;
if (index = PatcherUtils.lastIndexOf(str, "return", index, 100), index < 0)
return !1;
return str = PatcherUtils.insertAt(str, index, "window.BxEvent.dispatch(window, window.BxEvent.XCLOUD_ROUTER_HISTORY_READY, {history: this.history});"), str;
} }
}, PATCH_ORDERS = [ }, PATCH_ORDERS = [
...getPref("native_mkb_enabled") === "on" ? [ ...getPref("native_mkb_enabled") === "on" ? [
@ -4063,6 +4073,7 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
"disableNativeRequestPointerLock", "disableNativeRequestPointerLock",
"exposeInputSink" "exposeInputSink"
] : [], ] : [],
"detectBrowserRouterReady",
"patchRequestInfoCrash", "patchRequestInfoCrash",
"disableStreamGate", "disableStreamGate",
"overrideSettings", "overrideSettings",
@ -4172,7 +4183,7 @@ class Patcher {
item[1][id] = eval(patchedFuncStr); item[1][id] = eval(patchedFuncStr);
} catch (e) { } catch (e) {
if (e instanceof Error) if (e instanceof Error)
BxLogger.error(LOG_TAG3, "Error", appliedPatches, e.message); BxLogger.error(LOG_TAG3, "Error", appliedPatches, e.message, patchedFuncStr);
} }
if (appliedPatches.length) if (appliedPatches.length)
patchesMap[id] = appliedPatches; patchesMap[id] = appliedPatches;
@ -5785,18 +5796,16 @@ class HeaderSection {
$parent.appendChild(HeaderSection.#$buttonsWrapper); $parent.appendChild(HeaderSection.#$buttonsWrapper);
} }
static checkHeader() { static checkHeader() {
if (!HeaderSection.#$buttonsWrapper.isConnected) { let $target = document.querySelector("#PageContent div[class*=EdgewaterHeader-module__rightSectionSpacing]");
let $target = document.querySelector("#PageContent div[class*=EdgewaterHeader-module__rightSectionSpacing]"); if (!$target)
if (!$target) $target = document.querySelector("div[class^=UnsupportedMarketPage-module__buttons]");
$target = document.querySelector("div[class^=UnsupportedMarketPage-module__buttons]"); $target && HeaderSection.#injectSettingsButton($target);
$target && HeaderSection.#injectSettingsButton($target);
}
} }
static showRemotePlayButton() { static showRemotePlayButton() {
HeaderSection.#$remotePlayBtn.classList.remove("bx-gone"); HeaderSection.#$remotePlayBtn.classList.remove("bx-gone");
} }
static watchHeader() { static watchHeader() {
let $root = document.querySelector("#PageContent header") || document.querySelector("#root"); const $root = document.querySelector("#PageContent header") || document.querySelector("#root");
if (!$root) if (!$root)
return; return;
HeaderSection.#observer && HeaderSection.#observer.disconnect(), HeaderSection.#observer = new MutationObserver((mutationList) => { HeaderSection.#observer && HeaderSection.#observer.disconnect(), HeaderSection.#observer = new MutationObserver((mutationList) => {