diff --git a/module/common/get_denylist.sh b/module/common/get_denylist.sh new file mode 100644 index 0000000..6083a49 --- /dev/null +++ b/module/common/get_denylist.sh @@ -0,0 +1,20 @@ +#!/system/bin/sh + +if [ -f "/data/adb/apd" ] || [ -f "/data/adb/ksud" ]; then + exit 1 +fi + +MODPATH=${0%/*} +OUTPUT="$MODPATH/denylist" + +# Get Magisk denylist +magisk --denylist ls 2>/dev/null | \ +awk -F'|' '{print $1}' | \ +grep -v "isolated" | \ +sort | uniq > "$OUTPUT" + +# Check if the output file is successfully created +if [ ! -s "$OUTPUT" ]; then + echo "Failed to retrieve Magisk denylist or no packages found." > "$OUTPUT" + exit 1 +fi \ No newline at end of file diff --git a/module/install_func.sh b/module/install_func.sh index 8aa740c..d38257e 100644 --- a/module/install_func.sh +++ b/module/install_func.sh @@ -15,6 +15,7 @@ initialize() { } set_perm $SCRIPT_DIR/UpdateTargetList.sh 0 2000 0755 + set_perm $COMPATH/get_denylist.sh 0 2000 0755 set_perm $COMPATH/get_exclude-list.sh 0 2000 0755 set_perm $COMPATH/get_WebUI.sh 0 2000 0755 diff --git a/module/webroot/index.html b/module/webroot/index.html index 4835fb1..8f38691 100644 --- a/module/webroot/index.html +++ b/module/webroot/index.html @@ -42,6 +42,12 @@

  • +
  • Select From DenyList + +
  • Deselect Unnecessary diff --git a/module/webroot/index.js b/module/webroot/index.js index 05e6ca3..578ea95 100644 --- a/module/webroot/index.js +++ b/module/webroot/index.js @@ -12,6 +12,7 @@ const helpOverlay = document.getElementById("help-overlay"); const closeHelp = document.getElementById("close-help"); const searchCard = document.querySelector('.search-card'); const menu = document.querySelector('.menu'); +const selectDenylistElement = document.getElementById("select-denylist"); const floatingBtn = document.querySelector('.floating-btn'); const basePath = "set-path"; let excludeList = []; @@ -50,6 +51,11 @@ async function readExcludeFile() { } } +// 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 async function fetchAppList() { try { @@ -57,8 +63,8 @@ async function fetchAppList() { 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 = ""; @@ -66,7 +72,7 @@ async function fetchAppList() { 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."); @@ -76,6 +82,7 @@ async function fetchAppList() { floatingBtn.style.transform = 'translateY(-100px)'; } + // Function to refresh app list async function refreshAppList() { isRefreshing = true; @@ -105,7 +112,7 @@ async function runXposedScript() { noConnection.style.display = "none"; } catch (error) { console.error("Failed to execute Xposed script:", error); - showPrompt("Please check your Internet connection", false); + showPrompt("Please check your Internet connection", false); noConnection.style.display = "flex"; } } @@ -129,6 +136,40 @@ async function deselectXposedApps() { } } +// Function to run the Denylist script +async function runDenylistScript() { + try { + const denylistScriptPath = `${basePath}get_denylist.sh`; + await execCommand(denylistScriptPath); + console.log('Denylist element displayed successfully.'); + selectDenylistElement.style.display = "flex"; + } catch (error) { + console.error("Failed to execute Denylist script:", error); + } +} + +// Function to read the denylist and check corresponding apps +async function selectDenylistApps() { + try { + const result = await execCommand(`cat ${basePath}denylist`); + const denylistApps = result.split("\n") + .map(app => app.trim()) + .filter(Boolean); + const apps = document.querySelectorAll(".card"); + apps.forEach(app => { + const appName = app.querySelector(".name").textContent.trim(); + const checkbox = app.querySelector(".checkbox"); + if (denylistApps.includes(appName)) { + 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 select all visible apps function selectAllApps() { document.querySelectorAll(".card").forEach(card => { @@ -195,7 +236,7 @@ function setupMenuToggle() { } }); - const closeMenuItems = ['refresh', 'select-all', 'deselect-all', 'deselect-xposed']; + const closeMenuItems = ['refresh', 'select-all', 'deselect-all', 'select-denylist', 'deselect-xposed']; closeMenuItems.forEach(id => { const item = document.getElementById(id); if (item) { @@ -319,8 +360,10 @@ document.addEventListener('DOMContentLoaded', async () => { document.getElementById("refresh").addEventListener("click", refreshAppList); document.getElementById("select-all").addEventListener("click", selectAllApps); document.getElementById("deselect-all").addEventListener("click", deselectAllApps); - document.getElementById("deselect-xposed").addEventListener("click", deselectXposedApps); + document.getElementById("select-denylist").addEventListener("click", selectDenylistApps); + document.getElementById("deselect-xposed").addEventListener("click", deselectXposedApps); await fetchAppList(); + runDenylistScript(); runXposedScript(); loadingIndicator.style.display = "none"; }); diff --git a/module/webroot/styles.css b/module/webroot/styles.css index 0d9a088..90e7d76 100644 --- a/module/webroot/styles.css +++ b/module/webroot/styles.css @@ -236,6 +236,10 @@ body { white-space: nowrap; } +#select-denylist { + display: none; +} + .menu-options.visible { display: block; transform: translateX(0);