From c89ebb78a4e63955e5b614848a7be2650625b698 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:43:14 +0700 Subject: [PATCH] Update dists --- dist/better-xcloud.lite.user.js | 28 +++++++++++-------- dist/better-xcloud.user.js | 49 ++++++++++++++++----------------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/dist/better-xcloud.lite.user.js b/dist/better-xcloud.lite.user.js index 43144ef..645e196 100644 --- a/dist/better-xcloud.lite.user.js +++ b/dist/better-xcloud.lite.user.js @@ -206,9 +206,12 @@ function createButton(options) { if (options.url) $btn = CE("a", { class: "bx-button" }), $btn.href = options.url, $btn.target = "_blank"; else $btn = CE("button", { class: "bx-button", type: "button" }); let style = options.style || 0; - style && ButtonStyleIndices.forEach((index) => { - style & index && $btn.classList.add(ButtonStyleClass[index]); - }), options.classes && $btn.classList.add(...options.classes), options.icon && $btn.appendChild(createSvgIcon(options.icon)), options.label && $btn.appendChild(CE("span", {}, options.label)), options.title && $btn.setAttribute("title", options.title), options.disabled && ($btn.disabled = !0), options.onClick && $btn.addEventListener("click", options.onClick), $btn.tabIndex = typeof options.tabIndex === "number" ? options.tabIndex : 0; + if (style) { + let index; + for (index of ButtonStyleIndices) + style & index && $btn.classList.add(ButtonStyleClass[index]); + } + options.classes && $btn.classList.add(...options.classes), options.icon && $btn.appendChild(createSvgIcon(options.icon)), options.label && $btn.appendChild(CE("span", {}, options.label)), options.title && $btn.setAttribute("title", options.title), options.disabled && ($btn.disabled = !0), options.onClick && $btn.addEventListener("click", options.onClick), $btn.tabIndex = typeof options.tabIndex === "number" ? options.tabIndex : 0; for (let key in options.attributes) if (!$btn.hasOwnProperty(key)) $btn.setAttribute(key, options.attributes[key]); return $btn; @@ -2871,7 +2874,8 @@ class NavigationDialogManager { }).observe(this.$container, { childList: !0 }); } calculateSelectBoxes($root) { - $root.querySelectorAll(".bx-select:not([data-calculated]) select").forEach(($select) => { + let selects = Array.from($root.querySelectorAll(".bx-select:not([data-calculated]) select")); + for (let $select of selects) { let $parent = $select.parentElement; if ($parent.classList.contains("bx-full-width")) { $parent.dataset.calculated = "true"; @@ -2882,7 +2886,7 @@ class NavigationDialogManager { if ($select.multiple) $label = $parent.querySelector(".bx-select-value"), width += 20; else $label = $parent.querySelector("div"); $label.style.minWidth = width + "px", $parent.dataset.calculated = "true"; - }); + } } handleEvent(event) { switch (event.type) { @@ -4958,13 +4962,14 @@ class StreamBadges { this.serverInfo.video ? this.badges.video.$element : ["video", "?"], this.serverInfo.audio ? this.badges.audio.$element : ["audio", "?"] ], $container = CE("div", { class: "bx-badges" }); - return BADGES.forEach((item) => { - if (!item) return; + for (let item of BADGES) { + if (!item) continue; let $badge; if (!(item instanceof HTMLElement)) $badge = this.renderBadge(...item); else $badge = item; $container.appendChild($badge); - }), this.$container = $container, await this.start(), $container; + } + return this.$container = $container, await this.start(), $container; } async getServerStats() { let stats = await STATES.currentStream.peerConnection.getStats(), allVideoCodecs = {}, videoCodecId, videoWidth = 0, videoHeight = 0, allAudioCodecs = {}, audioCodecId, allCandidates = {}, candidateId; @@ -5821,8 +5826,9 @@ class StreamUiHandler { let $screen = document.querySelector("#PageContent section[class*=PureScreens]"); if (!$screen) return; let observer = new MutationObserver((mutationList) => { - mutationList.forEach((item) => { - if (item.type !== "childList") return; + let item; + for (item of mutationList) { + if (item.type !== "childList") continue; item.addedNodes.forEach(async ($node) => { if (!$node || $node.nodeType !== Node.ELEMENT_NODE) return; let $elm = $node; @@ -5840,7 +5846,7 @@ class StreamUiHandler { if (!$elm || ($elm.id || "") !== "StreamHud") return; StreamUiHandler.handleSystemMenu($elm); }); - }); + } }); observer.observe($screen, { subtree: !0, childList: !0 }), StreamUiHandler.observer = observer; } diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index 3bb44dd..d36d17b 100644 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -208,9 +208,12 @@ function createButton(options) { if (options.url) $btn = CE("a", { class: "bx-button" }), $btn.href = options.url, $btn.target = "_blank"; else $btn = CE("button", { class: "bx-button", type: "button" }); let style = options.style || 0; - style && ButtonStyleIndices.forEach((index) => { - style & index && $btn.classList.add(ButtonStyleClass[index]); - }), options.classes && $btn.classList.add(...options.classes), options.icon && $btn.appendChild(createSvgIcon(options.icon)), options.label && $btn.appendChild(CE("span", {}, options.label)), options.title && $btn.setAttribute("title", options.title), options.disabled && ($btn.disabled = !0), options.onClick && $btn.addEventListener("click", options.onClick), $btn.tabIndex = typeof options.tabIndex === "number" ? options.tabIndex : 0; + if (style) { + let index; + for (index of ButtonStyleIndices) + style & index && $btn.classList.add(ButtonStyleClass[index]); + } + options.classes && $btn.classList.add(...options.classes), options.icon && $btn.appendChild(createSvgIcon(options.icon)), options.label && $btn.appendChild(CE("span", {}, options.label)), options.title && $btn.setAttribute("title", options.title), options.disabled && ($btn.disabled = !0), options.onClick && $btn.addEventListener("click", options.onClick), $btn.tabIndex = typeof options.tabIndex === "number" ? options.tabIndex : 0; for (let key in options.attributes) if (!$btn.hasOwnProperty(key)) $btn.setAttribute(key, options.attributes[key]); return $btn; @@ -3152,7 +3155,8 @@ class NavigationDialogManager { }).observe(this.$container, { childList: !0 }); } calculateSelectBoxes($root) { - $root.querySelectorAll(".bx-select:not([data-calculated]) select").forEach(($select) => { + let selects = Array.from($root.querySelectorAll(".bx-select:not([data-calculated]) select")); + for (let $select of selects) { let $parent = $select.parentElement; if ($parent.classList.contains("bx-full-width")) { $parent.dataset.calculated = "true"; @@ -3163,7 +3167,7 @@ class NavigationDialogManager { if ($select.multiple) $label = $parent.querySelector(".bx-select-value"), width += 20; else $label = $parent.querySelector("div"); $label.style.minWidth = width + "px", $parent.dataset.calculated = "true"; - }); + } } handleEvent(event) { switch (event.type) { @@ -4319,10 +4323,10 @@ true` + text; "native-mkb": "8fa264dd-124f-4af3-97e8-596fcdf4b486", "most-popular": "e7590b22-e299-44db-ae22-25c61405454c" }; - PREF_HIDE_SECTIONS.forEach((section) => { + for (let section of PREF_HIDE_SECTIONS) { let galleryId = sections[section]; galleryId && siglIds.push(galleryId); - }); + } let newCode = ` if (e && e.id) { const siglId = e.id; @@ -4383,11 +4387,6 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) { let index = str.indexOf('"ContextualCardActions-module__container'); if (index >= 0 && (index = str.indexOf('addEventListener("touchstart"', index)), index >= 0 && (index = PatcherUtils.lastIndexOf(str, "return ", index, 50)), index < 0) return !1; return str = PatcherUtils.replaceWith(str, index, "return", "return () => {};"), str; - }, - disableSendMetadata(str) { - let text = "this.sendMetadata(),this.isStreamActive()"; - if (!str.includes(text)) return !1; - return str = str.replaceAll(text, "true; return;" + text), str; } }, PATCH_ORDERS = [ ...getPref("native_mkb_enabled") === "on" ? [ @@ -4443,9 +4442,6 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) { "patchStreamHud", "playVibration", "alwaysShowStreamHud", - ...getPref("block_tracking") ? [ - "disableSendMetadata" - ] : [], getPref("audio_enable_volume_control") && !getPref("stream_combine_sources") && "patchAudioMediaStream", getPref("audio_enable_volume_control") && getPref("stream_combine_sources") && "patchCombinedAudioVideoMediaStream", getPref("stream_disable_feedback_dialog") && "skipFeedbackDialog", @@ -5546,12 +5542,12 @@ class ControllerShortcut { let gamepadIndex = gamepad.index, actions = ControllerShortcut.ACTIONS[gamepad.id]; if (!actions) return !1; ControllerShortcut.buttonsCache[gamepadIndex] = ControllerShortcut.buttonsStatus[gamepadIndex].slice(0), ControllerShortcut.buttonsStatus[gamepadIndex] = []; - let pressed = [], otherButtonPressed = !1; - return gamepad.buttons.forEach((button, index) => { + let pressed = [], otherButtonPressed = !1, entries = gamepad.buttons.entries(); + for (let [index, button] of entries) if (button.pressed && index !== 16) { if (otherButtonPressed = !0, pressed[index] = !0, actions[index] && !ControllerShortcut.buttonsCache[gamepadIndex][index]) setTimeout(() => ControllerShortcut.runAction(actions[index]), 0); } - }), ControllerShortcut.buttonsStatus[gamepadIndex] = pressed, otherButtonPressed; + return ControllerShortcut.buttonsStatus[gamepadIndex] = pressed, otherButtonPressed; } static runAction(action) { switch (action) { @@ -6543,13 +6539,14 @@ class StreamBadges { this.serverInfo.video ? this.badges.video.$element : ["video", "?"], this.serverInfo.audio ? this.badges.audio.$element : ["audio", "?"] ], $container = CE("div", { class: "bx-badges" }); - return BADGES.forEach((item2) => { - if (!item2) return; + for (let item2 of BADGES) { + if (!item2) continue; let $badge; if (!(item2 instanceof HTMLElement)) $badge = this.renderBadge(...item2); else $badge = item2; $container.appendChild($badge); - }), this.$container = $container, await this.start(), $container; + } + return this.$container = $container, await this.start(), $container; } async getServerStats() { let stats = await STATES.currentStream.peerConnection.getStats(), allVideoCodecs = {}, videoCodecId, videoWidth = 0, videoHeight = 0, allAudioCodecs = {}, audioCodecId, allCandidates = {}, candidateId; @@ -7553,7 +7550,8 @@ class GameBar { this.clearHideTimeout(), this.$container.classList.replace("bx-show", "bx-hide"); } reset() { - this.actions.forEach((action) => action.reset()); + for (let action of this.actions) + action.reset(); } } class XcloudApi { @@ -7771,8 +7769,9 @@ class StreamUiHandler { let $screen = document.querySelector("#PageContent section[class*=PureScreens]"); if (!$screen) return; let observer = new MutationObserver((mutationList) => { - mutationList.forEach((item2) => { - if (item2.type !== "childList") return; + let item2; + for (item2 of mutationList) { + if (item2.type !== "childList") continue; item2.addedNodes.forEach(async ($node) => { if (!$node || $node.nodeType !== Node.ELEMENT_NODE) return; let $elm = $node; @@ -7790,7 +7789,7 @@ class StreamUiHandler { if (!$elm || ($elm.id || "") !== "StreamHud") return; StreamUiHandler.handleSystemMenu($elm); }); - }); + } }); observer.observe($screen, { subtree: !0, childList: !0 }), StreamUiHandler.observer = observer; }