From f78bd31b5812a02d8b782cdbf50e565e710f9771 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 15 Jul 2023 12:27:03 +0700 Subject: [PATCH] Fix video not showing then the "Skip splash video" setting is off --- better-xcloud.user.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/better-xcloud.user.js b/better-xcloud.user.js index efe7af7..7f3beb3 100644 --- a/better-xcloud.user.js +++ b/better-xcloud.user.js @@ -778,14 +778,17 @@ function watchHeader() { function patchVideoApi() { const PREF_SKIP_SPLASH_VIDEO = PREFS.get(Preferences.SKIP_SPLASH_VIDEO); - // Do nothing if the "Skip splash video" setting is off - if (!PREF_SKIP_SPLASH_VIDEO) { - return; + + // Show video player when it's ready + var showFunc; + showFunc = function() { + this.style.visibility = 'visible'; + this.removeEventListener('playing', showFunc); } HTMLMediaElement.prototype.orgPlay = HTMLMediaElement.prototype.play; HTMLMediaElement.prototype.play = function() { - if (this.className.startsWith('XboxSplashVideo')) { + if (PREF_SKIP_SPLASH_VIDEO && this.className.startsWith('XboxSplashVideo')) { this.volume = 0; this.style.display = 'none'; this.dispatchEvent(new Event('ended')); @@ -795,14 +798,8 @@ function patchVideoApi() { }; } - // Show video player when it's ready - let showFunc; - showFunc = function() { - this.style.visibility = 'visible'; - this.removeEventListener('playing', showFunc); - } + this.addEventListener('playing', showFunc); - return this.orgPlay.apply(this); }; }