mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-01 13:17:20 +02:00
Always check for new version
This commit is contained in:
parent
8bdad8b319
commit
8998daf14c
7
dist/better-xcloud.pretty.user.js
vendored
7
dist/better-xcloud.pretty.user.js
vendored
@ -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;
|
||||
|
2
dist/better-xcloud.user.js
vendored
2
dist/better-xcloud.user.js
vendored
@ -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;});}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user