mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-03 06:07:19 +02:00
Fix web's version detection
This commit is contained in:
parent
a3094d2c9f
commit
b5ba6e9600
23
dist/better-xcloud.pretty.user.js
vendored
23
dist/better-xcloud.pretty.user.js
vendored
@ -402,6 +402,9 @@ var SUPPORTED_LANGUAGES = {
|
|||||||
"zh-CN": "中文(简体)",
|
"zh-CN": "中文(简体)",
|
||||||
"zh-TW": "中文(繁體)"
|
"zh-TW": "中文(繁體)"
|
||||||
}, Texts = {
|
}, Texts = {
|
||||||
|
"clarity-boost-mode": "Clarity boost mode",
|
||||||
|
performance: "Performance",
|
||||||
|
quality: "Quality",
|
||||||
achievements: "Achievements",
|
achievements: "Achievements",
|
||||||
activate: "Activate",
|
activate: "Activate",
|
||||||
activated: "Activated",
|
activated: "Activated",
|
||||||
@ -875,9 +878,7 @@ class Translations {
|
|||||||
localStorage.setItem(Translations.KEY_LOCALE, locale);
|
localStorage.setItem(Translations.KEY_LOCALE, locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var t = Translations.get, ut = (text) => {
|
var t = Translations.get;
|
||||||
return BxLogger.warning("Untranslated text", text), text;
|
|
||||||
};
|
|
||||||
Translations.init();
|
Translations.init();
|
||||||
class NavigationUtils {
|
class NavigationUtils {
|
||||||
static setNearby($elm, nearby) {
|
static setNearby($elm, nearby) {
|
||||||
@ -2399,11 +2400,11 @@ class StreamSettingsStorage extends BaseSettingsStorage {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"video.processing.mode": {
|
"video.processing.mode": {
|
||||||
label: ut("clarity-boost-mode"),
|
label: t("clarity-boost-mode"),
|
||||||
default: "performance",
|
default: "performance",
|
||||||
options: {
|
options: {
|
||||||
performance: ut("performance"),
|
performance: t("performance"),
|
||||||
quality: ut("quality")
|
quality: t("quality")
|
||||||
},
|
},
|
||||||
suggest: {
|
suggest: {
|
||||||
lowest: "performance",
|
lowest: "performance",
|
||||||
@ -5861,20 +5862,20 @@ class PatcherCache {
|
|||||||
PATCH_ORDERS = this.cleanupPatches(PATCH_ORDERS), STREAM_PAGE_PATCH_ORDERS = this.cleanupPatches(STREAM_PAGE_PATCH_ORDERS), PRODUCT_DETAIL_PAGE_PATCH_ORDERS = this.cleanupPatches(PRODUCT_DETAIL_PAGE_PATCH_ORDERS), BxLogger.info(LOG_TAG2, "PATCH_ORDERS", PATCH_ORDERS.slice(0));
|
PATCH_ORDERS = this.cleanupPatches(PATCH_ORDERS), STREAM_PAGE_PATCH_ORDERS = this.cleanupPatches(STREAM_PAGE_PATCH_ORDERS), PRODUCT_DETAIL_PAGE_PATCH_ORDERS = this.cleanupPatches(PRODUCT_DETAIL_PAGE_PATCH_ORDERS), BxLogger.info(LOG_TAG2, "PATCH_ORDERS", PATCH_ORDERS.slice(0));
|
||||||
}
|
}
|
||||||
getSignature() {
|
getSignature() {
|
||||||
let scriptVersion = SCRIPT_VERSION, patches = JSON.stringify(ALL_PATCHES), webVersion = "", $link = document.querySelector('link[data-chunk="client"][as="script"][href*="/client."]');
|
let scriptVersion = SCRIPT_VERSION, patches = JSON.stringify(ALL_PATCHES), clientHash = "", $link = document.querySelector('link[data-chunk="client"][as="script"][href*="/client."]');
|
||||||
if ($link) {
|
if ($link) {
|
||||||
let match = /\/client\.([^\.]+)\.js/.exec($link.href);
|
let match = /\/client\.([^\.]+)\.js/.exec($link.href);
|
||||||
match && (webVersion = match[1]);
|
match && (clientHash = match[1]);
|
||||||
}
|
}
|
||||||
if (!webVersion) webVersion = document.querySelector("meta[name=gamepass-app-version]")?.content ?? "";
|
let webVersion = document.querySelector("meta[name=gamepass-app-version]")?.content ?? "", webVersionDate = document.querySelector("meta[name=gamepass-app-date]")?.content ?? "";
|
||||||
return hashCode(scriptVersion + webVersion + patches);
|
return `${scriptVersion}:${clientHash}:${webVersion}:${webVersionDate}:${hashCode(patches)}`;
|
||||||
}
|
}
|
||||||
clear() {
|
clear() {
|
||||||
window.localStorage.removeItem(this.KEY_CACHE), this.CACHE = {};
|
window.localStorage.removeItem(this.KEY_CACHE), this.CACHE = {};
|
||||||
}
|
}
|
||||||
checkSignature() {
|
checkSignature() {
|
||||||
let storedSig = window.localStorage.getItem(this.KEY_SIGNATURE) || 0, currentSig = this.getSignature();
|
let storedSig = window.localStorage.getItem(this.KEY_SIGNATURE) || 0, currentSig = this.getSignature();
|
||||||
if (currentSig !== parseInt(storedSig)) BxLogger.warning(LOG_TAG2, "Signature changed"), window.localStorage.setItem(this.KEY_SIGNATURE, currentSig.toString()), this.clear();
|
if (currentSig !== storedSig) BxLogger.warning(LOG_TAG2, "Signature changed"), window.localStorage.setItem(this.KEY_SIGNATURE, currentSig.toString()), this.clear();
|
||||||
else BxLogger.info(LOG_TAG2, "Signature unchanged");
|
else BxLogger.info(LOG_TAG2, "Signature unchanged");
|
||||||
}
|
}
|
||||||
cleanupPatches(patches) {
|
cleanupPatches(patches) {
|
||||||
|
8
dist/better-xcloud.user.js
vendored
8
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -1565,26 +1565,25 @@ export class PatcherCache {
|
|||||||
/**
|
/**
|
||||||
* Get patch's signature
|
* Get patch's signature
|
||||||
*/
|
*/
|
||||||
private getSignature(): number {
|
private getSignature(): string {
|
||||||
const scriptVersion = SCRIPT_VERSION;
|
const scriptVersion = SCRIPT_VERSION;
|
||||||
const patches = JSON.stringify(ALL_PATCHES);
|
const patches = JSON.stringify(ALL_PATCHES);
|
||||||
|
|
||||||
// Get client.js's hash
|
// Get client.js's hash
|
||||||
let webVersion = '';
|
let clientHash = '';
|
||||||
const $link = document.querySelector<HTMLLinkElement>('link[data-chunk="client"][as="script"][href*="/client."]');
|
const $link = document.querySelector<HTMLLinkElement>('link[data-chunk="client"][as="script"][href*="/client."]');
|
||||||
if ($link) {
|
if ($link) {
|
||||||
const match = /\/client\.([^\.]+)\.js/.exec($link.href);
|
const match = /\/client\.([^\.]+)\.js/.exec($link.href);
|
||||||
match && (webVersion = match[1]);
|
match && (clientHash = match[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!webVersion) {
|
// Get version from <meta>
|
||||||
// Get version from <meta>
|
// Sometimes this value is missing
|
||||||
// Sometimes this value is missing
|
const webVersion = (document.querySelector<HTMLMetaElement>('meta[name=gamepass-app-version]'))?.content ?? '';
|
||||||
webVersion = (document.querySelector<HTMLMetaElement>('meta[name=gamepass-app-version]'))?.content ?? '';
|
const webVersionDate = (document.querySelector<HTMLMetaElement>('meta[name=gamepass-app-date]'))?.content ?? '';
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate signature
|
// Calculate signature
|
||||||
const sig = hashCode(scriptVersion + webVersion + patches)
|
const sig = `${scriptVersion}:${clientHash}:${webVersion}:${webVersionDate}:${hashCode(patches)}`;
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1598,7 +1597,7 @@ export class PatcherCache {
|
|||||||
const storedSig = window.localStorage.getItem(this.KEY_SIGNATURE) || 0;
|
const storedSig = window.localStorage.getItem(this.KEY_SIGNATURE) || 0;
|
||||||
const currentSig = this.getSignature();
|
const currentSig = this.getSignature();
|
||||||
|
|
||||||
if (currentSig !== parseInt(storedSig as string)) {
|
if (currentSig !== storedSig) {
|
||||||
// Save new signature
|
// Save new signature
|
||||||
BxLogger.warning(LOG_TAG, 'Signature changed');
|
BxLogger.warning(LOG_TAG, 'Signature changed');
|
||||||
window.localStorage.setItem(this.KEY_SIGNATURE, currentSig.toString());
|
window.localStorage.setItem(this.KEY_SIGNATURE, currentSig.toString());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user