From fcfa723052924cf27769c197289623757959fa68 Mon Sep 17 00:00:00 2001 From: KOWX712 Date: Sat, 9 Nov 2024 03:22:48 +0800 Subject: [PATCH] better logic now can show app that excluded by keyword as deselected. --- module/common/EXCLUDE | 1 + module/webroot/index.js | 15 ++++++++++++--- more-excldue.json | 13 +++++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/module/common/EXCLUDE b/module/common/EXCLUDE index 6196bc6..623dd5b 100644 --- a/module/common/EXCLUDE +++ b/module/common/EXCLUDE @@ -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 diff --git a/module/webroot/index.js b/module/webroot/index.js index 132fcaa..aad56a6 100644 --- a/module/webroot/index.js +++ b/module/webroot/index.js @@ -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 &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)'; } diff --git a/more-excldue.json b/more-excldue.json index debe252..acdda1a 100644 --- a/more-excldue.json +++ b/more-excldue.json @@ -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": "" + } + ] } ] } \ No newline at end of file