diff --git a/dist/better-xcloud.pretty.user.js b/dist/better-xcloud.pretty.user.js index 6704cae..89e431a 100644 --- a/dist/better-xcloud.pretty.user.js +++ b/dist/better-xcloud.pretty.user.js @@ -2693,11 +2693,12 @@ function setPref(prefKey, value, origin) { } function checkForUpdate() { if (SCRIPT_VERSION.includes("beta")) return; + fetch("https://api.github.com/repos/redphx/better-xcloud/releases/latest").then((response) => response.json()).then((json) => { + setGlobalPref("version.latest", json.tag_name.substring(1), "direct"), setGlobalPref("version.current", SCRIPT_VERSION, "direct"); + }); let CHECK_INTERVAL_SECONDS = 7200, currentVersion = getGlobalPref("version.current"), lastCheck = getGlobalPref("version.lastCheck"), now = Math.round(+new Date / 1000); if (currentVersion === SCRIPT_VERSION && now - lastCheck < CHECK_INTERVAL_SECONDS) return; - setGlobalPref("version.lastCheck", now, "direct"), fetch("https://api.github.com/repos/redphx/better-xcloud/releases/latest").then((response) => response.json()).then((json) => { - setGlobalPref("version.latest", json.tag_name.substring(1), "direct"), setGlobalPref("version.current", SCRIPT_VERSION, "direct"); - }), Translations.updateTranslations(currentVersion === SCRIPT_VERSION); + setGlobalPref("version.lastCheck", now, "direct"), Translations.updateTranslations(currentVersion === SCRIPT_VERSION); } function disablePwa() { if (!(window.navigator.orgUserAgent || window.navigator.userAgent || "").toLowerCase()) return; diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index a45315f..f6ee64a 100755 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -95,7 +95,7 @@ function isGlobalPref(prefKey) {return ALL_PREFS.global.includes(prefKey);} function isStreamPref(prefKey) {return ALL_PREFS.stream.includes(prefKey);} function getPrefInfo(prefKey) {if (isGlobalPref(prefKey)) return {storage: STORAGE.Global,definition: getGlobalPrefDefinition(prefKey)};else if (isStreamPref(prefKey)) return {storage: STORAGE.Stream,definition: getStreamPrefDefinition(prefKey)};return alert("Missing pref definition: " + prefKey), {};} function setPref(prefKey, value, origin) {if (isGlobalPref(prefKey)) setGlobalPref(prefKey, value, origin);else if (isStreamPref(prefKey)) setStreamPref(prefKey, value, origin);} -function checkForUpdate() {if (SCRIPT_VERSION.includes("beta")) return;let CHECK_INTERVAL_SECONDS = 7200, currentVersion = getGlobalPref("version.current"), lastCheck = getGlobalPref("version.lastCheck"), now = Math.round(+new Date / 1000);if (currentVersion === SCRIPT_VERSION && now - lastCheck < CHECK_INTERVAL_SECONDS) return;setGlobalPref("version.lastCheck", now, "direct"), fetch("https://api.github.com/repos/redphx/better-xcloud/releases/latest").then((response) => response.json()).then((json) => {setGlobalPref("version.latest", json.tag_name.substring(1), "direct"), setGlobalPref("version.current", SCRIPT_VERSION, "direct");}), Translations.updateTranslations(currentVersion === SCRIPT_VERSION);} +function checkForUpdate() {if (SCRIPT_VERSION.includes("beta")) return;fetch("https://api.github.com/repos/redphx/better-xcloud/releases/latest").then((response) => response.json()).then((json) => {setGlobalPref("version.latest", json.tag_name.substring(1), "direct"), setGlobalPref("version.current", SCRIPT_VERSION, "direct");});let CHECK_INTERVAL_SECONDS = 7200, currentVersion = getGlobalPref("version.current"), lastCheck = getGlobalPref("version.lastCheck"), now = Math.round(+new Date / 1000);if (currentVersion === SCRIPT_VERSION && now - lastCheck < CHECK_INTERVAL_SECONDS) return;setGlobalPref("version.lastCheck", now, "direct"), Translations.updateTranslations(currentVersion === SCRIPT_VERSION);} function disablePwa() {if (!(window.navigator.orgUserAgent || window.navigator.userAgent || "").toLowerCase()) return;if (!!AppInterface || UserAgent.isSafariMobile()) Object.defineProperty(window.navigator, "standalone", {value: !0});} function hashCode(str) {let hash = 0;for (let i = 0, len = str.length;i < len; i++) {let chr = str.charCodeAt(i);hash = (hash << 5) - hash + chr, hash |= 0;}return hash;} function renderString(str, obj) {return str.replace(/\$\{([A-Za-z0-9_$]+)\}|\$([A-Za-z0-9_$]+)\$/g, (match, p1, p2) => {let name = p1 || p2;return name in obj ? obj[name] : match;});} diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 91dc5b0..6a354a1 100755 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -16,6 +16,15 @@ export function checkForUpdate() { return; } + // Always check for new version + fetch('https://api.github.com/repos/redphx/better-xcloud/releases/latest') + .then(response => response.json()) + .then(json => { + // Store the latest version + setGlobalPref(GlobalPref.VERSION_LATEST, json.tag_name.substring(1), 'direct'); + setGlobalPref(GlobalPref.VERSION_CURRENT, SCRIPT_VERSION, 'direct'); + }); + const CHECK_INTERVAL_SECONDS = 2 * 3600; // check every 2 hours const currentVersion = getGlobalPref(GlobalPref.VERSION_CURRENT); @@ -28,13 +37,6 @@ export function checkForUpdate() { // Start checking setGlobalPref(GlobalPref.VERSION_LAST_CHECK, now, 'direct'); - fetch('https://api.github.com/repos/redphx/better-xcloud/releases/latest') - .then(response => response.json()) - .then(json => { - // Store the latest version - setGlobalPref(GlobalPref.VERSION_LATEST, json.tag_name.substring(1), 'direct'); - setGlobalPref(GlobalPref.VERSION_CURRENT, SCRIPT_VERSION, 'direct'); - }); // Update translations Translations.updateTranslations(currentVersion === SCRIPT_VERSION);