Update better-xcloud.user.js

This commit is contained in:
redphx 2024-07-15 17:12:22 +07:00
parent 368a6f726a
commit 66120d6970

View File

@ -141,6 +141,7 @@ var userAgent = window.navigator.userAgent.toLowerCase(), isTv = userAgent.inclu
serverRegions: {}, serverRegions: {},
selectedRegion: {}, selectedRegion: {},
gsToken: "", gsToken: "",
isSignedIn: !1,
isPlaying: !1, isPlaying: !1,
appContext: {}, appContext: {},
browser: { browser: {
@ -693,9 +694,14 @@ class SettingElement {
const $control = CE("select", { const $control = CE("select", {
tabindex: 0 tabindex: 0
}); });
let $parent;
if (setting.optionsGroup)
$parent = CE("optgroup", { label: setting.optionsGroup }), $control.appendChild($parent);
else
$parent = $control;
for (let value in setting.options) { for (let value in setting.options) {
const label = setting.options[value], $option = CE("option", { value }, label); const label = setting.options[value], $option = CE("option", { value }, label);
$control.appendChild($option); $parent.appendChild($option);
} }
return $control.value = currentValue, onChange && $control.addEventListener("input", (e) => { return $control.value = currentValue, onChange && $control.addEventListener("input", (e) => {
const target = e.target, value = setting.type && setting.type === "number" ? parseInt(target.value) : target.value; const target = e.target, value = setting.type && setting.type === "number" ? parseInt(target.value) : target.value;
@ -1110,8 +1116,9 @@ class Preferences {
}, },
[PrefKey.SERVER_BYPASS_RESTRICTION]: { [PrefKey.SERVER_BYPASS_RESTRICTION]: {
label: t("bypass-region-restriction"), label: t("bypass-region-restriction"),
note: t("use-this-at-your-own-risk"), note: "⚠️ " + t("use-this-at-your-own-risk"),
default: "off", default: "off",
optionsGroup: t("region"),
options: Object.assign({ options: Object.assign({
off: t("off") off: t("off")
}, BypassServers) }, BypassServers)
@ -5022,7 +5029,7 @@ function setupSettingsUi() {
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE | ButtonStyle.FULL_WIDTH, style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE | ButtonStyle.FULL_WIDTH,
url: "https://github.com/redphx/better-xcloud/releases/latest" url: "https://github.com/redphx/better-xcloud/releases/latest"
})); }));
if (topButtons.push(createButton({ if (STATES.supportedRegion && STATES.isSignedIn && topButtons.push(createButton({
label: t("stream-settings"), label: t("stream-settings"),
icon: BxIcon.STREAM_SETTINGS, icon: BxIcon.STREAM_SETTINGS,
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE, style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
@ -5059,6 +5066,8 @@ function setupSettingsUi() {
} }
}; };
for (let groupLabel in SETTINGS_UI) { for (let groupLabel in SETTINGS_UI) {
if (groupLabel !== "Better xCloud" && (!STATES.supportedRegion || !STATES.isSignedIn))
continue;
const $group = CE("span", { class: "bx-settings-group-label" }, groupLabel); const $group = CE("span", { class: "bx-settings-group-label" }, groupLabel);
if (SETTINGS_UI[groupLabel].note) { if (SETTINGS_UI[groupLabel].note) {
const $note = CE("b", {}, SETTINGS_UI[groupLabel].note); const $note = CE("b", {}, SETTINGS_UI[groupLabel].note);
@ -7451,7 +7460,7 @@ var unload = function() {
TouchController.setup(); TouchController.setup();
if (getPref(PrefKey.MKB_ENABLED) && AppInterface) if (getPref(PrefKey.MKB_ENABLED) && AppInterface)
STATES.pointerServerPort = AppInterface.startPointerServer() || 9269, BxLogger.info("startPointerServer", "Port", STATES.pointerServerPort.toString()); STATES.pointerServerPort = AppInterface.startPointerServer() || 9269, BxLogger.info("startPointerServer", "Port", STATES.pointerServerPort.toString());
getPref(PrefKey.REMOTE_PLAY_ENABLED) && BX_FLAGS.PreloadRemotePlay && RemotePlay.preload(), getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup(); getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup();
}; };
if (window.location.pathname.includes("/auth/msa")) { if (window.location.pathname.includes("/auth/msa")) {
const nativePushState = window.history.pushState; const nativePushState = window.history.pushState;
@ -7490,13 +7499,18 @@ window.addEventListener("load", (e) => {
window.stop(), window.location.reload(!0); window.stop(), window.location.reload(!0);
}, 3000); }, 3000);
}); });
if (getPref(PrefKey.UI_HIDE_SECTIONS).includes(UiSection.FRIENDS)) document.addEventListener("readystatechange", (e) => {
document.addEventListener("readystatechange", (e) => { if (document.readyState !== "interactive")
if (document.readyState === "interactive") { return;
const $parent = document.querySelector("div[class*=PlayWithFriendsSkeleton]")?.closest("div[class*=HomePage-module]"); if (STATES.isSignedIn = window.xbcUser.isSignedIn, STATES.isSignedIn)
$parent && ($parent.style.display = "none"); getPref(PrefKey.REMOTE_PLAY_ENABLED) && BX_FLAGS.PreloadRemotePlay && RemotePlay.preload();
} else
}); HeaderSection.watchHeader();
if (getPref(PrefKey.UI_HIDE_SECTIONS).includes(UiSection.FRIENDS)) {
const $parent = document.querySelector("div[class*=PlayWithFriendsSkeleton]")?.closest("div[class*=HomePage-module]");
$parent && ($parent.style.display = "none");
}
});
window.BX_EXPOSED = BxExposed; window.BX_EXPOSED = BxExposed;
window.addEventListener(BxEvent.POPSTATE, onHistoryChanged); window.addEventListener(BxEvent.POPSTATE, onHistoryChanged);
window.addEventListener("popstate", onHistoryChanged); window.addEventListener("popstate", onHistoryChanged);