|
|
|
@ -4,11 +4,40 @@ import type { GlosSISettings } from './@types/GlosSISettings';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SteamTargetApi {
|
|
|
|
|
public getGlosSIActive() {
|
|
|
|
|
return fetchWithTimeout('http://localhost:8756/', { timeout: 500 })
|
|
|
|
|
|
|
|
|
|
public static GlosSIActive = true;
|
|
|
|
|
|
|
|
|
|
public static readonly ACTIVE_FAIL_THRESHOLD = 2;
|
|
|
|
|
private activeFailCounter = 0;
|
|
|
|
|
private static ActiveCheckTimer = 0;
|
|
|
|
|
|
|
|
|
|
public constructor() {
|
|
|
|
|
if (SteamTargetApi.ActiveCheckTimer !== 0) {
|
|
|
|
|
clearInterval(SteamTargetApi.ActiveCheckTimer);
|
|
|
|
|
}
|
|
|
|
|
SteamTargetApi.ActiveCheckTimer = setInterval(() => {
|
|
|
|
|
void this.getGlosSIActive().then((active) => {
|
|
|
|
|
if (!active) {
|
|
|
|
|
this.activeFailCounter++;
|
|
|
|
|
if (this.activeFailCounter >= SteamTargetApi.ACTIVE_FAIL_THRESHOLD) {
|
|
|
|
|
window?.GlosSITweaks?.GlosSI?.uninstall?.();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, 666);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async getGlosSIActive() {
|
|
|
|
|
return fetchWithTimeout('http://localhost:8756/running', { timeout: 500 })
|
|
|
|
|
.then(
|
|
|
|
|
() => true
|
|
|
|
|
).catch(() => false);
|
|
|
|
|
() => {
|
|
|
|
|
SteamTargetApi.GlosSIActive = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
).catch(() => {
|
|
|
|
|
SteamTargetApi.GlosSIActive = false;
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
public getSteamSettings(): Promise<SteamConfig> {
|
|
|
|
|
return fetch('http://localhost:8756/steam_settings')
|
|
|
|
@ -33,6 +62,7 @@ class SteamTargetApi {
|
|
|
|
|
|
|
|
|
|
class GlosSIApiCtor {
|
|
|
|
|
public readonly SteamTarget: SteamTargetApi = new SteamTargetApi();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface GlosSITweaks {
|
|
|
|
@ -51,7 +81,6 @@ declare global {
|
|
|
|
|
const GlosSITweaks: GlosSITweaks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const installGlosSIApi = () => {
|
|
|
|
|
window.GlosSITweaks = {
|
|
|
|
|
GlosSI: {
|
|
|
|
|