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
Restructure index.js, simplify translation process
No big change
This commit is contained in:
@@ -47,11 +47,28 @@ check_update() {
|
||||
REMOTE_VERSION=$(echo "$JSON" | grep -o '"versionCode": *[0-9]*' | awk -F: '{print $2}' | tr -d ' ')
|
||||
LOCAL_VERSION=$(grep -o 'versionCode=[0-9]*' "$MODPATH/update/module.prop" | awk -F= '{print $2}')
|
||||
if [ "$REMOTE_VERSION" -gt "$LOCAL_VERSION" ]; then
|
||||
echo "update"
|
||||
if [ "$MODPATH" = "/data/adb/modules/.TA_utl/common" ]; then
|
||||
[ -d "/data/adb/modules/TA_utl" ] && rm -rf "/data/adb/modules/TA_utl"
|
||||
cp -rf "$MODPATH/update" "/data/adb/modules/TA_utl"
|
||||
else
|
||||
cp -f "$MODPATH/update/module.prop" "/data/adb/modules/TA_utl/module.prop"
|
||||
fi
|
||||
echo "update"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
if [ "$MODPATH" = "/data/adb/modules/.TA_utl/common" ]; then
|
||||
[ -d "/data/adb/modules/TA_utl" ] && rm -rf "/data/adb/modules/TA_utl"
|
||||
cp -rf "$MODPATH/update" "/data/adb/modules/TA_utl"
|
||||
else
|
||||
cp -f "$MODPATH/update/module.prop" "/data/adb/modules/TA_utl/module.prop"
|
||||
fi
|
||||
touch "/data/adb/modules/TA_utl/remove"
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
--kb)
|
||||
get_kb
|
||||
@@ -69,4 +86,8 @@ case "$1" in
|
||||
check_update
|
||||
exit
|
||||
;;
|
||||
--uninstall)
|
||||
uninstall
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -16,10 +16,7 @@ initialize() {
|
||||
fi
|
||||
|
||||
#Set specific path
|
||||
sed -i "s|\"set-path\"|\"/data/adb/modules/$NEW_MODID/\"|" "$MODPATH/webui/index.js" || {
|
||||
ui_print "! Failed to set path"
|
||||
abort
|
||||
}
|
||||
sed -i "s|\"set-path\"|\"/data/adb/modules/$NEW_MODID/\"|" "$MODPATH/webui/js/main.js" || abort "! Failed to set path"
|
||||
|
||||
# Set aapt binary
|
||||
cp "$MODPATH/module.prop" "$COMPATH/update/module.prop"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||
<link rel="stylesheet" href="styles.css" type="text/css">
|
||||
<link rel="stylesheet" type="text/css" href="/mmrl/insets.css" />
|
||||
<script type="module" crossorigin src="index.js"></script>
|
||||
<script type="module" crossorigin src="js/main.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -27,15 +27,7 @@
|
||||
<button class="language-button">
|
||||
<i class="material-icons">language</i>
|
||||
</button>
|
||||
<div class="language-menu">
|
||||
<button class="language-option" data-lang="en-US">English</button>
|
||||
<button class="language-option" data-lang="es-ES">Español</button>
|
||||
<button class="language-option" data-lang="ja-JP">日本語</button>
|
||||
<button class="language-option" data-lang="ru-RU">Русский</button>
|
||||
<button class="language-option" data-lang="tl-PH">Tagalog</button>
|
||||
<button class="language-option" data-lang="zh-CN">中文(简体)</button>
|
||||
<button class="language-option" data-lang="zh-TW">中文(繁体)</button>
|
||||
</div>
|
||||
<div class="language-menu"></div>
|
||||
<div id="language-overlay" class="language-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -63,7 +55,9 @@
|
||||
<div class="menu">
|
||||
<input type="checkbox" id="menu-toggle" class="menu-toggle">
|
||||
<label for="menu-toggle" id="menu-button">
|
||||
<span class="menu-icon"><i class="fa fa-bars"></i></span>
|
||||
<i class="menu-icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -1060 960 960" width="24px"><path d="M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z"/></svg>
|
||||
</i>
|
||||
</label>
|
||||
<div id="menu-options" class="menu-options">
|
||||
<ul>
|
||||
@@ -182,8 +176,14 @@
|
||||
<br>
|
||||
<p>
|
||||
<div class="link">
|
||||
<i class="fa fa-telegram" id="telegram" aria-hidden="true"> <span id="link-text" data-i18n="about.telegram_channel"></span></i>
|
||||
<i class="fa fa-github" id="github" aria-hidden="true"> <span id="link-text" data-i18n="about.github"></span></i>
|
||||
<i class="link-icon" id="telegram" aria-hidden="true">
|
||||
<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="M248 8C111 8 0 119 0 256S111 504 248 504 496 393 496 256 385 8 248 8zM363 176.7c-3.7 39.2-19.9 134.4-28.1 178.3-3.5 18.6-10.3 24.8-16.9 25.4-14.4 1.3-25.3-9.5-39.3-18.7-21.8-14.3-34.2-23.2-55.3-37.2-24.5-16.1-8.6-25 5.3-39.5 3.7-3.8 67.1-61.5 68.3-66.7 .2-.7 .3-3.1-1.2-4.4s-3.6-.8-5.1-.5q-3.3 .7-104.6 69.1-14.8 10.2-26.9 9.9c-8.9-.2-25.9-5-38.6-9.1-15.5-5-27.9-7.7-26.8-16.3q.8-6.7 18.5-13.7 108.4-47.2 144.6-62.3c68.9-28.6 83.2-33.6 92.5-33.8 2.1 0 6.6 .5 9.6 2.9a10.5 10.5 0 0 1 3.5 6.7A43.8 43.8 0 0 1 363 176.7z"/></svg>
|
||||
<span id="link-text" data-i18n="about.telegram_channel"></span>
|
||||
</i>
|
||||
<i class="link-icon" id="github" aria-hidden="true">
|
||||
<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" data-i18n="about.github"></span>
|
||||
</i>
|
||||
</div>
|
||||
</p>
|
||||
<br>
|
||||
|
||||
@@ -1,818 +0,0 @@
|
||||
// Header Elements
|
||||
const headerBlock = document.querySelector('.header-block');
|
||||
const title = document.querySelector('.header');
|
||||
const helpButton = document.getElementById('help-button');
|
||||
const noConnection = document.querySelector('.no-connection');
|
||||
const languageButton = document.querySelector('.language-button');
|
||||
const languageMenu = document.querySelector('.language-menu');
|
||||
const languageOptions = document.querySelectorAll('.language-option');
|
||||
const languageOverlay = document.getElementById('language-overlay');
|
||||
|
||||
// Help Overlay Elements
|
||||
const helpOverlay = document.getElementById('help-overlay');
|
||||
const closeHelp = document.getElementById('close-help');
|
||||
const helpList = document.getElementById('help-list');
|
||||
|
||||
// Search and Menu Elements
|
||||
const searchInput = document.getElementById('search');
|
||||
const clearBtn = document.getElementById('clear-btn');
|
||||
const searchMenuContainer = document.querySelector('.search-menu-container');
|
||||
const searchCard = document.querySelector('.search-card');
|
||||
const menu = document.querySelector('.menu');
|
||||
const menuButton = document.getElementById('menu-button');
|
||||
const menuOptions = document.getElementById('menu-options');
|
||||
const selectDenylistElement = document.getElementById('select-denylist');
|
||||
const menuOverlay = document.getElementById('menu-overlay');
|
||||
const menuIcon = menuButton.querySelector('.menu-icon');
|
||||
|
||||
// BootHash Overlay Elements
|
||||
const bootHashOverlay = document.getElementById('boot-hash-overlay');
|
||||
const card = document.getElementById('boot-hash-card');
|
||||
const inputBox = document.getElementById('boot-hash-input');
|
||||
const saveButton = document.getElementById('boot-hash-save-button');
|
||||
|
||||
// Applist Elements
|
||||
const appTemplate = document.getElementById('app-template').content;
|
||||
const appListContainer = document.getElementById('apps-list');
|
||||
const updateCard = document.getElementById('update-card');
|
||||
|
||||
// Loading, Save and Prompt Elements
|
||||
const loadingIndicator = document.querySelector('.loading');
|
||||
const floatingBtn = document.querySelector('.floating-btn');
|
||||
const prompt = document.getElementById('prompt');
|
||||
|
||||
// About Elements
|
||||
const telegramLink = document.getElementById('telegram');
|
||||
const githubLink = document.getElementById('github');
|
||||
|
||||
const basePath = "set-path";
|
||||
const ADDITIONAL_APPS = [
|
||||
"com.google.android.gms",
|
||||
"io.github.vvb2060.keyattestation",
|
||||
"io.github.vvb2060.mahoshojo",
|
||||
"icu.nullptr.nativetest"
|
||||
];
|
||||
|
||||
// Variables
|
||||
let e = 0;
|
||||
let excludeList = [];
|
||||
let isRefreshing = false;
|
||||
let translations = {};
|
||||
let currentLang = 'en-US';
|
||||
let availableLanguages = ['en-US'];
|
||||
|
||||
// Function to check for available language
|
||||
async function initializeAvailableLanguages() {
|
||||
try {
|
||||
const multiLang = await execCommand(`find ${basePath}webui/locales -type f -name "*.json" ! -name "A-template.json" -exec basename -s .json {} \\;`);
|
||||
availableLanguages = multiLang.trim().split('\n');
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch available languages:', error);
|
||||
availableLanguages = ['en-US'];
|
||||
}
|
||||
}
|
||||
|
||||
// Function to detect user's default language
|
||||
function detectUserLanguage() {
|
||||
const userLang = navigator.language || navigator.userLanguage;
|
||||
const langCode = userLang.split('-')[0];
|
||||
if (availableLanguages.includes(userLang)) {
|
||||
return userLang;
|
||||
} else if (availableLanguages.includes(langCode)) {
|
||||
return langCode;
|
||||
} else {
|
||||
return 'en-US';
|
||||
}
|
||||
}
|
||||
|
||||
// Load translations dynamically based on the selected language
|
||||
async function loadTranslations(lang) {
|
||||
try {
|
||||
const response = await fetch(`/locales/${lang}.json`);
|
||||
translations = await response.json();
|
||||
applyTranslations();
|
||||
} catch (error) {
|
||||
console.error(`Error loading translations for ${lang}:`, error);
|
||||
if (lang !== 'en-US') {
|
||||
console.log("Falling back to English.");
|
||||
loadTranslations('en-US');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to apply translations to all elements with data-i18n attributes
|
||||
function applyTranslations() {
|
||||
document.querySelectorAll("[data-i18n]").forEach((el) => {
|
||||
const keyString = el.getAttribute("data-i18n");
|
||||
const translation = keyString.split('.').reduce((acc, key) => acc && acc[key], translations);
|
||||
if (translation) {
|
||||
if (el.hasAttribute("placeholder")) {
|
||||
el.setAttribute("placeholder", translation);
|
||||
} else {
|
||||
el.textContent = translation;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Language selection event listener
|
||||
document.querySelectorAll(".language-option").forEach((button) => {
|
||||
button.addEventListener("click", (e) => {
|
||||
const lang = e.target.getAttribute("data-lang");
|
||||
loadTranslations(lang);
|
||||
});
|
||||
});
|
||||
|
||||
// Function to setup the language menu
|
||||
function setupLanguageMenu() {
|
||||
languageButton.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
const isVisible = languageMenu.classList.contains("show");
|
||||
if (isVisible) {
|
||||
closeLanguageMenu();
|
||||
} else {
|
||||
openLanguageMenu();
|
||||
}
|
||||
});
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!languageButton.contains(event.target) && !languageMenu.contains(event.target)) {
|
||||
closeLanguageMenu();
|
||||
}
|
||||
});
|
||||
languageOptions.forEach(option => {
|
||||
option.addEventListener("click", () => {
|
||||
closeLanguageMenu();
|
||||
});
|
||||
});
|
||||
window.addEventListener('scroll', () => {
|
||||
if (languageMenu.classList.contains("show")) {
|
||||
closeLanguageMenu();
|
||||
}
|
||||
});
|
||||
function openLanguageMenu() {
|
||||
languageMenu.classList.add("show");
|
||||
languageOverlay.style.display = 'flex';
|
||||
}
|
||||
function closeLanguageMenu() {
|
||||
languageMenu.classList.remove("show");
|
||||
languageOverlay.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Focus on search input when search card is clicked
|
||||
searchCard.addEventListener("click", () => {
|
||||
searchInput.focus();
|
||||
});
|
||||
|
||||
// Search functionality
|
||||
searchInput.addEventListener("input", (e) => {
|
||||
const searchQuery = e.target.value.toLowerCase();
|
||||
const apps = appListContainer.querySelectorAll(".card");
|
||||
apps.forEach(app => {
|
||||
const name = app.querySelector(".name").textContent.toLowerCase();
|
||||
app.style.display = name.includes(searchQuery) ? "block" : "none";
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
if (searchQuery !== "") {
|
||||
clearBtn.style.display = "block";
|
||||
} else {
|
||||
clearBtn.style.display = "none";
|
||||
}
|
||||
});
|
||||
|
||||
// Clear search input
|
||||
clearBtn.addEventListener("click", () => {
|
||||
searchInput.value = "";
|
||||
clearBtn.style.display = "none";
|
||||
window.scrollTo(0, 0);
|
||||
const apps = appListContainer.querySelectorAll(".card");
|
||||
apps.forEach(app => {
|
||||
app.style.display = "block";
|
||||
});
|
||||
});
|
||||
|
||||
// Function to setup the help menu
|
||||
function setupHelpOverlay() {
|
||||
helpButton.addEventListener("click", () => {
|
||||
helpOverlay.classList.remove("hide");
|
||||
helpOverlay.style.display = "flex";
|
||||
requestAnimationFrame(() => {
|
||||
helpOverlay.classList.add("show");
|
||||
});
|
||||
document.body.classList.add("no-scroll");
|
||||
});
|
||||
const hideHelpOverlay = () => {
|
||||
helpOverlay.classList.remove("show");
|
||||
helpOverlay.classList.add("hide");
|
||||
document.body.classList.remove("no-scroll");
|
||||
setTimeout(() => {
|
||||
helpOverlay.style.display = "none";
|
||||
}, 200);
|
||||
};
|
||||
closeHelp.addEventListener("click", hideHelpOverlay);
|
||||
helpOverlay.addEventListener("click", (event) => {
|
||||
if (event.target === helpOverlay) {
|
||||
hideHelpOverlay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to toggle menu option
|
||||
function setupMenuToggle() {
|
||||
let menuOpen = false;
|
||||
let menuAnimating = false;
|
||||
menuButton.addEventListener('click', (event) => {
|
||||
if (menuAnimating) return;
|
||||
event.stopPropagation();
|
||||
if (menuOptions.classList.contains('visible')) {
|
||||
closeMenu();
|
||||
} else {
|
||||
openMenu();
|
||||
}
|
||||
});
|
||||
document.addEventListener('click', (event) => {
|
||||
if (!menuOptions.contains(event.target) && event.target !== menuButton) {
|
||||
closeMenu();
|
||||
}
|
||||
});
|
||||
window.addEventListener('scroll', () => {
|
||||
if (menuOptions.classList.contains('visible')) {
|
||||
closeMenu();
|
||||
}
|
||||
});
|
||||
const menuOptionsList = document.querySelectorAll('#menu-options li');
|
||||
menuOptionsList.forEach(option => {
|
||||
option.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
closeMenu();
|
||||
});
|
||||
});
|
||||
function openMenu() {
|
||||
menuAnimating = true;
|
||||
menuOptions.style.display = 'block';
|
||||
setTimeout(() => {
|
||||
menuOptions.classList.remove('hidden');
|
||||
menuOptions.classList.add('visible');
|
||||
menuIcon.classList.add('menu-open');
|
||||
menuIcon.classList.remove('menu-closed');
|
||||
menuOverlay.style.display = 'flex';
|
||||
menuOpen = true;
|
||||
menuAnimating = false;
|
||||
}, 10);
|
||||
}
|
||||
function closeMenu() {
|
||||
if (menuOptions.classList.contains('visible')) {
|
||||
menuAnimating = true;
|
||||
menuOptions.classList.remove('visible');
|
||||
menuOptions.classList.add('hidden');
|
||||
menuIcon.classList.remove('menu-open');
|
||||
menuIcon.classList.add('menu-closed');
|
||||
menuOverlay.style.display = 'none';
|
||||
setTimeout(() => {
|
||||
menuOptions.style.display = 'none';
|
||||
menuOpen = false;
|
||||
menuAnimating = false;
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to refresh app list
|
||||
async function refreshAppList() {
|
||||
isRefreshing = true;
|
||||
title.style.transform = 'translateY(0)';
|
||||
searchMenuContainer.style.transform = 'translateY(0)';
|
||||
floatingBtn.style.transform = 'translateY(0)';
|
||||
searchInput.value = '';
|
||||
clearBtn.style.display = "none";
|
||||
appListContainer.innerHTML = '';
|
||||
loadingIndicator.style.display = 'flex';
|
||||
document.querySelector('.uninstall-container').classList.add('hidden-uninstall');
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
window.scrollTo(0, 0);
|
||||
if (noConnection.style.display === "flex") {
|
||||
try {
|
||||
await updateCheck();
|
||||
await execCommand(`[ -f ${basePath}common/tmp/exclude-list ] && rm -f "${basePath}common/tmp/exclude-list"`);
|
||||
} catch (error) {
|
||||
console.error("Error occurred:", error);
|
||||
}
|
||||
}
|
||||
await fetchAppList();
|
||||
loadingIndicator.style.display = 'none';
|
||||
document.querySelector('.uninstall-container').classList.remove('hidden-uninstall');
|
||||
isRefreshing = false;
|
||||
}
|
||||
|
||||
// Function to select all visible apps
|
||||
function selectAllApps() {
|
||||
document.querySelectorAll(".card").forEach(card => {
|
||||
if (card.style.display !== "none") {
|
||||
card.querySelector(".checkbox").checked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to deselect all visible apps
|
||||
function deselectAllApps() {
|
||||
document.querySelectorAll(".card").forEach(card => {
|
||||
if (card.style.display !== "none") {
|
||||
card.querySelector(".checkbox").checked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to run the update check
|
||||
async function updateCheck() {
|
||||
try {
|
||||
const scriptPath = `sh ${basePath}common/get_extra.sh --update`;
|
||||
const output = await execCommand(scriptPath);
|
||||
console.log("update script executed successfully.");
|
||||
noConnection.style.display = "none";
|
||||
if (output.includes("update")) {
|
||||
console.log("Update detected from extra script.");
|
||||
showPrompt("prompt.new_update");
|
||||
updateCard.style.display = "flex";
|
||||
await execCommand(`
|
||||
su -c "
|
||||
if [ -f '${basePath}action.sh' ]; then
|
||||
if [ -d "/data/adb/modules/TA_utl" ]; then
|
||||
rm -rf "/data/adb/modules/TA_utl"
|
||||
fi
|
||||
cp -rf '${basePath}common/update' '/data/adb/modules/TA_utl'
|
||||
else
|
||||
cp '${basePath}common/update/module.prop' '/data/adb/modules/TA_utl/module.prop'
|
||||
fi
|
||||
"
|
||||
`);
|
||||
} else {
|
||||
console.log("No update detected from extra script.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to execute update script:", error);
|
||||
showPrompt("prompt.no_internet", false);
|
||||
noConnection.style.display = "flex";
|
||||
}
|
||||
}
|
||||
|
||||
// Function to read the exclude list and uncheck corresponding apps
|
||||
async function deselectUnnecessaryApps() {
|
||||
try {
|
||||
const fileCheck = await execCommand(`test -f ${basePath}common/tmp/exclude-list && echo "exists" || echo "not found"`);
|
||||
if (fileCheck.trim() === "not found") {
|
||||
setTimeout(async () => {
|
||||
await execCommand(`sh ${basePath}common/get_extra.sh --unnecessary`);
|
||||
}, 0);
|
||||
console.log("Exclude list not found. Running the unnecessary apps script.");
|
||||
} else {
|
||||
setTimeout(async () => {
|
||||
await execCommand(`sh ${basePath}common/get_extra.sh --xposed`);
|
||||
}, 0);
|
||||
console.log("Exclude list found. Running xposed script.");
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
const result = await execCommand(`cat ${basePath}common/tmp/exclude-list`);
|
||||
const UnnecessaryApps = result.split("\n").map(app => app.trim()).filter(Boolean);
|
||||
const apps = document.querySelectorAll(".card");
|
||||
apps.forEach(app => {
|
||||
const contentElement = app.querySelector(".content");
|
||||
const packageName = contentElement.getAttribute("data-package");
|
||||
const checkbox = app.querySelector(".checkbox");
|
||||
if (UnnecessaryApps.includes(packageName)) {
|
||||
checkbox.checked = false;
|
||||
}
|
||||
});
|
||||
console.log("Unnecessary apps deselected successfully.");
|
||||
} catch (error) {
|
||||
console.error("Failed to deselect unnecessary apps:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to check if Magisk
|
||||
async function checkMagisk() {
|
||||
try {
|
||||
const magiskEnv = await execCommand(`command -v magisk >/dev/null 2>&1 && echo "OK"`);
|
||||
if (magiskEnv.trim() === "OK") {
|
||||
console.log("Denylist conditions met, displaying element.");
|
||||
selectDenylistElement.style.display = "flex";
|
||||
} else {
|
||||
console.log("ksud or apd detected, leaving denylist element hidden.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error while checking denylist conditions:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to read the denylist and check corresponding apps
|
||||
async function selectDenylistApps() {
|
||||
try {
|
||||
const result = await execCommand(`
|
||||
magisk --denylist ls 2>/dev/null | \
|
||||
awk -F'|' '{print $1}' | \
|
||||
grep -v "isolated" | \
|
||||
sort | uniq
|
||||
`);
|
||||
const denylistApps = result.split("\n").map(app => app.trim()).filter(Boolean);
|
||||
const apps = document.querySelectorAll(".card");
|
||||
await deselectAllApps();
|
||||
apps.forEach(app => {
|
||||
const contentElement = app.querySelector(".content");
|
||||
const packageName = contentElement.getAttribute("data-package");
|
||||
const checkbox = app.querySelector(".checkbox");
|
||||
if (denylistApps.includes(packageName)) {
|
||||
checkbox.checked = true; // Select the app if found in denylist
|
||||
}
|
||||
});
|
||||
console.log("Denylist apps selected successfully.");
|
||||
} catch (error) {
|
||||
console.error("Failed to select Denylist apps:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to replace aosp kb
|
||||
async function aospkb() {
|
||||
try {
|
||||
const sourcePath = `${basePath}common/.default`;
|
||||
const destinationPath = "/data/adb/tricky_store/keybox.xml";
|
||||
await execCommand(`xxd -r -p ${sourcePath} | base64 -d > ${destinationPath}`);
|
||||
console.log("AOSP keybox copied successfully.");
|
||||
showPrompt("prompt.aosp_key_set");
|
||||
} catch (error) {
|
||||
console.error("Failed to copy AOSP keybox:", error);
|
||||
showPrompt("prompt.key_set_error", false);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to replace valid kb
|
||||
async function extrakb() {
|
||||
setTimeout(async () => {
|
||||
await execCommand(`sh ${basePath}common/get_extra.sh --kb`);
|
||||
}, 100);
|
||||
const sourcePath = `${basePath}common/tmp/.extra`;
|
||||
const destinationPath = "/data/adb/tricky_store/keybox.xml";
|
||||
try {
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
const fileExists = await execCommand(`[ -f ${sourcePath} ] && echo "exists"`);
|
||||
if (fileExists.trim() !== "exists") {
|
||||
throw new Error(".extra file not found");
|
||||
}
|
||||
await execCommand(`xxd -r -p ${sourcePath} | base64 -d > ${destinationPath}`);
|
||||
console.log("Valid keybox copied successfully.");
|
||||
showPrompt("prompt.valid_key_set");
|
||||
} catch (error) {
|
||||
console.error("Failed to copy valid keybox:", error);
|
||||
await aospkb();
|
||||
showPrompt("prompt.no_valid_fallback", false);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to handle Verified Boot Hash
|
||||
async function setBootHash() {
|
||||
const showCard = () => {
|
||||
bootHashOverlay.style.display = "flex";
|
||||
card.style.display = "flex";
|
||||
requestAnimationFrame(() => {
|
||||
bootHashOverlay.classList.add("show");
|
||||
card.classList.add("show");
|
||||
});
|
||||
document.body.style.overflow = "hidden";
|
||||
};
|
||||
const closeCard = () => {
|
||||
bootHashOverlay.classList.remove("show");
|
||||
card.classList.remove("show");
|
||||
setTimeout(() => {
|
||||
bootHashOverlay.style.display = "none";
|
||||
card.style.display = "none";
|
||||
document.body.style.overflow = "auto";
|
||||
}, 200);
|
||||
};
|
||||
showCard();
|
||||
try {
|
||||
const bootHashContent = await execCommand("cat /data/adb/boot_hash");
|
||||
const validHash = bootHashContent
|
||||
.split("\n")
|
||||
.filter(line => !line.startsWith("#") && line.trim())[0];
|
||||
inputBox.value = validHash || "";
|
||||
} catch (error) {
|
||||
console.warn("Failed to read boot_hash file. Defaulting to empty input.");
|
||||
inputBox.value = "";
|
||||
}
|
||||
saveButton.addEventListener("click", async () => {
|
||||
const inputValue = inputBox.value.trim();
|
||||
try {
|
||||
await execCommand(`echo "${inputValue}" > /data/adb/boot_hash`);
|
||||
await execCommand(`su -c resetprop -n ro.boot.vbmeta.digest ${inputValue}`);
|
||||
showPrompt("prompt.boot_hash_set");
|
||||
closeCard();
|
||||
} catch (error) {
|
||||
console.error("Failed to update boot_hash:", error);
|
||||
showPrompt("prompt.boot_hash_set_error", false);
|
||||
}
|
||||
});
|
||||
bootHashOverlay.addEventListener("click", (event) => {
|
||||
if (event.target === bootHashOverlay) closeCard();
|
||||
});
|
||||
}
|
||||
|
||||
// Function to show about overlay
|
||||
function aboutMenu() {
|
||||
const aboutOverlay = document.getElementById('about-overlay');
|
||||
const aboutMenu = document.getElementById('about-menu');
|
||||
const closeAbout = document.getElementById('close-about');
|
||||
const showMenu = () => {
|
||||
aboutOverlay.style.display = 'flex';
|
||||
setTimeout(() => {
|
||||
aboutOverlay.style.opacity = '1';
|
||||
aboutMenu.style.opacity = '1';
|
||||
}, 10);
|
||||
document.body.style.overflow = 'hidden';
|
||||
};
|
||||
const hideMenu = () => {
|
||||
aboutOverlay.style.opacity = '0';
|
||||
aboutMenu.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
aboutOverlay.style.display = 'none';
|
||||
document.body.style.overflow = 'auto';
|
||||
}, 200);
|
||||
};
|
||||
showMenu();
|
||||
closeAbout.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
hideMenu();
|
||||
});
|
||||
aboutOverlay.addEventListener('click', (event) => {
|
||||
if (!aboutMenu.contains(event.target)) {
|
||||
hideMenu();
|
||||
}
|
||||
});
|
||||
menu.addEventListener('click', (event) => event.stopPropagation());
|
||||
}
|
||||
|
||||
// Fetch and render applist
|
||||
async function fetchAppList() {
|
||||
try {
|
||||
let targetList = [];
|
||||
try {
|
||||
const targetFileContent = await execCommand('cat /data/adb/tricky_store/target.txt');
|
||||
targetList = targetFileContent.split("\n").filter(app => app.trim() !== ''); // Filter out empty lines
|
||||
console.log("Current target list:", targetList);
|
||||
} catch (error) {
|
||||
console.error("Failed to read target.txt file:", error);
|
||||
}
|
||||
|
||||
let applistMap = {};
|
||||
try {
|
||||
const applistResult = await execCommand(`cat ${basePath}common/tmp/applist`);
|
||||
applistMap = applistResult
|
||||
.split("\n")
|
||||
.reduce((map, line) => {
|
||||
const match = line.match(/app-name:\s*(.+),\s*package-name:\s*(.+)/);
|
||||
if (match) {
|
||||
const appName = match[1].trim();
|
||||
const packageName = match[2].trim();
|
||||
map[packageName] = appName;
|
||||
}
|
||||
return map;
|
||||
}, {});
|
||||
console.log("Applist loaded successfully.");
|
||||
} catch (error) {
|
||||
console.warn("Applist file not found or could not be loaded. Skipping applist lookup.");
|
||||
}
|
||||
|
||||
const result = await execCommand("pm list packages -3");
|
||||
const appEntries = result
|
||||
.split("\n")
|
||||
.map(line => {
|
||||
const packageName = line.replace("package:", "").trim();
|
||||
const appName = applistMap[packageName] || null;
|
||||
return { appName, packageName };
|
||||
})
|
||||
.filter(entry => entry.packageName);
|
||||
for (const entry of appEntries) {
|
||||
if (!entry.appName) {
|
||||
try {
|
||||
const apkPath = await execCommand(`pm path ${entry.packageName} | grep "base.apk" | awk -F: '{print $2}' | tr -d '\\r'`);
|
||||
if (apkPath) {
|
||||
const appName = await execCommand(`${basePath}common/aapt dump badging ${apkPath.trim()} 2>/dev/null | grep "application-label:" | sed "s/application-label://; s/'//g"`);
|
||||
entry.appName = appName.trim() || "Unknown App";
|
||||
} else {
|
||||
entry.appName = "Unknown App";
|
||||
}
|
||||
} catch (error) {
|
||||
entry.appName = "Unknown App";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort
|
||||
const sortedApps = appEntries.sort((a, b) => {
|
||||
const aChecked = targetList.includes(a.packageName);
|
||||
const bChecked = targetList.includes(b.packageName);
|
||||
if (aChecked !== bChecked) {
|
||||
return aChecked ? -1 : 1;
|
||||
}
|
||||
return (a.appName || "").localeCompare(b.appName || "");
|
||||
});
|
||||
|
||||
// Render
|
||||
appListContainer.innerHTML = "";
|
||||
sortedApps.forEach(({ appName, packageName }) => {
|
||||
const appElement = document.importNode(appTemplate, true);
|
||||
const contentElement = appElement.querySelector(".content");
|
||||
contentElement.setAttribute("data-package", packageName);
|
||||
const nameElement = appElement.querySelector(".name");
|
||||
nameElement.innerHTML = `<strong>${appName || "Unknown App"}</strong><br>${packageName}`;
|
||||
const checkbox = appElement.querySelector(".checkbox");
|
||||
checkbox.checked = targetList.includes(packageName);
|
||||
appListContainer.appendChild(appElement);
|
||||
});
|
||||
console.log("App list with names and packages rendered successfully.");
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch or render app list with names:", error);
|
||||
}
|
||||
floatingBtn.style.transform = "translateY(-120px)";
|
||||
toggleableCheckbox();
|
||||
if (appListContainer.firstChild !== updateCard) {
|
||||
appListContainer.insertBefore(updateCard, appListContainer.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
// Make checkboxes toggleable
|
||||
function toggleableCheckbox() {
|
||||
const appElements = appListContainer.querySelectorAll(".card");
|
||||
appElements.forEach(card => {
|
||||
const content = card.querySelector(".content");
|
||||
const checkbox = content.querySelector(".checkbox");
|
||||
content.addEventListener("click", (event) => {
|
||||
if (event.target !== checkbox) {
|
||||
checkbox.checked = !checkbox.checked;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Function to show the prompt with a success or error message
|
||||
function showPrompt(key, isSuccess = true) {
|
||||
const message = key.split('.').reduce((acc, k) => acc && acc[k], translations) || key;
|
||||
prompt.textContent = message;
|
||||
prompt.classList.toggle('error', !isSuccess);
|
||||
if (window.promptTimeout) {
|
||||
clearTimeout(window.promptTimeout);
|
||||
}
|
||||
setTimeout(() => {
|
||||
prompt.classList.add('visible');
|
||||
prompt.classList.remove('hidden');
|
||||
window.promptTimeout = setTimeout(() => {
|
||||
prompt.classList.remove('visible');
|
||||
prompt.classList.add('hidden');
|
||||
}, 3000);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// Save configure
|
||||
document.getElementById("save").addEventListener("click", async () => {
|
||||
const selectedApps = Array.from(appListContainer.querySelectorAll(".checkbox:checked"))
|
||||
.map(checkbox => checkbox.closest(".card").querySelector(".content").getAttribute("data-package"));
|
||||
let finalAppsList = new Set(selectedApps);
|
||||
ADDITIONAL_APPS.forEach(app => {
|
||||
finalAppsList.add(app);
|
||||
});
|
||||
finalAppsList = Array.from(finalAppsList);
|
||||
try {
|
||||
const updatedTargetContent = finalAppsList.join("\n");
|
||||
await execCommand(`echo "${updatedTargetContent}" > /data/adb/tricky_store/target.txt`);
|
||||
console.log("target.txt updated successfully.");
|
||||
showPrompt("prompt.saved_target");
|
||||
} catch (error) {
|
||||
console.error("Failed to update target.txt:", error);
|
||||
showPrompt("prompt.save_error", false);
|
||||
}
|
||||
await refreshAppList();
|
||||
});
|
||||
|
||||
// Uninstall WebUI
|
||||
document.querySelector(".uninstall-container").addEventListener("click", async () => {
|
||||
try {
|
||||
await execCommand(`
|
||||
su -c "
|
||||
if [ -f '${basePath}action.sh' ]; then
|
||||
if [ -d "/data/adb/modules/TA_utl" ]; then
|
||||
rm -rf "/data/adb/modules/TA_utl"
|
||||
fi
|
||||
cp -rf '${basePath}common/update' '/data/adb/modules/TA_utl' &&
|
||||
touch '/data/adb/modules/TA_utl/remove'
|
||||
else
|
||||
touch '${basePath}remove'
|
||||
fi
|
||||
"
|
||||
`);
|
||||
showPrompt("prompt.uninstall_prompt");
|
||||
} catch (error) {
|
||||
console.error("Failed to execute uninstall command:", error);
|
||||
console.log("Error message:", error.message);
|
||||
showPrompt("prompt.uninstall_failed", false);
|
||||
}
|
||||
});
|
||||
|
||||
// Function to check if running in MMRL
|
||||
function adjustHeaderForMMRL() {
|
||||
if (typeof ksu !== 'undefined' && ksu.mmrl) {
|
||||
console.log("Running in MMRL");
|
||||
title.style.top = 'var(--window-inset-top)';
|
||||
const insetTop = getComputedStyle(document.documentElement).getPropertyValue('--window-inset-top');
|
||||
const insetTopValue = parseInt(insetTop, 10);
|
||||
searchMenuContainer.style.top = `${insetTopValue + 40}px`;
|
||||
headerBlock.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll event
|
||||
let lastScrollY = window.scrollY;
|
||||
const scrollThreshold = 40;
|
||||
window.addEventListener('scroll', () => {
|
||||
if (isRefreshing) return;
|
||||
if (window.scrollY > lastScrollY && window.scrollY > scrollThreshold) {
|
||||
title.style.transform = 'translateY(-80px)';
|
||||
headerBlock.style.transform = 'translateY(-80px)';
|
||||
searchMenuContainer.style.transform = 'translateY(-40px)';
|
||||
floatingBtn.style.transform = 'translateY(0)';
|
||||
} else if (window.scrollY < lastScrollY) {
|
||||
headerBlock.style.transform = 'translateY(0)';
|
||||
title.style.transform = 'translateY(0)';
|
||||
searchMenuContainer.style.transform = 'translateY(0)';
|
||||
floatingBtn.style.transform = 'translateY(-120px)';
|
||||
}
|
||||
lastScrollY = window.scrollY;
|
||||
});
|
||||
|
||||
// Initial load
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
adjustHeaderForMMRL();
|
||||
await initializeAvailableLanguages();
|
||||
const userLang = detectUserLanguage();
|
||||
await loadTranslations(userLang);
|
||||
setupMenuToggle();
|
||||
setupLanguageMenu();
|
||||
setupHelpOverlay();
|
||||
document.getElementById("refresh").addEventListener("click", refreshAppList);
|
||||
document.getElementById("select-all").addEventListener("click", selectAllApps);
|
||||
document.getElementById("deselect-all").addEventListener("click", deselectAllApps);
|
||||
document.getElementById("select-denylist").addEventListener("click", selectDenylistApps);
|
||||
document.getElementById("deselect-unnecessary").addEventListener("click", deselectUnnecessaryApps);
|
||||
document.getElementById("aospkb").addEventListener("click", aospkb);
|
||||
document.getElementById("extrakb").addEventListener("click", extrakb);
|
||||
document.getElementById("boot-hash").addEventListener("click", setBootHash);
|
||||
document.getElementById("about").addEventListener("click", aboutMenu);
|
||||
await fetchAppList();
|
||||
checkMagisk();
|
||||
updateCheck();
|
||||
loadingIndicator.style.display = "none";
|
||||
document.querySelector('.uninstall-container').classList.remove('hidden-uninstall');
|
||||
});
|
||||
|
||||
// Redirect to GitHub release page
|
||||
updateCard.addEventListener('click', async () => {
|
||||
try {
|
||||
await execCommand('am start -a android.intent.action.VIEW -d https://github.com/KOWX712/Tricky-Addon-Update-Target-List/releases/latest');
|
||||
} catch (error) {
|
||||
console.error('Error opening GitHub Release link:', error);
|
||||
}
|
||||
});
|
||||
|
||||
telegramLink.addEventListener('click', async () => {
|
||||
try {
|
||||
await execCommand('am start -a android.intent.action.VIEW -d https://t.me/kowchannel');
|
||||
} catch (error) {
|
||||
console.error('Error opening Telegram link:', error);
|
||||
}
|
||||
});
|
||||
|
||||
githubLink.addEventListener('click', async () => {
|
||||
try {
|
||||
await execCommand('am start -a android.intent.action.VIEW -d https://github.com/KOWX712/Tricky-Addon-Update-Target-List');
|
||||
} catch (error) {
|
||||
console.error('Error opening GitHub link:', error);
|
||||
}
|
||||
});
|
||||
|
||||
// Function to execute shell commands
|
||||
async function execCommand(command) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const callbackName = `exec_callback_${Date.now()}_${e++}`;
|
||||
window[callbackName] = (errno, stdout, stderr) => {
|
||||
delete window[callbackName];
|
||||
if (errno === 0) {
|
||||
resolve(stdout);
|
||||
} else {
|
||||
console.error(`Error executing command: ${stderr}`);
|
||||
reject(stderr);
|
||||
}
|
||||
};
|
||||
try {
|
||||
ksu.exec(command, "{}", callbackName);
|
||||
} catch (error) {
|
||||
console.error(`Execution error: ${error}`);
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
54
module/webui/js/about.js
Normal file
54
module/webui/js/about.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { execCommand } from './main.js';
|
||||
|
||||
const telegramLink = document.getElementById('telegram');
|
||||
const githubLink = document.getElementById('github');
|
||||
|
||||
// Function to show about overlay
|
||||
export function aboutMenu() {
|
||||
const aboutOverlay = document.getElementById('about-overlay');
|
||||
const aboutMenu = document.getElementById('about-menu');
|
||||
const closeAbout = document.getElementById('close-about');
|
||||
const showMenu = () => {
|
||||
aboutOverlay.style.display = 'flex';
|
||||
setTimeout(() => {
|
||||
aboutOverlay.style.opacity = '1';
|
||||
aboutMenu.style.opacity = '1';
|
||||
}, 10);
|
||||
document.body.style.overflow = 'hidden';
|
||||
};
|
||||
const hideMenu = () => {
|
||||
aboutOverlay.style.opacity = '0';
|
||||
aboutMenu.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
aboutOverlay.style.display = 'none';
|
||||
document.body.style.overflow = 'auto';
|
||||
}, 200);
|
||||
};
|
||||
showMenu();
|
||||
closeAbout.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
hideMenu();
|
||||
});
|
||||
aboutOverlay.addEventListener('click', (event) => {
|
||||
if (!aboutMenu.contains(event.target)) {
|
||||
hideMenu();
|
||||
}
|
||||
});
|
||||
menu.addEventListener('click', (event) => event.stopPropagation());
|
||||
}
|
||||
|
||||
// Event listener for link redirect
|
||||
telegramLink.addEventListener('click', async () => {
|
||||
try {
|
||||
await execCommand('am start -a android.intent.action.VIEW -d https://t.me/kowchannel');
|
||||
} catch (error) {
|
||||
console.error('Error opening Telegram link:', error);
|
||||
}
|
||||
});
|
||||
githubLink.addEventListener('click', async () => {
|
||||
try {
|
||||
await execCommand('am start -a android.intent.action.VIEW -d https://github.com/KOWX712/Tricky-Addon-Update-Target-List');
|
||||
} catch (error) {
|
||||
console.error('Error opening GitHub link:', error);
|
||||
}
|
||||
});
|
||||
108
module/webui/js/applist.js
Normal file
108
module/webui/js/applist.js
Normal file
@@ -0,0 +1,108 @@
|
||||
import { basePath, execCommand, floatingBtn } from './main.js';
|
||||
|
||||
const appTemplate = document.getElementById('app-template').content;
|
||||
export const appListContainer = document.getElementById('apps-list');
|
||||
export const updateCard = document.getElementById('update-card');
|
||||
|
||||
// Fetch and render applist
|
||||
export async function fetchAppList() {
|
||||
try {
|
||||
let targetList = [];
|
||||
try {
|
||||
const targetFileContent = await execCommand('cat /data/adb/tricky_store/target.txt');
|
||||
targetList = targetFileContent.split("\n").filter(app => app.trim() !== ''); // Filter out empty lines
|
||||
console.log("Current target list:", targetList);
|
||||
} catch (error) {
|
||||
console.error("Failed to read target.txt file:", error);
|
||||
}
|
||||
|
||||
let applistMap = {};
|
||||
try {
|
||||
const applistResult = await execCommand(`cat ${basePath}common/tmp/applist`);
|
||||
applistMap = applistResult
|
||||
.split("\n")
|
||||
.reduce((map, line) => {
|
||||
const match = line.match(/app-name:\s*(.+),\s*package-name:\s*(.+)/);
|
||||
if (match) {
|
||||
const appName = match[1].trim();
|
||||
const packageName = match[2].trim();
|
||||
map[packageName] = appName;
|
||||
}
|
||||
return map;
|
||||
}, {});
|
||||
console.log("Applist loaded successfully.");
|
||||
} catch (error) {
|
||||
console.warn("Applist file not found or could not be loaded. Skipping applist lookup.");
|
||||
}
|
||||
|
||||
const result = await execCommand("pm list packages -3");
|
||||
const appEntries = result
|
||||
.split("\n")
|
||||
.map(line => {
|
||||
const packageName = line.replace("package:", "").trim();
|
||||
const appName = applistMap[packageName] || null;
|
||||
return { appName, packageName };
|
||||
})
|
||||
.filter(entry => entry.packageName);
|
||||
for (const entry of appEntries) {
|
||||
if (!entry.appName) {
|
||||
try {
|
||||
const apkPath = await execCommand(`pm path ${entry.packageName} | grep "base.apk" | awk -F: '{print $2}' | tr -d '\\r'`);
|
||||
if (apkPath) {
|
||||
const appName = await execCommand(`${basePath}common/aapt dump badging ${apkPath.trim()} 2>/dev/null | grep "application-label:" | sed "s/application-label://; s/'//g"`);
|
||||
entry.appName = appName.trim() || "Unknown App";
|
||||
} else {
|
||||
entry.appName = "Unknown App";
|
||||
}
|
||||
} catch (error) {
|
||||
entry.appName = "Unknown App";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort
|
||||
const sortedApps = appEntries.sort((a, b) => {
|
||||
const aChecked = targetList.includes(a.packageName);
|
||||
const bChecked = targetList.includes(b.packageName);
|
||||
if (aChecked !== bChecked) {
|
||||
return aChecked ? -1 : 1;
|
||||
}
|
||||
return (a.appName || "").localeCompare(b.appName || "");
|
||||
});
|
||||
|
||||
// Render
|
||||
appListContainer.innerHTML = "";
|
||||
sortedApps.forEach(({ appName, packageName }) => {
|
||||
const appElement = document.importNode(appTemplate, true);
|
||||
const contentElement = appElement.querySelector(".content");
|
||||
contentElement.setAttribute("data-package", packageName);
|
||||
const nameElement = appElement.querySelector(".name");
|
||||
nameElement.innerHTML = `<strong>${appName || "Unknown App"}</strong><br>${packageName}`;
|
||||
const checkbox = appElement.querySelector(".checkbox");
|
||||
checkbox.checked = targetList.includes(packageName);
|
||||
appListContainer.appendChild(appElement);
|
||||
});
|
||||
console.log("App list with names and packages rendered successfully.");
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch or render app list with names:", error);
|
||||
}
|
||||
floatingBtn.style.transform = "translateY(-120px)";
|
||||
toggleableCheckbox();
|
||||
if (appListContainer.firstChild !== updateCard) {
|
||||
appListContainer.insertBefore(updateCard, appListContainer.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
// Make checkboxes toggleable
|
||||
function toggleableCheckbox() {
|
||||
const appElements = appListContainer.querySelectorAll(".card");
|
||||
appElements.forEach(card => {
|
||||
const content = card.querySelector(".content");
|
||||
const checkbox = content.querySelector(".checkbox");
|
||||
content.addEventListener("click", (event) => {
|
||||
if (event.target !== checkbox) {
|
||||
checkbox.checked = !checkbox.checked;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
30
module/webui/js/help.js
Normal file
30
module/webui/js/help.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const helpButton = document.getElementById('help-button');
|
||||
const helpOverlay = document.getElementById('help-overlay');
|
||||
const closeHelp = document.getElementById('close-help');
|
||||
const helpList = document.getElementById('help-list');
|
||||
|
||||
// Function to setup the help menu
|
||||
export function setupHelpOverlay() {
|
||||
helpButton.addEventListener("click", () => {
|
||||
helpOverlay.classList.remove("hide");
|
||||
helpOverlay.style.display = "flex";
|
||||
requestAnimationFrame(() => {
|
||||
helpOverlay.classList.add("show");
|
||||
});
|
||||
document.body.classList.add("no-scroll");
|
||||
});
|
||||
const hideHelpOverlay = () => {
|
||||
helpOverlay.classList.remove("show");
|
||||
helpOverlay.classList.add("hide");
|
||||
document.body.classList.remove("no-scroll");
|
||||
setTimeout(() => {
|
||||
helpOverlay.style.display = "none";
|
||||
}, 200);
|
||||
};
|
||||
closeHelp.addEventListener("click", hideHelpOverlay);
|
||||
helpOverlay.addEventListener("click", (event) => {
|
||||
if (event.target === helpOverlay) {
|
||||
hideHelpOverlay();
|
||||
}
|
||||
});
|
||||
}
|
||||
132
module/webui/js/language.js
Normal file
132
module/webui/js/language.js
Normal file
@@ -0,0 +1,132 @@
|
||||
import { basePath, execCommand } from './main.js';
|
||||
|
||||
const languageButton = document.querySelector('.language-button');
|
||||
const languageMenu = document.querySelector('.language-menu');
|
||||
const languageOptions = document.querySelectorAll('.language-option');
|
||||
const languageOverlay = document.getElementById('language-overlay');
|
||||
|
||||
export let translations = {};
|
||||
let currentLang = 'en-US';
|
||||
let availableLanguages = ['en-US'];
|
||||
|
||||
// Function to check for available language
|
||||
export async function initializeAvailableLanguages() {
|
||||
try {
|
||||
const multiLang = await execCommand(`find ${basePath}webui/locales -type f -name "*.json" ! -name "A-template.json" -exec basename -s .json {} \\;`);
|
||||
availableLanguages = multiLang.trim().split('\n');
|
||||
generateLanguageMenu();
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch available languages:', error);
|
||||
availableLanguages = ['en-US'];
|
||||
}
|
||||
}
|
||||
|
||||
// Function to detect user's default language
|
||||
export function detectUserLanguage() {
|
||||
const userLang = navigator.language || navigator.userLanguage;
|
||||
const langCode = userLang.split('-')[0];
|
||||
if (availableLanguages.includes(userLang)) {
|
||||
return userLang;
|
||||
} else if (availableLanguages.includes(langCode)) {
|
||||
return langCode;
|
||||
} else {
|
||||
return 'en-US';
|
||||
}
|
||||
}
|
||||
|
||||
// Load translations dynamically based on the selected language
|
||||
export async function loadTranslations(lang) {
|
||||
try {
|
||||
const response = await fetch(`/locales/${lang}.json`);
|
||||
translations = await response.json();
|
||||
applyTranslations();
|
||||
} catch (error) {
|
||||
console.error(`Error loading translations for ${lang}:`, error);
|
||||
if (lang !== 'en-US') {
|
||||
console.log("Falling back to English.");
|
||||
loadTranslations('en-US');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to apply translations to all elements with data-i18n attributes
|
||||
function applyTranslations() {
|
||||
document.querySelectorAll("[data-i18n]").forEach((el) => {
|
||||
const keyString = el.getAttribute("data-i18n");
|
||||
const translation = keyString.split('.').reduce((acc, key) => acc && acc[key], translations);
|
||||
if (translation) {
|
||||
if (el.hasAttribute("placeholder")) {
|
||||
el.setAttribute("placeholder", translation);
|
||||
} else {
|
||||
el.textContent = translation;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to setup the language menu
|
||||
export function setupLanguageMenu() {
|
||||
languageButton.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
const isVisible = languageMenu.classList.contains("show");
|
||||
if (isVisible) {
|
||||
closeLanguageMenu();
|
||||
} else {
|
||||
openLanguageMenu();
|
||||
}
|
||||
});
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!languageButton.contains(event.target) && !languageMenu.contains(event.target)) {
|
||||
closeLanguageMenu();
|
||||
}
|
||||
});
|
||||
languageOptions.forEach(option => {
|
||||
option.addEventListener("click", () => {
|
||||
closeLanguageMenu();
|
||||
});
|
||||
});
|
||||
window.addEventListener('scroll', () => {
|
||||
if (languageMenu.classList.contains("show")) {
|
||||
closeLanguageMenu();
|
||||
}
|
||||
});
|
||||
function openLanguageMenu() {
|
||||
languageMenu.classList.add("show");
|
||||
languageOverlay.style.display = 'flex';
|
||||
}
|
||||
function closeLanguageMenu() {
|
||||
languageMenu.classList.remove("show");
|
||||
languageOverlay.style.display = 'none';
|
||||
}
|
||||
languageMenu.addEventListener("click", (e) => {
|
||||
if (e.target.classList.contains("language-option")) {
|
||||
const lang = e.target.getAttribute("data-lang");
|
||||
loadTranslations(lang);
|
||||
closeLanguageMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to generate the language menu dynamically
|
||||
async function generateLanguageMenu() {
|
||||
languageMenu.innerHTML = '';
|
||||
const languagePromises = availableLanguages.map(async (lang) => {
|
||||
try {
|
||||
const response = await fetch(`/locales/${lang}.json`);
|
||||
const data = await response.json();
|
||||
return { lang, name: data.language || lang };
|
||||
} catch (error) {
|
||||
console.error(`Error fetching language name for ${lang}:`, error);
|
||||
return { lang, name: lang };
|
||||
}
|
||||
});
|
||||
const languageData = await Promise.all(languagePromises);
|
||||
const sortedLanguages = languageData.sort((a, b) => a.name.localeCompare(b.name));
|
||||
sortedLanguages.forEach(({ lang, name }) => {
|
||||
const button = document.createElement('button');
|
||||
button.classList.add('language-option');
|
||||
button.setAttribute('data-lang', lang);
|
||||
button.textContent = name;
|
||||
languageMenu.appendChild(button);
|
||||
});
|
||||
}
|
||||
233
module/webui/js/main.js
Normal file
233
module/webui/js/main.js
Normal file
@@ -0,0 +1,233 @@
|
||||
import { aboutMenu } from './about.js';
|
||||
import { appListContainer, updateCard, fetchAppList } from './applist.js';
|
||||
import { setupHelpOverlay } from './help.js';
|
||||
import { initializeAvailableLanguages, detectUserLanguage, loadTranslations, setupLanguageMenu, translations } from './language.js';
|
||||
import { selectAllApps, deselectAllApps, selectDenylistApps, deselectUnnecessaryApps, aospkb, extrakb } from './menu_option.js';
|
||||
import { searchMenuContainer, searchInput, clearBtn, setupMenuToggle } from './search_menu.js';
|
||||
import { setBootHash } from './vbmeta-digest.js';
|
||||
|
||||
// Header Elements
|
||||
const headerBlock = document.querySelector('.header-block');
|
||||
const title = document.querySelector('.header');
|
||||
const noConnection = document.querySelector('.no-connection');
|
||||
|
||||
// Menu Elements
|
||||
const selectDenylistElement = document.getElementById('select-denylist');
|
||||
|
||||
// Loading, Save and Prompt Elements
|
||||
const loadingIndicator = document.querySelector('.loading');
|
||||
const prompt = document.getElementById('prompt');
|
||||
export const floatingBtn = document.querySelector('.floating-btn');
|
||||
|
||||
export const basePath = "set-path";
|
||||
const ADDITIONAL_APPS = [
|
||||
"com.google.android.gms",
|
||||
"io.github.vvb2060.keyattestation",
|
||||
"io.github.vvb2060.mahoshojo",
|
||||
"icu.nullptr.nativetest"
|
||||
];
|
||||
|
||||
// Variables
|
||||
let e = 0;
|
||||
let isRefreshing = false;
|
||||
|
||||
// Function to refresh app list
|
||||
async function refreshAppList() {
|
||||
isRefreshing = true;
|
||||
title.style.transform = 'translateY(0)';
|
||||
searchMenuContainer.style.transform = 'translateY(0)';
|
||||
floatingBtn.style.transform = 'translateY(0)';
|
||||
searchInput.value = '';
|
||||
clearBtn.style.display = "none";
|
||||
appListContainer.innerHTML = '';
|
||||
loadingIndicator.style.display = 'flex';
|
||||
document.querySelector('.uninstall-container').classList.add('hidden-uninstall');
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
window.scrollTo(0, 0);
|
||||
if (noConnection.style.display === "flex") {
|
||||
try {
|
||||
await updateCheck();
|
||||
await execCommand(`[ -f ${basePath}common/tmp/exclude-list ] && rm -f "${basePath}common/tmp/exclude-list"`);
|
||||
} catch (error) {
|
||||
console.error("Error occurred:", error);
|
||||
}
|
||||
}
|
||||
await fetchAppList();
|
||||
loadingIndicator.style.display = 'none';
|
||||
document.querySelector('.uninstall-container').classList.remove('hidden-uninstall');
|
||||
isRefreshing = false;
|
||||
}
|
||||
|
||||
// Function to run the update check
|
||||
async function updateCheck() {
|
||||
try {
|
||||
const scriptPath = `sh ${basePath}common/get_extra.sh --update`;
|
||||
const output = await execCommand(scriptPath);
|
||||
console.log("update script executed successfully.");
|
||||
noConnection.style.display = "none";
|
||||
if (output.includes("update")) {
|
||||
console.log("Update detected from extra script.");
|
||||
showPrompt("prompt.new_update");
|
||||
updateCard.style.display = "flex";
|
||||
} else {
|
||||
console.log("No update detected from extra script.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to execute update script:", error);
|
||||
showPrompt("prompt.no_internet", false);
|
||||
noConnection.style.display = "flex";
|
||||
}
|
||||
}
|
||||
|
||||
// Function to check if Magisk
|
||||
async function checkMagisk() {
|
||||
try {
|
||||
const magiskEnv = await execCommand(`command -v magisk >/dev/null 2>&1 && echo "OK"`);
|
||||
if (magiskEnv.trim() === "OK") {
|
||||
console.log("Denylist conditions met, displaying element.");
|
||||
selectDenylistElement.style.display = "flex";
|
||||
} else {
|
||||
console.log("ksud or apd detected, leaving denylist element hidden.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error while checking denylist conditions:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to show the prompt with a success or error message
|
||||
export function showPrompt(key, isSuccess = true) {
|
||||
const message = key.split('.').reduce((acc, k) => acc && acc[k], translations) || key;
|
||||
prompt.textContent = message;
|
||||
prompt.classList.toggle('error', !isSuccess);
|
||||
if (window.promptTimeout) {
|
||||
clearTimeout(window.promptTimeout);
|
||||
}
|
||||
setTimeout(() => {
|
||||
prompt.classList.add('visible');
|
||||
prompt.classList.remove('hidden');
|
||||
window.promptTimeout = setTimeout(() => {
|
||||
prompt.classList.remove('visible');
|
||||
prompt.classList.add('hidden');
|
||||
}, 3000);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// Save configure
|
||||
document.getElementById("save").addEventListener("click", async () => {
|
||||
const selectedApps = Array.from(appListContainer.querySelectorAll(".checkbox:checked"))
|
||||
.map(checkbox => checkbox.closest(".card").querySelector(".content").getAttribute("data-package"));
|
||||
let finalAppsList = new Set(selectedApps);
|
||||
ADDITIONAL_APPS.forEach(app => {
|
||||
finalAppsList.add(app);
|
||||
});
|
||||
finalAppsList = Array.from(finalAppsList);
|
||||
try {
|
||||
const updatedTargetContent = finalAppsList.join("\n");
|
||||
await execCommand(`echo "${updatedTargetContent}" > /data/adb/tricky_store/target.txt`);
|
||||
console.log("target.txt updated successfully.");
|
||||
showPrompt("prompt.saved_target");
|
||||
} catch (error) {
|
||||
console.error("Failed to update target.txt:", error);
|
||||
showPrompt("prompt.save_error", false);
|
||||
}
|
||||
await refreshAppList();
|
||||
});
|
||||
|
||||
// Uninstall WebUI
|
||||
document.querySelector(".uninstall-container").addEventListener("click", async () => {
|
||||
try {
|
||||
await execCommand(`sh ${basePath}common/get_extra.sh --uninstall`);
|
||||
console.log("uninstall script executed successfully.");
|
||||
showPrompt("prompt.uninstall_prompt");
|
||||
} catch (error) {
|
||||
console.error("Failed to execute uninstall command:", error);
|
||||
showPrompt("prompt.uninstall_failed", false);
|
||||
}
|
||||
});
|
||||
|
||||
// Function to check if running in MMRL
|
||||
function adjustHeaderForMMRL() {
|
||||
if (typeof ksu !== 'undefined' && ksu.mmrl) {
|
||||
console.log("Running in MMRL");
|
||||
title.style.top = 'var(--window-inset-top)';
|
||||
const insetTop = getComputedStyle(document.documentElement).getPropertyValue('--window-inset-top');
|
||||
const insetTopValue = parseInt(insetTop, 10);
|
||||
searchMenuContainer.style.top = `${insetTopValue + 40}px`;
|
||||
headerBlock.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll event
|
||||
let lastScrollY = window.scrollY;
|
||||
const scrollThreshold = 40;
|
||||
window.addEventListener('scroll', () => {
|
||||
if (isRefreshing) return;
|
||||
if (window.scrollY > lastScrollY && window.scrollY > scrollThreshold) {
|
||||
title.style.transform = 'translateY(-80px)';
|
||||
headerBlock.style.transform = 'translateY(-80px)';
|
||||
searchMenuContainer.style.transform = 'translateY(-40px)';
|
||||
floatingBtn.style.transform = 'translateY(0)';
|
||||
} else if (window.scrollY < lastScrollY) {
|
||||
headerBlock.style.transform = 'translateY(0)';
|
||||
title.style.transform = 'translateY(0)';
|
||||
searchMenuContainer.style.transform = 'translateY(0)';
|
||||
floatingBtn.style.transform = 'translateY(-120px)';
|
||||
}
|
||||
lastScrollY = window.scrollY;
|
||||
});
|
||||
|
||||
// Initial load
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
adjustHeaderForMMRL();
|
||||
await initializeAvailableLanguages();
|
||||
const userLang = detectUserLanguage();
|
||||
await loadTranslations(userLang);
|
||||
setupMenuToggle();
|
||||
setupLanguageMenu();
|
||||
setupHelpOverlay();
|
||||
document.getElementById("refresh").addEventListener("click", refreshAppList);
|
||||
document.getElementById("select-all").addEventListener("click", selectAllApps);
|
||||
document.getElementById("deselect-all").addEventListener("click", deselectAllApps);
|
||||
document.getElementById("select-denylist").addEventListener("click", selectDenylistApps);
|
||||
document.getElementById("deselect-unnecessary").addEventListener("click", deselectUnnecessaryApps);
|
||||
document.getElementById("aospkb").addEventListener("click", aospkb);
|
||||
document.getElementById("extrakb").addEventListener("click", extrakb);
|
||||
document.getElementById("boot-hash").addEventListener("click", setBootHash);
|
||||
document.getElementById("about").addEventListener("click", aboutMenu);
|
||||
await fetchAppList();
|
||||
checkMagisk();
|
||||
updateCheck();
|
||||
loadingIndicator.style.display = "none";
|
||||
document.querySelector('.uninstall-container').classList.remove('hidden-uninstall');
|
||||
});
|
||||
|
||||
// Redirect to GitHub release page
|
||||
updateCard.addEventListener('click', async () => {
|
||||
try {
|
||||
await execCommand('am start -a android.intent.action.VIEW -d https://github.com/KOWX712/Tricky-Addon-Update-Target-List/releases/latest');
|
||||
} catch (error) {
|
||||
console.error('Error opening GitHub Release link:', error);
|
||||
}
|
||||
});
|
||||
|
||||
// Function to execute shell commands
|
||||
export async function execCommand(command) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const callbackName = `exec_callback_${Date.now()}_${e++}`;
|
||||
window[callbackName] = (errno, stdout, stderr) => {
|
||||
delete window[callbackName];
|
||||
if (errno === 0) {
|
||||
resolve(stdout);
|
||||
} else {
|
||||
console.error(`Error executing command: ${stderr}`);
|
||||
reject(stderr);
|
||||
}
|
||||
};
|
||||
try {
|
||||
ksu.exec(command, "{}", callbackName);
|
||||
} catch (error) {
|
||||
console.error(`Execution error: ${error}`);
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
111
module/webui/js/menu_option.js
Normal file
111
module/webui/js/menu_option.js
Normal file
@@ -0,0 +1,111 @@
|
||||
import { basePath, execCommand, showPrompt } from './main.js';
|
||||
|
||||
// Function to check or uncheck all app
|
||||
function toggleCheckboxes(shouldCheck) {
|
||||
document.querySelectorAll(".card").forEach(card => {
|
||||
if (card.style.display !== "none") {
|
||||
card.querySelector(".checkbox").checked = shouldCheck;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to select all visible apps
|
||||
export function selectAllApps() {
|
||||
toggleCheckboxes(true);
|
||||
}
|
||||
|
||||
// Function to deselect all visible apps
|
||||
export function deselectAllApps() {
|
||||
toggleCheckboxes(false);
|
||||
}
|
||||
|
||||
// Function to read the denylist and check corresponding apps
|
||||
export async function selectDenylistApps() {
|
||||
try {
|
||||
const result = await execCommand(`magisk --denylist ls 2>/dev/null | awk -F'|' '{print $1}' | grep -v "isolated" | sort | uniq`);
|
||||
const denylistApps = result.split("\n").map(app => app.trim()).filter(Boolean);
|
||||
const apps = document.querySelectorAll(".card");
|
||||
await deselectAllApps();
|
||||
apps.forEach(app => {
|
||||
const contentElement = app.querySelector(".content");
|
||||
const packageName = contentElement.getAttribute("data-package");
|
||||
const checkbox = app.querySelector(".checkbox");
|
||||
if (denylistApps.includes(packageName)) {
|
||||
checkbox.checked = true;
|
||||
}
|
||||
});
|
||||
console.log("Denylist apps selected successfully.");
|
||||
} catch (error) {
|
||||
console.error("Failed to select Denylist apps:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to read the exclude list and uncheck corresponding apps
|
||||
export async function deselectUnnecessaryApps() {
|
||||
try {
|
||||
const fileCheck = await execCommand(`test -f ${basePath}common/tmp/exclude-list && echo "exists" || echo "not found"`);
|
||||
if (fileCheck.trim() === "not found") {
|
||||
setTimeout(async () => {
|
||||
await execCommand(`sh ${basePath}common/get_extra.sh --unnecessary`);
|
||||
}, 0);
|
||||
console.log("Exclude list not found. Running the unnecessary apps script.");
|
||||
} else {
|
||||
setTimeout(async () => {
|
||||
await execCommand(`sh ${basePath}common/get_extra.sh --xposed`);
|
||||
}, 0);
|
||||
console.log("Exclude list found. Running xposed script.");
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
const result = await execCommand(`cat ${basePath}common/tmp/exclude-list`);
|
||||
const UnnecessaryApps = result.split("\n").map(app => app.trim()).filter(Boolean);
|
||||
const apps = document.querySelectorAll(".card");
|
||||
apps.forEach(app => {
|
||||
const contentElement = app.querySelector(".content");
|
||||
const packageName = contentElement.getAttribute("data-package");
|
||||
const checkbox = app.querySelector(".checkbox");
|
||||
if (UnnecessaryApps.includes(packageName)) {
|
||||
checkbox.checked = false;
|
||||
}
|
||||
});
|
||||
console.log("Unnecessary apps deselected successfully.");
|
||||
} catch (error) {
|
||||
console.error("Failed to deselect unnecessary apps:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to replace aosp kb
|
||||
export async function aospkb() {
|
||||
try {
|
||||
const sourcePath = `${basePath}common/.default`;
|
||||
const destinationPath = "/data/adb/tricky_store/keybox.xml";
|
||||
await execCommand(`xxd -r -p ${sourcePath} | base64 -d > ${destinationPath}`);
|
||||
console.log("AOSP keybox copied successfully.");
|
||||
showPrompt("prompt.aosp_key_set");
|
||||
} catch (error) {
|
||||
console.error("Failed to copy AOSP keybox:", error);
|
||||
showPrompt("prompt.key_set_error", false);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to replace valid kb
|
||||
export async function extrakb() {
|
||||
setTimeout(async () => {
|
||||
await execCommand(`sh ${basePath}common/get_extra.sh --kb`);
|
||||
}, 100);
|
||||
const sourcePath = `${basePath}common/tmp/.extra`;
|
||||
const destinationPath = "/data/adb/tricky_store/keybox.xml";
|
||||
try {
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
const fileExists = await execCommand(`[ -f ${sourcePath} ] && echo "exists"`);
|
||||
if (fileExists.trim() !== "exists") {
|
||||
throw new Error(".extra file not found");
|
||||
}
|
||||
await execCommand(`xxd -r -p ${sourcePath} | base64 -d > ${destinationPath}`);
|
||||
console.log("Valid keybox copied successfully.");
|
||||
showPrompt("prompt.valid_key_set");
|
||||
} catch (error) {
|
||||
console.error("Failed to copy valid keybox:", error);
|
||||
await aospkb();
|
||||
showPrompt("prompt.no_valid_fallback", false);
|
||||
}
|
||||
}
|
||||
103
module/webui/js/search_menu.js
Normal file
103
module/webui/js/search_menu.js
Normal file
@@ -0,0 +1,103 @@
|
||||
import { appListContainer } from './applist.js';
|
||||
|
||||
const searchCard = document.querySelector('.search-card');
|
||||
export const searchInput = document.getElementById('search');
|
||||
export const clearBtn = document.getElementById('clear-btn');
|
||||
export const searchMenuContainer = document.querySelector('.search-menu-container');
|
||||
const menu = document.querySelector('.menu');
|
||||
const menuButton = document.getElementById('menu-button');
|
||||
const menuOptions = document.getElementById('menu-options');
|
||||
const menuOverlay = document.getElementById('menu-overlay');
|
||||
const menuIcon = menuButton.querySelector('.menu-icon');
|
||||
|
||||
// Focus on search input when search card is clicked
|
||||
searchCard.addEventListener("click", () => {
|
||||
searchInput.focus();
|
||||
});
|
||||
|
||||
// Search functionality
|
||||
searchInput.addEventListener("input", (e) => {
|
||||
const searchQuery = e.target.value.toLowerCase();
|
||||
const apps = appListContainer.querySelectorAll(".card");
|
||||
apps.forEach(app => {
|
||||
const name = app.querySelector(".name").textContent.toLowerCase();
|
||||
app.style.display = name.includes(searchQuery) ? "block" : "none";
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
if (searchQuery !== "") {
|
||||
clearBtn.style.display = "block";
|
||||
} else {
|
||||
clearBtn.style.display = "none";
|
||||
}
|
||||
});
|
||||
|
||||
// Clear search input
|
||||
clearBtn.addEventListener("click", () => {
|
||||
searchInput.value = "";
|
||||
clearBtn.style.display = "none";
|
||||
window.scrollTo(0, 0);
|
||||
const apps = appListContainer.querySelectorAll(".card");
|
||||
apps.forEach(app => {
|
||||
app.style.display = "block";
|
||||
});
|
||||
});
|
||||
|
||||
// Function to toggle menu option
|
||||
export function setupMenuToggle() {
|
||||
let menuOpen = false;
|
||||
let menuAnimating = false;
|
||||
menuButton.addEventListener('click', (event) => {
|
||||
if (menuAnimating) return;
|
||||
event.stopPropagation();
|
||||
if (menuOptions.classList.contains('visible')) {
|
||||
closeMenu();
|
||||
} else {
|
||||
openMenu();
|
||||
}
|
||||
});
|
||||
document.addEventListener('click', (event) => {
|
||||
if (!menuOptions.contains(event.target) && event.target !== menuButton) {
|
||||
closeMenu();
|
||||
}
|
||||
});
|
||||
window.addEventListener('scroll', () => {
|
||||
if (menuOptions.classList.contains('visible')) {
|
||||
closeMenu();
|
||||
}
|
||||
});
|
||||
const menuOptionsList = document.querySelectorAll('#menu-options li');
|
||||
menuOptionsList.forEach(option => {
|
||||
option.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
closeMenu();
|
||||
});
|
||||
});
|
||||
function openMenu() {
|
||||
menuAnimating = true;
|
||||
menuOptions.style.display = 'block';
|
||||
setTimeout(() => {
|
||||
menuOptions.classList.remove('hidden');
|
||||
menuOptions.classList.add('visible');
|
||||
menuIcon.classList.add('menu-open');
|
||||
menuIcon.classList.remove('menu-closed');
|
||||
menuOverlay.style.display = 'flex';
|
||||
menuOpen = true;
|
||||
menuAnimating = false;
|
||||
}, 10);
|
||||
}
|
||||
function closeMenu() {
|
||||
if (menuOptions.classList.contains('visible')) {
|
||||
menuAnimating = true;
|
||||
menuOptions.classList.remove('visible');
|
||||
menuOptions.classList.add('hidden');
|
||||
menuIcon.classList.remove('menu-open');
|
||||
menuIcon.classList.add('menu-closed');
|
||||
menuOverlay.style.display = 'none';
|
||||
setTimeout(() => {
|
||||
menuOptions.style.display = 'none';
|
||||
menuOpen = false;
|
||||
menuAnimating = false;
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
54
module/webui/js/vbmeta-digest.js
Normal file
54
module/webui/js/vbmeta-digest.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { execCommand, showPrompt } from './main.js';
|
||||
|
||||
const bootHashOverlay = document.getElementById('boot-hash-overlay');
|
||||
const card = document.getElementById('boot-hash-card');
|
||||
const inputBox = document.getElementById('boot-hash-input');
|
||||
const saveButton = document.getElementById('boot-hash-save-button');
|
||||
|
||||
// Function to handle Verified Boot Hash
|
||||
export async function setBootHash() {
|
||||
const showCard = () => {
|
||||
bootHashOverlay.style.display = "flex";
|
||||
card.style.display = "flex";
|
||||
requestAnimationFrame(() => {
|
||||
bootHashOverlay.classList.add("show");
|
||||
card.classList.add("show");
|
||||
});
|
||||
document.body.style.overflow = "hidden";
|
||||
};
|
||||
const closeCard = () => {
|
||||
bootHashOverlay.classList.remove("show");
|
||||
card.classList.remove("show");
|
||||
setTimeout(() => {
|
||||
bootHashOverlay.style.display = "none";
|
||||
card.style.display = "none";
|
||||
document.body.style.overflow = "auto";
|
||||
}, 200);
|
||||
};
|
||||
showCard();
|
||||
try {
|
||||
const bootHashContent = await execCommand("cat /data/adb/boot_hash");
|
||||
const validHash = bootHashContent
|
||||
.split("\n")
|
||||
.filter(line => !line.startsWith("#") && line.trim())[0];
|
||||
inputBox.value = validHash || "";
|
||||
} catch (error) {
|
||||
console.warn("Failed to read boot_hash file. Defaulting to empty input.");
|
||||
inputBox.value = "";
|
||||
}
|
||||
saveButton.addEventListener("click", async () => {
|
||||
const inputValue = inputBox.value.trim();
|
||||
try {
|
||||
await execCommand(`echo "${inputValue}" > /data/adb/boot_hash`);
|
||||
await execCommand(`su -c resetprop -n ro.boot.vbmeta.digest ${inputValue}`);
|
||||
showPrompt("prompt.boot_hash_set");
|
||||
closeCard();
|
||||
} catch (error) {
|
||||
console.error("Failed to update boot_hash:", error);
|
||||
showPrompt("prompt.boot_hash_set_error", false);
|
||||
}
|
||||
});
|
||||
bootHashOverlay.addEventListener("click", (event) => {
|
||||
if (event.target === bootHashOverlay) closeCard();
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"language": "English",
|
||||
"header": {
|
||||
"title": "Tricky Addon - Update Target List"
|
||||
},
|
||||
|
||||
@@ -15,17 +15,4 @@
|
||||
2. Make a copy of `/module/webroot/locales/A-template.json`
|
||||
3. Rename it to `language_code-COUNTRY_CODE.json`, e.g., `en-US.json`.
|
||||
4. Translate the string value inside.
|
||||
5. Add `langauge-option` into `/module/webroot/index.html`.
|
||||
|
||||
Format:
|
||||
```xml
|
||||
<button class="language-option" data-lang="language_code-COUNTRY_CODE">languageName</button>
|
||||
```
|
||||
|
||||
Example:
|
||||
```xml
|
||||
<div class="language-menu">
|
||||
<button class="language-option" data-lang="en-US">English</button>
|
||||
</div>
|
||||
```
|
||||
Finally, Create a Pull Request.
|
||||
6. Create a Pull Request.
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"language": "English",
|
||||
"header": {
|
||||
"title": "Tricky Addon - Update Target List"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"language": "Español",
|
||||
"header": {
|
||||
"title": "Tricky Addon - Update Target List"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"language": "日本語",
|
||||
"header": {
|
||||
"title": "Tricky Addon - Update Target List"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"language": "Русский",
|
||||
"header": {
|
||||
"title": "Tricky Addon - Обновить список целей"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"language": "Tagalog",
|
||||
"header": {
|
||||
"title": "Tricky Addon - I-update ang Target List"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"language": "中文(简体)",
|
||||
"header": {
|
||||
"title": "TS插件 - 更新目标列表"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"language": "中文(繁体)",
|
||||
"header": {
|
||||
"title": "TS插件 - 更新目標列表"
|
||||
},
|
||||
|
||||
@@ -295,12 +295,12 @@ body {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 75vw;
|
||||
width: 90vw;
|
||||
max-width: 800px;
|
||||
transform: translate(-50%, -50%);
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 25px 30px;
|
||||
border-radius: 15px;
|
||||
padding: 30px 0;
|
||||
z-index: 1200;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1200;
|
||||
@@ -321,8 +321,10 @@ body {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.link,
|
||||
.about-content p {
|
||||
margin: 0;
|
||||
padding: 0 30px;
|
||||
font-size: 16px;
|
||||
text-align: left;
|
||||
}
|
||||
@@ -348,33 +350,35 @@ body {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.about-content p:not([data-i18n]) {
|
||||
font-size: 16px;
|
||||
.link-icon {
|
||||
display: inline-block;
|
||||
font-style: normal;
|
||||
border-radius: 8px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 5px;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.link {
|
||||
flex: 0 1 auto;
|
||||
.link-icon svg {
|
||||
padding-bottom: 3px;
|
||||
vertical-align: bottom;
|
||||
height: 17px;
|
||||
}
|
||||
|
||||
#telegram {
|
||||
font-size: 18px;
|
||||
padding: 5px 10px;
|
||||
padding: 3px 10px;
|
||||
background-color: #38A7ED;
|
||||
color: #fff;
|
||||
border-radius: 8px;
|
||||
margin-right: 3px;
|
||||
margin-bottom: 5px;
|
||||
transition: background-color 0.2s ease;
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
#github {
|
||||
font-size: 18px;
|
||||
padding: 5px 10px;
|
||||
padding: 3px 10px;
|
||||
background-color: #606060;
|
||||
color: #fff;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 5px;
|
||||
transition: background-color 0.2s ease;
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
#link-text {
|
||||
@@ -464,6 +468,7 @@ body {
|
||||
|
||||
.menu-icon {
|
||||
display: inline-block;
|
||||
fill: #000;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
@@ -790,7 +795,11 @@ body {
|
||||
.help-button {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
||||
.menu-icon {
|
||||
fill: #eee;
|
||||
}
|
||||
|
||||
.help-menu,
|
||||
.about-menu,
|
||||
.boot-hash-card,
|
||||
|
||||
Reference in New Issue
Block a user