better logic

now can show app that excluded by keyword as deselected.
This commit is contained in:
KOWX712
2024-11-09 03:22:48 +08:00
parent c347392792
commit fcfa723052
3 changed files with 24 additions and 5 deletions

View File

@@ -4,6 +4,7 @@
# Each app package name should be on a new line
oneplus
coloros
miui
com.android.patch
me.bmax.apatch
me.garfieldhan.apatch.next

View File

@@ -44,29 +44,38 @@ async function readExcludeFile() {
}
}
// 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
async function fetchAppList() {
try {
await readExcludeFile();
const result = await execCommand("pm list packages -3 </dev/null 2>&1 | cat");
const packageList = result.split("\n").map(line => line.replace("package:", "").trim()).filter(Boolean);
const sortedApps = packageList.sort((a, b) => {
const aInExclude = excludeList.includes(a);
const bInExclude = excludeList.includes(b);
const aInExclude = isExcluded(a);
const bInExclude = isExcluded(b);
return aInExclude === bInExclude ? a.localeCompare(b) : aInExclude ? 1 : -1;
});
appListContainer.innerHTML = "";
sortedApps.forEach(appName => {
const appElement = document.importNode(appTemplate, true);
appElement.querySelector(".name").textContent = appName;
const checkbox = appElement.querySelector(".checkbox");
checkbox.checked = !excludeList.includes(appName);
checkbox.checked = !isExcluded(appName);
appListContainer.appendChild(appElement);
});
console.log("App list fetched, sorted, and rendered successfully.");
} catch (error) {
console.error("Failed to fetch or render app list:", error);
}
floatingBtn.style.transform = 'translateY(-100px)';
}

View File

@@ -2,7 +2,7 @@
"description": "Extra exclude option for root related apps",
"data": [
{
"info": "Root Manager",
"info": "Root manager",
"apps": [
{
"name": "Magisk",
@@ -31,7 +31,7 @@
]
},
{
"info": "Miscellaneous Root Related App",
"info": "Root related app that won't detect bootloader",
"apps": [
{
"name": "LSPosed Manager",
@@ -58,6 +58,15 @@
"package-name": "com.omarea.vtools"
}
]
},
{
"info": "General app that won't detect bootloader",
"apps": [
{
"name": "",
"package-name": ""
}
]
}
]
}