opt: faster way to download canary link

download nightly html from shell seems to be faster
This commit is contained in:
KOWX712
2025-06-19 12:24:53 +08:00
parent bff0e1f0d5
commit 8d53dde8a1
2 changed files with 41 additions and 29 deletions

View File

@@ -225,6 +225,11 @@ KEYBOX_EOF
}
case "$1" in
--download)
shift
download $@
exit
;;
--xposed)
get_xposed
exit

View File

@@ -44,16 +44,22 @@ document.getElementById('github').addEventListener('click', () => {
});
// Update to latest canary verison
document.getElementById('canary').addEventListener('click', async () => {
document.getElementById('canary').addEventListener('click', () => {
if (isDownloading) return;
isDownloading = true;
try {
showPrompt("prompt_checking_update", true, 10000);
const url = "https://api.allorigins.win/raw?url=" + encodeURIComponent("https://nightly.link/KOWX712/Tricky-Addon-Update-Target-List/workflows/build/main?preview");
const response = await fetch(url);
const html = await response.text();
let htmlContent = '';
const link = "https://nightly.link/KOWX712/Tricky-Addon-Update-Target-List/workflows/build/main?preview"
const output = spawn('sh', [`${basePath}/common/get_extra.sh`, '--download', `${link}`],
{ env: { PATH: "$PATH:/data/adb/ap/bin:/data/adb/ksu/bin:/data/adb/magisk" } });
output.stdout.on('data', (data) => {
htmlContent += data;
});
output.on('exit', async (code) => {
if (code === 0) {
const parser = new DOMParser();
const doc = parser.parseFromString(html, "text/html");
const doc = parser.parseFromString(htmlContent, "text/html");
const zipURL = doc.querySelector('a[href$=".zip"]')?.href;
if (zipURL) {
@@ -74,10 +80,11 @@ document.getElementById('canary').addEventListener('click', async () => {
} else {
console.error("No link found.");
}
} catch (error) {
console.error("Error fetching ZIP link:", error);
} else {
console.error("Error fetching ZIP link");
isDownloading = false;
}
});
});
/**
@@ -86,7 +93,7 @@ document.getElementById('canary').addEventListener('click', async () => {
* @returns {void}
*/
function downloadUpdate(link) {
showPrompt("prompt_downloading", true, 10000);
showPrompt("prompt_downloading", true, 20000);
const download = spawn('sh', [`${basePath}/common/get_extra.sh`, '--get-update', `${link}`],
{ env: { PATH: "$PATH:/data/adb/ap/bin:/data/adb/ksu/bin:/data/adb/magisk:/data/data/com.termux/files/usr/bin" } });
download.on('exit', (code) => {