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
webui: abandon UpdateTargetList.sh
This commit is contained in:
@@ -72,10 +72,10 @@
|
|||||||
<!-- Applist Display -->
|
<!-- Applist Display -->
|
||||||
<div id="apps-list"></div>
|
<div id="apps-list"></div>
|
||||||
<template id="app-template">
|
<template id="app-template">
|
||||||
<div class="card" onclick="toggleCheckbox(event)">
|
<div class="card">
|
||||||
<div class="content" data-package="">
|
<div class="content" data-package="">
|
||||||
<p class="name"></p>
|
<p class="name"></p>
|
||||||
<input type="checkbox" class="checkbox" checked>
|
<input type="checkbox" class="checkbox">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
+55
-57
@@ -39,6 +39,12 @@ const inputBox = document.getElementById('boot-hash-input');
|
|||||||
const saveButton = document.getElementById('boot-hash-save-button');
|
const saveButton = document.getElementById('boot-hash-save-button');
|
||||||
|
|
||||||
const basePath = "set-path";
|
const basePath = "set-path";
|
||||||
|
const ADDITIONAL_APPS = [
|
||||||
|
"com.google.android.gms",
|
||||||
|
"io.github.vvb2060.keyattestation",
|
||||||
|
"io.github.vvb2060.mahoshojo",
|
||||||
|
"icu.nullptr.nativetest"
|
||||||
|
];
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
let e = 0;
|
let e = 0;
|
||||||
@@ -150,26 +156,18 @@ async function execCommand(command) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to read the EXCLUDE file and return its contents as an array
|
// Fetch and render applist
|
||||||
async function readExcludeFile() {
|
|
||||||
try {
|
|
||||||
const result = await execCommand('cat /data/adb/tricky_store/target_list_config/EXCLUDE');
|
|
||||||
excludeList = result.split("\n").filter(app => app.trim() !== ''); // Filter out empty lines
|
|
||||||
console.log("Current EXCLUDE list:", excludeList);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to read EXCLUDE file:", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to check if an app name should be excluded
|
|
||||||
function isExcluded(appName) {
|
|
||||||
return excludeList.some(excludeItem => appName.includes(excludeItem));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to fetch, sort, and render the app list with app names
|
|
||||||
async function fetchAppList() {
|
async function fetchAppList() {
|
||||||
try {
|
try {
|
||||||
await readExcludeFile();
|
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 = {};
|
let applistMap = {};
|
||||||
try {
|
try {
|
||||||
const applistResult = await execCommand(`cat ${basePath}applist`);
|
const applistResult = await execCommand(`cat ${basePath}applist`);
|
||||||
@@ -188,6 +186,7 @@ async function fetchAppList() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn("Applist file not found or could not be loaded. Skipping applist lookup.");
|
console.warn("Applist file not found or could not be loaded. Skipping applist lookup.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await execCommand("pm list packages -3");
|
const result = await execCommand("pm list packages -3");
|
||||||
const appEntries = result
|
const appEntries = result
|
||||||
.split("\n")
|
.split("\n")
|
||||||
@@ -212,11 +211,18 @@ async function fetchAppList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort
|
||||||
const sortedApps = appEntries.sort((a, b) => {
|
const sortedApps = appEntries.sort((a, b) => {
|
||||||
const aInExclude = isExcluded(a.packageName);
|
const aChecked = targetList.includes(a.packageName);
|
||||||
const bInExclude = isExcluded(b.packageName);
|
const bChecked = targetList.includes(b.packageName);
|
||||||
return aInExclude === bInExclude ? a.appName.localeCompare(b.appName) : aInExclude ? 1 : -1;
|
if (aChecked !== bChecked) {
|
||||||
|
return aChecked ? -1 : 1;
|
||||||
|
}
|
||||||
|
return (a.appName || "").localeCompare(b.appName || "");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Render
|
||||||
appListContainer.innerHTML = "";
|
appListContainer.innerHTML = "";
|
||||||
sortedApps.forEach(({ appName, packageName }) => {
|
sortedApps.forEach(({ appName, packageName }) => {
|
||||||
const appElement = document.importNode(appTemplate, true);
|
const appElement = document.importNode(appTemplate, true);
|
||||||
@@ -225,7 +231,7 @@ async function fetchAppList() {
|
|||||||
const nameElement = appElement.querySelector(".name");
|
const nameElement = appElement.querySelector(".name");
|
||||||
nameElement.innerHTML = `<strong>${appName || "Unknown App"}</strong><br>${packageName}`;
|
nameElement.innerHTML = `<strong>${appName || "Unknown App"}</strong><br>${packageName}`;
|
||||||
const checkbox = appElement.querySelector(".checkbox");
|
const checkbox = appElement.querySelector(".checkbox");
|
||||||
checkbox.checked = !isExcluded(packageName);
|
checkbox.checked = targetList.includes(packageName);
|
||||||
appListContainer.appendChild(appElement);
|
appListContainer.appendChild(appElement);
|
||||||
});
|
});
|
||||||
console.log("App list with names and packages rendered successfully.");
|
console.log("App list with names and packages rendered successfully.");
|
||||||
@@ -233,6 +239,21 @@ async function fetchAppList() {
|
|||||||
console.error("Failed to fetch or render app list with names:", error);
|
console.error("Failed to fetch or render app list with names:", error);
|
||||||
}
|
}
|
||||||
floatingBtn.style.transform = "translateY(-120px)";
|
floatingBtn.style.transform = "translateY(-120px)";
|
||||||
|
toggleableCheckbox();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 refresh app list
|
// Function to refresh app list
|
||||||
@@ -502,6 +523,7 @@ function showPrompt(key, isSuccess = true) {
|
|||||||
// Function to toggle menu option
|
// Function to toggle menu option
|
||||||
function setupMenuToggle() {
|
function setupMenuToggle() {
|
||||||
const menuIcon = menuButton.querySelector('.menu-icon');
|
const menuIcon = menuButton.querySelector('.menu-icon');
|
||||||
|
const menuOptions = document.getElementById('menu-options');
|
||||||
let menuOpen = false;
|
let menuOpen = false;
|
||||||
let menuAnimating = false;
|
let menuAnimating = false;
|
||||||
|
|
||||||
@@ -599,48 +621,24 @@ clearBtn.addEventListener("click", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add button click event to update EXCLUDE file and run UpdateTargetList.sh
|
// Save configure
|
||||||
document.getElementById("save").addEventListener("click", async () => {
|
document.getElementById("save").addEventListener("click", async () => {
|
||||||
await readExcludeFile();
|
|
||||||
const deselectedApps = Array.from(appListContainer.querySelectorAll(".checkbox:not(:checked)"))
|
|
||||||
.map(checkbox => checkbox.closest(".card").querySelector(".content").getAttribute("data-package"));
|
|
||||||
const selectedApps = Array.from(appListContainer.querySelectorAll(".checkbox:checked"))
|
const selectedApps = Array.from(appListContainer.querySelectorAll(".checkbox:checked"))
|
||||||
.map(checkbox => checkbox.closest(".card").querySelector(".content").getAttribute("data-package"));
|
.map(checkbox => checkbox.closest(".card").querySelector(".content").getAttribute("data-package"));
|
||||||
// Add deselected apps to EXCLUDE list
|
let finalAppsList = new Set(selectedApps);
|
||||||
for (const packageName of deselectedApps) {
|
ADDITIONAL_APPS.forEach(app => {
|
||||||
if (!excludeList.includes(packageName)) {
|
finalAppsList.add(app);
|
||||||
excludeList.push(packageName);
|
});
|
||||||
console.log("Added to EXCLUDE list:", packageName);
|
finalAppsList = Array.from(finalAppsList);
|
||||||
} else {
|
|
||||||
console.log("Package already in EXCLUDE file, skipping:", packageName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remove selected apps from EXCLUDE list
|
|
||||||
if (selectedApps.length > 0) {
|
|
||||||
selectedApps.forEach(packageName => {
|
|
||||||
excludeList = excludeList.filter(excludedPackage => excludedPackage !== packageName);
|
|
||||||
console.log("Removed from EXCLUDE list:", packageName);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// Save the EXCLUDE file
|
const updatedTargetContent = finalAppsList.join("\n");
|
||||||
const updatedExcludeContent = excludeList.join("\n");
|
await execCommand(`echo "${updatedTargetContent}" > /data/adb/tricky_store/target.txt`);
|
||||||
await execCommand(`echo "${updatedExcludeContent}" > /data/adb/tricky_store/target_list_config/EXCLUDE`);
|
console.log("target.txt updated successfully.");
|
||||||
console.log("EXCLUDE file updated successfully.");
|
showPrompt("saved_target");
|
||||||
|
|
||||||
// Execute UpdateTargetList.sh
|
|
||||||
try {
|
|
||||||
await execCommand("/data/adb/tricky_store/UpdateTargetList.sh");
|
|
||||||
showPrompt("saved_and_updated");
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to update target list:", error);
|
|
||||||
showPrompt("saved_not_updated", false);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to update EXCLUDE file:", error);
|
console.error("Failed to update target.txt:", error);
|
||||||
showPrompt("save_error", false);
|
showPrompt("save_error", false);
|
||||||
}
|
}
|
||||||
await readExcludeFile();
|
|
||||||
await refreshAppList();
|
await refreshAppList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user