feat: option to update to latest canary version

about - Update to latest canary version
This commit is contained in:
KOWX712
2025-06-05 14:53:45 +08:00
parent 97bd0083c1
commit 1acb97d1b6
9 changed files with 117 additions and 20 deletions

View File

@@ -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

View File

@@ -221,6 +221,10 @@
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 496 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
<span id="link-text">GitHub</span>
</i>
<i class="link-icon ripple-element" id="canary" aria-hidden="true">
<svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px"><path d="M200-120q-51 0-72.5-45.5T138-250l222-270v-240h-40q-17 0-28.5-11.5T280-800q0-17 11.5-28.5T320-840h320q17 0 28.5 11.5T680-800q0 17-11.5 28.5T640-760h-40v240l222 270q32 39 10.5 84.5T760-120H200Zm0-80h560L520-492v-268h-80v268L200-200Zm280-280Z"/></svg>
<span id="link-text" data-i18n="about_canary_update"></span>
</i>
</div>
<div class="acknowledgment">
<p id="acknowledgment" data-i18n="about_acknowledgment"></p>

View File

@@ -63,6 +63,7 @@
<string name="about_module_name_line2">Update Target List</string>
<string name="about_by">by</string>
<string name="about_telegram_channel">Telegram Channel</string>
<string name="about_canary_update">Update to latest canary version</string>
<string name="about_disclaimer">This module is not a part of the Tricky Store module. DO NOT report any issues to Tricky Store if encountered.</string>
<string name="about_acknowledgment">Acknowledgment</string>
<!-- Prompt -->
@@ -78,7 +79,9 @@
<string name="prompt_save_error">Failed to save config</string>
<string name="prompt_uninstall_prompt">WebUI will be removed after reboot</string>
<string name="prompt_uninstall_failed">Failed to uninstall WebUI</string>
<string name="prompt_checking_update">Checking udpate...</string>
<string name="prompt_new_update">A new update is available!</string>
<string name="prompt_no_update">There are currently no updates available</string>
<string name="prompt_downloading">Downloading new update...</string>
<string name="prompt_downloaded">Download completed</string>
<string name="prompt_download_fail">Fail to download update</string>

View File

@@ -63,6 +63,7 @@
<string name="about_module_name_line2">更新目标列表</string>
<string name="about_by">作者:</string>
<string name="about_telegram_channel">TG频道</string>
<string name="about_canary_update">下载最新测试版</string>
<string name="about_disclaimer">此 WebUI 不是 Tricky Store 的一部分,遇到任何问题请勿向 Tricky Store 作者反馈。</string>
<string name="about_acknowledgment">特别鸣谢</string>
<!-- Prompt -->
@@ -78,7 +79,9 @@
<string name="prompt_save_error">保存配置失败</string>
<string name="prompt_uninstall_prompt">WebUI 将在重启后被移除</string>
<string name="prompt_uninstall_failed">卸载 WebUI 失败</string>
<string name="prompt_checking_update">正在检测更新...</string>
<string name="prompt_new_update">发现新的版本!</string>
<string name="prompt_no_update">当前已是最新版本</string>
<string name="prompt_downloading">正在下载...</string>
<string name="prompt_downloaded">下载完成</string>
<string name="prompt_download_fail">下载失败</string>

View File

@@ -63,6 +63,7 @@
<string name="about_module_name_line2">更新目標列表</string>
<string name="about_by">作者:</string>
<string name="about_telegram_channel">Telegram 頻道</string>
<string name="about_canary_update">下載最新測試版</string>
<string name="about_disclaimer">此 WebUI 並非 Tricky Store 的一部分,如遇任何問題請勿向 Tricky Store 作者反饋。</string>
<string name="about_acknowledgment">特別鳴謝</string>
<!-- Prompt -->
@@ -78,7 +79,9 @@
<string name="prompt_save_error">保存配置失敗</string>
<string name="prompt_uninstall_prompt">WebUI 將在重啟後被移除</string>
<string name="prompt_uninstall_failed">卸載 WebUI 失敗</string>
<string name="prompt_checking_update">正在檢測更新...</string>
<string name="prompt_new_update">發現新版本!</string>
<string name="prompt_no_update">當前已是最新版本</string>
<string name="prompt_downloading">正在下載...</string>
<string name="prompt_downloaded">下載完成</string>
<string name="prompt_download_fail">下載失敗</string>

View File

@@ -63,6 +63,7 @@
<string name="about_module_name_line2">Update Target List</string>
<string name="about_by">by</string>
<string name="about_telegram_channel">Telegram Channel</string>
<string name="about_canary_update">Update to latest canary version</string>
<string name="about_disclaimer">This module is not a part of the Tricky Store module. DO NOT report any issues to Tricky Store if encountered.</string>
<string name="about_acknowledgment">Acknowledgment</string>
<!-- Prompt -->
@@ -78,7 +79,9 @@
<string name="prompt_save_error">Failed to save config</string>
<string name="prompt_uninstall_prompt">WebUI will be removed after reboot</string>
<string name="prompt_uninstall_failed">Failed to uninstall WebUI</string>
<string name="prompt_checking_update">Checking udpate...</string>
<string name="prompt_new_update">A new update is available!</string>
<string name="prompt_no_update">There are currently no updates available</string>
<string name="prompt_downloading">Downloading new update...</string>
<string name="prompt_downloaded">Download completed</string>
<string name="prompt_download_fail">Fail to download update</string>

View File

@@ -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');
});
});
// 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;
});
}

View File

@@ -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");

View File

@@ -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 {