opt: move unnecessary list download to JS

This commit is contained in:
KOWX712
2025-02-22 19:17:53 +08:00
parent 7424ed325a
commit 410629fad5
2 changed files with 30 additions and 27 deletions

View File

@@ -2,7 +2,6 @@
MODPATH=${0%/*}
ORG_PATH="$PATH"
SKIPLIST="$MODPATH/tmp/skiplist"
OUTPUT="$MODPATH/tmp/exclude-list"
if [ "$MODPATH" = "/data/adb/modules/.TA_utl/common" ]; then
MODDIR="/data/adb/modules/.TA_utl"
@@ -39,24 +38,16 @@ download() {
}
get_xposed() {
pm list packages -3 | cut -d':' -f2 | grep -vxF -f "$SKIPLIST" | grep -vxF -f "$OUTPUT" | while read -r PACKAGE; do
pm list packages -3 | cut -d':' -f2 | grep -vxF -f "$SKIPLIST" | while read -r PACKAGE; do
APK_PATH=$(pm path "$PACKAGE" | grep "base.apk" | cut -d':' -f2 | tr -d '\r')
if [ -n "$APK_PATH" ]; then
if aapt dump xmltree "$APK_PATH" AndroidManifest.xml 2>/dev/null | grep -qE "xposed.category|xposeddescription"; then
echo "$PACKAGE" >>"$OUTPUT"
echo "$PACKAGE"
fi
fi
done
}
get_unnecessary() {
if [ ! -s "$OUTPUT" ] || [ ! -f "$OUTPUT" ]; then
JSON=$(download --fetch "https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/main/more-exclude.json") || exit 1
echo "$JSON" | grep -o '"package-name": *"[^"]*"' | awk -F'"' '{print $4}' >"$OUTPUT"
fi
get_xposed
}
check_update() {
[ -f "$MODDIR/disable" ] && rm -f "$MODDIR/disable"
LOCAL_VERSION=$(grep '^versionCode=' "$MODPATH/update/module.prop" | awk -F= '{print $2}')
@@ -146,10 +137,6 @@ get_latest_security_patch() {
}
case "$1" in
--unnecessary)
get_unnecessary
exit
;;
--xposed)
get_xposed
exit

View File

@@ -40,17 +40,33 @@ document.getElementById("select-denylist").addEventListener("click", async () =>
// Function to read the exclude list and uncheck corresponding apps
document.getElementById("deselect-unnecessary").addEventListener("click", async () => {
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.");
const fileCheck = await execCommand(`[ -f ${basePath}common/tmp/exclude-list ] || echo "false"`);
if (fileCheck.trim() === "false") {
fetch("https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/main/more-exclude.json")
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
const excludeList = data.data
.flatMap(category => category.apps)
.map(app => app['package-name'])
.join('\n');
return excludeList;
})
.then(async excludeList => {
await execCommand(`
echo "${excludeList}" > ${basePath}common/tmp/exclude-list
sh ${basePath}common/get_extra.sh --xposed
`);
})
.catch(error => {
toast("Failed to download unnecessary apps!");
});
} else {
setTimeout(async () => {
await execCommand(`sh ${basePath}common/get_extra.sh --xposed`);
}, 0);
console.log("Exclude list found. Running xposed script.");
await execCommand(`sh ${basePath}common/get_extra.sh --xposed`);
}
await new Promise(resolve => setTimeout(resolve, 100));
const result = await execCommand(`cat ${basePath}common/tmp/exclude-list`);
@@ -66,8 +82,8 @@ document.getElementById("deselect-unnecessary").addEventListener("click", async
});
console.log("Unnecessary apps deselected successfully.");
} catch (error) {
toast("Failed!");
console.error("Failed to deselect unnecessary apps:", error);
toast("Failed to get unnecessary apps!");
console.error("Failed to get unnecessary apps:", error);
}
});