Skip to content

Commit 64b2d2b

Browse files
committed
mxyx
1 parent 2f0c722 commit 64b2d2b

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/main/offsetStore.ts

+25-5
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ interface IOffsetsStore {
138138
}
139139

140140
//// "https://cdn.jsdelivr.net/gh/OhMyGuus/BetterCrewlink-Offsets@main/"; // "https://raw.githubusercontent.com/OhMyGuus/BetterCrewlink-Offsets/main"
141-
141+
/*
142142
const BASE_URL = "https://offsets.mxyx.club";
143143
const BASE_URL_error = "https://github.moeyy.xyz/https://raw.githubusercontent.com/OhMyGuus/BetterCrewlink-Offsets/main";
144144
@@ -159,6 +159,28 @@ async function fetchOffsetLookupJson(error: boolean = false): Promise<IOffsetsLo
159159
throw Errors.LOOKUP_FETCH_ERROR;
160160
}
161161
});
162+
}*/
163+
164+
//// "https://cdn.jsdelivr.net/gh/OhMyGuus/BetterCrewlink-Offsets@main/"; // "https://raw.githubusercontent.com/OhMyGuus/BetterCrewlink-Offsets/main"
165+
166+
const BASE_URL = "https://offsets.mxyx.club";
167+
const BASE_URL_error = "https://github.moeyy.xyz/https://raw.githubusercontent.com/OhMyGuus/BetterCrewlink-Offsets/main";
168+
169+
const store = new Store<IOffsetsStore>({name: "offsets"});
170+
const lookupStore = new Store<IOffsetsLookup>({name: "lookup"});
171+
172+
async function fetchOffsetLookupJson(error: boolean = false): Promise<IOffsetsLookup> {
173+
const url = error ? BASE_URL_error : BASE_URL;
174+
return fetch(`${url}/lookup.json`)
175+
.then((response) => response.json())
176+
.then((data) => { return data as IOffsetsLookup })
177+
.catch((_) => {
178+
if (!error) {
179+
return fetchOffsetLookupJson(true);
180+
} else {
181+
throw Errors.LOOKUP_FETCH_ERROR;
182+
}
183+
});
162184
}
163185

164186
export async function fetchOffsetLookup(): Promise<IOffsetsLookup> {
@@ -174,9 +196,7 @@ export async function fetchOffsetLookup(): Promise<IOffsetsLookup> {
174196
}
175197

176198
async function fetchOffsetsJson(is_64bit: boolean, filename: string, error: boolean = false): Promise<IOffsets> {
177-
const GetUrl = SettingsStore.get('CDN_Url', 'nullUrl');
178-
const CDN_Url = GetUrl == 'nullUrl' ? BASE_URL : GetUrl;
179-
const url = error ? BASE_URL_error : CDN_Url;
199+
const url = error ? BASE_URL_error : BASE_URL;
180200
const OFFSETS_URL = `${url}/offsets`;
181201
return fetch(`${OFFSETS_URL}/${is_64bit ? 'x64' : 'x86'}/${filename}`)
182202
.then((response) => response.json())
@@ -185,7 +205,7 @@ async function fetchOffsetsJson(is_64bit: boolean, filename: string, error: bool
185205
if (!error) {
186206
return fetchOffsetsJson(is_64bit, filename, true);
187207
} else {
188-
throw Errors.OFFSETS_FETCH_ERROR;
208+
throw Errors.OFFSETS_FETCH_ERROR;
189209
}
190210
});
191211
}

0 commit comments

Comments
 (0)