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
opt: faster way to download canary link
download nightly html from shell seems to be faster
This commit is contained in:
@@ -225,6 +225,11 @@ KEYBOX_EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
--download)
|
||||||
|
shift
|
||||||
|
download $@
|
||||||
|
exit
|
||||||
|
;;
|
||||||
--xposed)
|
--xposed)
|
||||||
get_xposed
|
get_xposed
|
||||||
exit
|
exit
|
||||||
|
|||||||
@@ -44,40 +44,47 @@ document.getElementById('github').addEventListener('click', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Update to latest canary verison
|
// Update to latest canary verison
|
||||||
document.getElementById('canary').addEventListener('click', async () => {
|
document.getElementById('canary').addEventListener('click', () => {
|
||||||
if (isDownloading) return;
|
if (isDownloading) return;
|
||||||
isDownloading = true;
|
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();
|
|
||||||
const parser = new DOMParser();
|
|
||||||
const doc = parser.parseFromString(html, "text/html");
|
|
||||||
const zipURL = doc.querySelector('a[href$=".zip"]')?.href;
|
|
||||||
|
|
||||||
if (zipURL) {
|
showPrompt("prompt_checking_update", true, 10000);
|
||||||
// Extract versionCode
|
let htmlContent = '';
|
||||||
const parts = zipURL.split("-");
|
const link = "https://nightly.link/KOWX712/Tricky-Addon-Update-Target-List/workflows/build/main?preview"
|
||||||
const version = parts.length >= 2 ? parts[parts.length - 2] : null;
|
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(htmlContent, "text/html");
|
||||||
|
const zipURL = doc.querySelector('a[href$=".zip"]')?.href;
|
||||||
|
|
||||||
// Check local version
|
if (zipURL) {
|
||||||
const output = spawn('sh', [`${basePath}/common/get_extra.sh`, '--check-update', `${version}`], { env: { CANARY: "true" } });
|
// Extract versionCode
|
||||||
output.on('exit', (code) => {
|
const parts = zipURL.split("-");
|
||||||
if (code === 0) {
|
const version = parts.length >= 2 ? parts[parts.length - 2] : null;
|
||||||
showPrompt("prompt_no_update");
|
|
||||||
isDownloading = false;
|
// Check local version
|
||||||
} else if (code === 1) {
|
const output = spawn('sh', [`${basePath}/common/get_extra.sh`, '--check-update', `${version}`], { env: { CANARY: "true" } });
|
||||||
downloadUpdate(zipURL);
|
output.on('exit', (code) => {
|
||||||
}
|
if (code === 0) {
|
||||||
});
|
showPrompt("prompt_no_update");
|
||||||
|
isDownloading = false;
|
||||||
|
} else if (code === 1) {
|
||||||
|
downloadUpdate(zipURL);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error("No link found.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("No link found.");
|
console.error("Error fetching ZIP link");
|
||||||
|
isDownloading = false;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
});
|
||||||
console.error("Error fetching ZIP link:", error);
|
|
||||||
isDownloading = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +93,7 @@ document.getElementById('canary').addEventListener('click', async () => {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function downloadUpdate(link) {
|
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}`],
|
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" } });
|
{ 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) => {
|
download.on('exit', (code) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user