You've already forked Tricky-Addon-Update-Target-List
mirror of
https://github.com/KOWX712/Tricky-Addon-Update-Target-List.git
synced 2025-09-06 06:37:09 +00:00
feat: add mirror link fallback
- mostly mean for China user, possible to use all feature except module update
This commit is contained in:
@@ -42,11 +42,16 @@ document.getElementById("deselect-unnecessary").addEventListener("click", async
|
||||
try {
|
||||
const excludeList = await fetch("https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/main/more-exclude.json")
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
return response.json();
|
||||
})
|
||||
.catch(async () => {
|
||||
return fetch("https://raw.gitmirror.com/KOWX712/Tricky-Addon-Update-Target-List/main/more-exclude.json")
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
return response.json();
|
||||
});
|
||||
})
|
||||
.then(data => {
|
||||
return data.data
|
||||
.flatMap(category => category.apps)
|
||||
@@ -205,35 +210,40 @@ document.getElementById("aospkb").addEventListener("click", async () => {
|
||||
// Function to replace valid kb
|
||||
document.getElementById("validkb").addEventListener("click", async () => {
|
||||
fetch("https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/main/.extra")
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then(async data => {
|
||||
if (!data.trim()) {
|
||||
await aospkb();
|
||||
showPrompt("prompt.no_valid_fallback", false);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const hexBytes = new Uint8Array(data.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
||||
const decodedHex = new TextDecoder().decode(hexBytes);
|
||||
const source = atob(decodedHex);
|
||||
const result = await setKeybox(source);
|
||||
if (result) {
|
||||
showPrompt("prompt.valid_key_set");
|
||||
} else {
|
||||
throw new Error("Failed to copy valid keybox");
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
return response.text();
|
||||
})
|
||||
.catch(async () => {
|
||||
return fetch("https://raw.gitmirror.com/KOWX712/Tricky-Addon-Update-Target-List/main/.extra")
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
return response.text();
|
||||
});
|
||||
})
|
||||
.then(async data => {
|
||||
if (!data.trim()) {
|
||||
await aospkb();
|
||||
showPrompt("prompt.no_valid_fallback", false);
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error("Failed to decode keybox data");
|
||||
}
|
||||
})
|
||||
.catch(async error => {
|
||||
showPrompt("prompt.no_internet", false);
|
||||
});
|
||||
try {
|
||||
const hexBytes = new Uint8Array(data.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
||||
const decodedHex = new TextDecoder().decode(hexBytes);
|
||||
const source = atob(decodedHex);
|
||||
const result = await setKeybox(source);
|
||||
if (result) {
|
||||
showPrompt("prompt.valid_key_set");
|
||||
} else {
|
||||
throw new Error("Failed to copy valid keybox");
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error("Failed to decode keybox data");
|
||||
}
|
||||
})
|
||||
.catch(async error => {
|
||||
showPrompt("prompt.no_internet", false);
|
||||
});
|
||||
});
|
||||
|
||||
// File selector
|
||||
|
||||
@@ -41,10 +41,11 @@ function downloadFile(targetURL, fileName) {
|
||||
// Function to check for updates
|
||||
export async function updateCheck() {
|
||||
try {
|
||||
const response = await fetch("https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/main/update.json");
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const response = await fetch("https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/main/update.json")
|
||||
.catch(async () => {
|
||||
return fetch("https://raw.gitmirror.com/KOWX712/Tricky-Addon-Update-Target-List/main/update.json");
|
||||
});
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
noConnection.style.display = "none";
|
||||
const data = await response.json();
|
||||
remoteVersionCode = data.versionCode;
|
||||
|
||||
Reference in New Issue
Block a user