diff --git a/module/common/get_extra.sh b/module/common/get_extra.sh index baa9ade..fbf4035 100644 --- a/module/common/get_extra.sh +++ b/module/common/get_extra.sh @@ -56,7 +56,9 @@ check_update() { [ -f "$MODDIR/disable" ] && rm -f "$MODDIR/disable" LOCAL_VERSION=$(grep '^versionCode=' "$MODPATH/update/module.prop" | awk -F= '{print $2}') if [ "$REMOTE_VERSION" -gt "$LOCAL_VERSION" ] && [ ! -f "/data/adb/modules/TA_utl/update" ]; then - if [ "$MAGISK" = "true" ]; then + if [ "$CANARY" = "true" ]; then + exit 1 + elif [ "$MAGISK" = "true" ]; then [ -d "/data/adb/modules/TA_utl" ] && rm -rf "/data/adb/modules/TA_utl" cp -rf "$MODPATH/update" "/data/adb/modules/TA_utl" else diff --git a/module/webui/index.html b/module/webui/index.html index 0ce1836..32fd0f2 100644 --- a/module/webui/index.html +++ b/module/webui/index.html @@ -221,6 +221,10 @@ GitHub +

diff --git a/module/webui/locales/strings/en.xml b/module/webui/locales/strings/en.xml index 30a7831..a2b0675 100644 --- a/module/webui/locales/strings/en.xml +++ b/module/webui/locales/strings/en.xml @@ -63,6 +63,7 @@ Update Target List by Telegram Channel + Update to latest canary version This module is not a part of the Tricky Store module. DO NOT report any issues to Tricky Store if encountered. Acknowledgment @@ -78,7 +79,9 @@ Failed to save config WebUI will be removed after reboot Failed to uninstall WebUI + Checking udpate... A new update is available! + There are currently no updates available Downloading new update... Download completed Fail to download update diff --git a/module/webui/locales/strings/zh-CN.xml b/module/webui/locales/strings/zh-CN.xml index 6eb796a..cbbf879 100644 --- a/module/webui/locales/strings/zh-CN.xml +++ b/module/webui/locales/strings/zh-CN.xml @@ -63,6 +63,7 @@ 更新目标列表 作者: TG频道 + 下载最新测试版 此 WebUI 不是 Tricky Store 的一部分,遇到任何问题请勿向 Tricky Store 作者反馈。 特别鸣谢 @@ -78,7 +79,9 @@ 保存配置失败 WebUI 将在重启后被移除 卸载 WebUI 失败 + 正在检测更新... 发现新的版本! + 当前已是最新版本 正在下载... 下载完成 下载失败 diff --git a/module/webui/locales/strings/zh-TW.xml b/module/webui/locales/strings/zh-TW.xml index a597fa6..b162096 100644 --- a/module/webui/locales/strings/zh-TW.xml +++ b/module/webui/locales/strings/zh-TW.xml @@ -63,6 +63,7 @@ 更新目標列表 作者: Telegram 頻道 + 下載最新測試版 此 WebUI 並非 Tricky Store 的一部分,如遇任何問題請勿向 Tricky Store 作者反饋。 特別鳴謝 @@ -78,7 +79,9 @@ 保存配置失敗 WebUI 將在重啟後被移除 卸載 WebUI 失敗 + 正在檢測更新... 發現新版本! + 當前已是最新版本 正在下載... 下載完成 下載失敗 diff --git a/module/webui/locales/template.xml b/module/webui/locales/template.xml index 30a7831..a2b0675 100644 --- a/module/webui/locales/template.xml +++ b/module/webui/locales/template.xml @@ -63,6 +63,7 @@ Update Target List by Telegram Channel + Update to latest canary version This module is not a part of the Tricky Store module. DO NOT report any issues to Tricky Store if encountered. Acknowledgment @@ -78,7 +79,9 @@ Failed to save config WebUI will be removed after reboot Failed to uninstall WebUI + Checking udpate... A new update is available! + There are currently no updates available Downloading new update... Download completed Fail to download update diff --git a/module/webui/scripts/about.js b/module/webui/scripts/about.js index e56184a..32d503d 100644 --- a/module/webui/scripts/about.js +++ b/module/webui/scripts/about.js @@ -1,9 +1,13 @@ -import { linkRedirect } from './main.js'; +import { linkRedirect, basePath, showPrompt } from './main.js'; +import { translations } from './language.js'; +import { spawn, toast } from './assets/kernelsu.js'; const aboutOverlay = document.getElementById('about-overlay'); const aboutContent = document.querySelector('.about-menu'); const closeAbout = document.getElementById('close-about'); +let isDownloading = false; + // Function to show about overlay document.getElementById("about").addEventListener("click", () => { // Show about menu @@ -32,9 +36,86 @@ aboutOverlay.addEventListener('click', (event) => { }); // Event listener for link redirect -document.getElementById('telegram').addEventListener('click', function() { +document.getElementById('telegram').addEventListener('click', () => { linkRedirect('https://t.me/kowchannel'); }); -document.getElementById('github').addEventListener('click', function() { +document.getElementById('github').addEventListener('click', () => { linkRedirect('https://github.com/KOWX712/Tricky-Addon-Update-Target-List'); -}); \ No newline at end of file +}); + +// Update to latest canary verison +document.getElementById('canary').addEventListener('click', async () => { + if (isDownloading) return; + isDownloading = true; + try { + showPrompt("prompt_checking_update"); + 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) { + // Extract versionCode + const parts = zipURL.split("-"); + const version = parts.length >= 2 ? parts[parts.length - 2] : null; + + // Check local version + const output = spawn('sh', [`${basePath}/common/get_extra.sh`, '--check-update', `${version}`], { env: { CANARY: "true" } }); + 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."); + } + } catch (error) { + console.error("Error fetching ZIP link:", error); + isDownloading = false; + } +}); + +/** + * Funtion to download update + * @param {string} link - link of file to download + * @returns {void} + */ +function downloadUpdate(link) { + showPrompt("prompt_downloading", true, 10000); + 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) => { + if (code === 0) { + installUpdate(); + } else { + showPrompt("prompt_download_fail", false); + isDownloading = false; + } + }); +} + +/** + * Funtion to install update + * @returns {void} + */ +function installUpdate() { + showPrompt("prompt_installing"); + const output = spawn('sh', [`${basePath}/common/get_extra.sh`, '--install-update'], + { env: { PATH: "$PATH:/data/adb/ap/bin:/data/adb/ksu/bin:/data/adb/magisk" } }); + output.stderr.on('data', (data) => { + console.error('Error during installation:', data); + }); + output.on('exit', (code) => { + if (code === 0) { + showPrompt("prompt_installed"); + } else { + showPrompt("prompt_install_fail", false); + } + isDownloading = false; + }); +} diff --git a/module/webui/scripts/update.js b/module/webui/scripts/update.js index 7226425..ff366dd 100644 --- a/module/webui/scripts/update.js +++ b/module/webui/scripts/update.js @@ -164,7 +164,7 @@ function setupUpdateMenu() { { env: { PATH: "$PATH:/data/adb/ap/bin:/data/adb/ksu/bin:/data/adb/magisk" } }); output.stderr.on('data', (data) => { console.error('Error during installation:', data); - }) + }); output.on('exit', (code) => { if (code === 0) { showPrompt("prompt_installed"); diff --git a/module/webui/styles/about.css b/module/webui/styles/about.css index fe8517c..dd1546e 100644 --- a/module/webui/styles/about.css +++ b/module/webui/styles/about.css @@ -53,7 +53,13 @@ } .link-icon { - display: inline-block; + font-size: 18px; + padding: 3px 10px; + color: #fff; + fill: #fff; + user-select: none; + display: inline-flex; + align-items: center; font-style: normal; border-radius: 8px; box-sizing: border-box; @@ -62,27 +68,19 @@ } .link-icon svg { - padding-bottom: 3px; - vertical-align: bottom; - height: 17px; + padding-right: 3px; } #telegram { - font-size: 18px; - padding: 3px 10px; background-color: #38A7ED; - color: #fff; - fill: #fff; - user-select: none; } #github { - font-size: 18px; - padding: 3px 10px; background-color: #606060; - color: #fff; - fill: #fff; - user-select: none; +} + +#canary { + background-color: #821284; } #link-text {