mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-30 03:11:43 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
29ff1bc09c | |||
8998daf14c | |||
8bdad8b319 | |||
5dd3ebdea1 |
2
dist/better-xcloud.meta.js
vendored
2
dist/better-xcloud.meta.js
vendored
@ -1,5 +1,5 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 6.4.5
|
||||
// @version 6.4.6
|
||||
// ==/UserScript==
|
||||
|
26
dist/better-xcloud.pretty.user.js
vendored
26
dist/better-xcloud.pretty.user.js
vendored
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 6.4.5
|
||||
// @version 6.4.6
|
||||
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
||||
// @author redphx
|
||||
// @license MIT
|
||||
@ -192,7 +192,7 @@ class UserAgent {
|
||||
});
|
||||
}
|
||||
}
|
||||
var SCRIPT_VERSION = "6.4.5", SCRIPT_VARIANT = "full", AppInterface = window.AppInterface;
|
||||
var SCRIPT_VERSION = "6.4.6", SCRIPT_VARIANT = "full", AppInterface = window.AppInterface;
|
||||
UserAgent.init();
|
||||
var userAgent = window.navigator.userAgent.toLowerCase(), isTv = userAgent.includes("smart-tv") || userAgent.includes("smarttv") || /\baft.*\b/.test(userAgent), isVr = window.navigator.userAgent.includes("VR") && window.navigator.userAgent.includes("OculusBrowser"), browserHasTouchSupport = "ontouchstart" in window || navigator.maxTouchPoints > 0, userAgentHasTouchSupport = !isTv && !isVr && browserHasTouchSupport, STATES = {
|
||||
supportedRegion: !0,
|
||||
@ -382,6 +382,7 @@ class GhPagesUtils {
|
||||
var SUPPORTED_LANGUAGES = {
|
||||
"en-US": "English (US)",
|
||||
"ca-CA": "Català",
|
||||
"cs-CZ": "čeština",
|
||||
"da-DK": "dansk",
|
||||
"de-DE": "Deutsch",
|
||||
"en-ID": "Bahasa Indonesia",
|
||||
@ -571,6 +572,7 @@ var SUPPORTED_LANGUAGES = {
|
||||
"new-version-available": [
|
||||
e => `Version ${e.version} available`,
|
||||
e => `Versió ${e.version} disponible`,
|
||||
e => `Verze ${e.version} dostupná`,
|
||||
,
|
||||
e => `Version ${e.version} verfügbar`,
|
||||
e => `Versi ${e.version} tersedia`,
|
||||
@ -616,6 +618,7 @@ var SUPPORTED_LANGUAGES = {
|
||||
"press-key-to-toggle-mkb": [
|
||||
e => `Press ${e.key} to toggle this feature`,
|
||||
e => `Premeu ${e.key} per alternar aquesta funció`,
|
||||
e => `Zmáčknete ${e.key} pro přepnutí této funkce`,
|
||||
e => `Tryk på ${e.key} for at slå denne funktion til`,
|
||||
e => `${e.key}: Funktion an-/ausschalten`,
|
||||
e => `Tekan ${e.key} untuk mengaktifkan fitur ini`,
|
||||
@ -641,6 +644,7 @@ var SUPPORTED_LANGUAGES = {
|
||||
e => `Recommended settings for ${e.device}`,
|
||||
e => `Configuració recomanada per a ${e.device}`,
|
||||
,
|
||||
,
|
||||
e => `Empfohlene Einstellungen für ${e.device}`,
|
||||
e => `Rekomendasi pengaturan untuk ${e.device}`,
|
||||
e => `Ajustes recomendados para ${e.device}`,
|
||||
@ -751,6 +755,7 @@ var SUPPORTED_LANGUAGES = {
|
||||
"touch-control-layout-by": [
|
||||
e => `Touch control layout by ${e.name}`,
|
||||
e => `Format del control tàctil per ${e.name}`,
|
||||
e => `Rozložení dotykového ovládání ${e.name}`,
|
||||
e => `Touch-kontrol layout af ${e.name}`,
|
||||
e => `Touch-Steuerungslayout von ${e.name}`,
|
||||
e => `Tata letak Sentuhan layar oleh ${e.name}`,
|
||||
@ -2688,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;
|
||||
@ -8490,6 +8496,9 @@ class RemotePlayManager {
|
||||
Authorization: `Bearer ${this.XHOME_TOKEN}`
|
||||
}
|
||||
};
|
||||
this.regions.sort((a, b) => {
|
||||
return a.isDefault ? -1 : 0;
|
||||
});
|
||||
for (let region of this.regions)
|
||||
try {
|
||||
let request = new Request(`${region.baseUri}/v6/servers/home?mr=50`, options), json = await (await fetch(request)).json();
|
||||
@ -9071,8 +9080,11 @@ function updateIceCandidates(candidates, options) {
|
||||
let pattern = new RegExp(/a=candidate:(?<foundation>\d+) (?<component>\d+) UDP (?<priority>\d+) (?<ip>[^\s]+) (?<port>\d+) (?<the_rest>.*)/), lst = [];
|
||||
for (let item2 of candidates) {
|
||||
if (item2.candidate == "a=end-of-candidates") continue;
|
||||
let groups = pattern.exec(item2.candidate).groups;
|
||||
lst.push(groups);
|
||||
let match = pattern.exec(item2.candidate);
|
||||
if (match && match.groups) {
|
||||
let groups = match.groups;
|
||||
lst.push(groups);
|
||||
}
|
||||
}
|
||||
if (options.preferIpv6Server) lst.sort((a, b) => {
|
||||
let firstIp = a.ip, secondIp = b.ip;
|
||||
|
12
dist/better-xcloud.user.js
vendored
12
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -156,6 +156,11 @@ export class RemotePlayManager {
|
||||
},
|
||||
};
|
||||
|
||||
// Start with "isDefault" = true first
|
||||
this.regions.sort((a: RemotePlayRegion, b: RemotePlayRegion) => {
|
||||
return a.isDefault ? -1 : 0;
|
||||
})
|
||||
|
||||
// Test servers one by one
|
||||
for (const region of this.regions) {
|
||||
try {
|
||||
|
@ -49,8 +49,11 @@ function updateIceCandidates(candidates: any, options: { preferIpv6Server: boole
|
||||
continue;
|
||||
}
|
||||
|
||||
const groups: { [index: string]: string | number } = pattern.exec(item.candidate)!.groups!;
|
||||
lst.push(groups);
|
||||
const match = pattern.exec(item.candidate);
|
||||
if (match && match.groups) {
|
||||
const groups: { [index: string]: string | number } = match.groups;
|
||||
lst.push(groups);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.preferIpv6Server) {
|
||||
|
@ -7,6 +7,7 @@ export const SUPPORTED_LANGUAGES = {
|
||||
'en-US': 'English (US)',
|
||||
|
||||
'ca-CA': 'Català',
|
||||
'cs-CZ': 'čeština',
|
||||
'da-DK': 'dansk',
|
||||
'de-DE': 'Deutsch',
|
||||
'en-ID': 'Bahasa Indonesia',
|
||||
@ -198,6 +199,7 @@ const Texts = {
|
||||
"new-version-available": [
|
||||
(e: any) => `Version ${e.version} available`,
|
||||
(e: any) => `Versió ${e.version} disponible`,
|
||||
(e: any) => `Verze ${e.version} dostupná`,
|
||||
,
|
||||
(e: any) => `Version ${e.version} verfügbar`,
|
||||
(e: any) => `Versi ${e.version} tersedia`,
|
||||
@ -243,6 +245,7 @@ const Texts = {
|
||||
"press-key-to-toggle-mkb": [
|
||||
(e: any) => `Press ${e.key} to toggle this feature`,
|
||||
(e: any) => `Premeu ${e.key} per alternar aquesta funció`,
|
||||
(e: any) => `Zmáčknete ${e.key} pro přepnutí této funkce`,
|
||||
(e: any) => `Tryk på ${e.key} for at slå denne funktion til`,
|
||||
(e: any) => `${e.key}: Funktion an-/ausschalten`,
|
||||
(e: any) => `Tekan ${e.key} untuk mengaktifkan fitur ini`,
|
||||
@ -268,6 +271,7 @@ const Texts = {
|
||||
(e: any) => `Recommended settings for ${e.device}`,
|
||||
(e: any) => `Configuració recomanada per a ${e.device}`,
|
||||
,
|
||||
,
|
||||
(e: any) => `Empfohlene Einstellungen für ${e.device}`,
|
||||
(e: any) => `Rekomendasi pengaturan untuk ${e.device}`,
|
||||
(e: any) => `Ajustes recomendados para ${e.device}`,
|
||||
@ -378,6 +382,7 @@ const Texts = {
|
||||
"touch-control-layout-by": [
|
||||
(e: any) => `Touch control layout by ${e.name}`,
|
||||
(e: any) => `Format del control tàctil per ${e.name}`,
|
||||
(e: any) => `Rozložení dotykového ovládání ${e.name}`,
|
||||
(e: any) => `Touch-kontrol layout af ${e.name}`,
|
||||
(e: any) => `Touch-Steuerungslayout von ${e.name}`,
|
||||
(e: any) => `Tata letak Sentuhan layar oleh ${e.name}`,
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user