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
opt: cache applist in json format
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
__MACOSX
|
__MACOSX
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
applist.json
|
||||||
@@ -78,7 +78,7 @@ if [ ! -d "$TS/webroot" ] && [ ! -L "$TS/webroot" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Optimization
|
# Optimization
|
||||||
OUTPUT_APP="$MODPATH/common/tmp/applist"
|
OUTPUT_APP="$MODPATH/webui/applist.json"
|
||||||
OUTPUT_SKIP="$MODPATH/common/tmp/skiplist"
|
OUTPUT_SKIP="$MODPATH/common/tmp/skiplist"
|
||||||
OUTPUT_XPOSED="$MODPATH/common/tmp/xposed"
|
OUTPUT_XPOSED="$MODPATH/common/tmp/xposed"
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialize cache files to save app list and skip list
|
# Initialize cache files to save app list and skip list
|
||||||
echo "# This file is generated from service.sh to speed up load time" > "$OUTPUT_APP"
|
echo "[" > "$OUTPUT_APP"
|
||||||
echo "# This file is generated from service.sh to speed up load time" > "$OUTPUT_SKIP"
|
echo "# This file is generated from service.sh to speed up load time" > "$OUTPUT_SKIP"
|
||||||
|
|
||||||
# Get list of third party apps and specific system apps, then cache app name
|
# Get list of third party apps and specific system apps, then cache app name
|
||||||
@@ -107,16 +107,12 @@ echo "# This file is generated from service.sh to speed up load time" > "$OUTPUT
|
|||||||
pm list packages -s | grep -E "$SYSTEM_APP" 2>/dev/null || true
|
pm list packages -s | grep -E "$SYSTEM_APP" 2>/dev/null || true
|
||||||
} | awk -F: '{print $2}' | while read -r PACKAGE; do
|
} | awk -F: '{print $2}' | while read -r PACKAGE; do
|
||||||
# Get APK path for the package
|
# Get APK path for the package
|
||||||
APK_PATH=$(pm path "$PACKAGE" 2>/dev/null | grep "base.apk" | awk -F: '{print $2}' | tr -d '\r')
|
APK_PATH=$(pm path "$PACKAGE" 2>/dev/null | grep "base.apk" | awk -F: '{print $2}')
|
||||||
[ -z "$APK_PATH" ] && APK_PATH=$(pm path "$PACKAGE" 2>/dev/null | grep ".apk" | awk -F: '{print $2}' | tr -d '\r')
|
[ -z "$APK_PATH" ] && APK_PATH=$(pm path "$PACKAGE" 2>/dev/null | grep ".apk" | awk -F: '{print $2}')
|
||||||
|
|
||||||
if [ -n "$APK_PATH" ]; then
|
APP_NAME=$(aapt dump badging "$APK_PATH" 2>/dev/null | grep "application-label:" | sed "s/application-label://g; s/'//g")
|
||||||
# Extract app name and save package info
|
[ -z "$APP_NAME" ] && APP_NAME="$PACKAGE"
|
||||||
APP_NAME=$(aapt dump badging "$APK_PATH" 2>/dev/null | grep "application-label:" | sed "s/application-label://g; s/'//g")
|
echo " {\"app_name\": \"$APP_NAME\", \"package_name\": \"$PACKAGE\"}," >> "$OUTPUT_APP"
|
||||||
echo "app-name: $APP_NAME, package-name: $PACKAGE" >> "$OUTPUT_APP"
|
|
||||||
else
|
|
||||||
echo "app-name: Unknown App package-name: $PACKAGE" >> "$OUTPUT_APP"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if app is Xposed module and add to skip list if not
|
# Check if app is Xposed module and add to skip list if not
|
||||||
touch "$OUTPUT_XPOSED"
|
touch "$OUTPUT_XPOSED"
|
||||||
@@ -126,3 +122,6 @@ echo "# This file is generated from service.sh to speed up load time" > "$OUTPUT
|
|||||||
echo "$PACKAGE" >> "$OUTPUT_SKIP"
|
echo "$PACKAGE" >> "$OUTPUT_SKIP"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
sed -i '$ s/,$//' "$OUTPUT_APP"
|
||||||
|
echo "]" >> "$OUTPUT_APP"
|
||||||
|
|||||||
@@ -105,29 +105,29 @@
|
|||||||
<div class="content" data-package="">
|
<div class="content" data-package="">
|
||||||
<div class="mode">
|
<div class="mode">
|
||||||
<label class="mode-switch" id="normal">
|
<label class="mode-switch" id="normal">
|
||||||
<input type="radio" class="mode-input" id="normal-mode">
|
<input type="radio" class="mode-input" id="normal-mode">
|
||||||
<i class="mode-icon">
|
<i class="mode-icon">
|
||||||
<div class="status-indicator ripple-element" id="normal-indicator">
|
<div class="status-indicator ripple-element" id="normal-indicator">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#ffffff"><path d="M480-480Zm0 280q-116 0-198-82t-82-198q0-116 82-198t198-82q116 0 198 82t82 198q0 116-82 198t-198 82Zm0-80q83 0 141.5-58.5T680-480q0-83-58.5-141.5T480-680q-83 0-141.5 58.5T280-480q0 83 58.5 141.5T480-280Z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#ffffff"><path d="M480-480Zm0 280q-116 0-198-82t-82-198q0-116 82-198t198-82q116 0 198 82t82 198q0 116-82 198t-198 82Zm0-80q83 0 141.5-58.5T680-480q0-83-58.5-141.5T480-680q-83 0-141.5 58.5T280-480q0 83 58.5 141.5T480-280Z"/></svg>
|
||||||
</div>
|
</div>
|
||||||
</i>
|
</i>
|
||||||
</label>
|
</label>
|
||||||
<label class="mode-switch" id="generate">
|
<label class="mode-switch" id="generate">
|
||||||
<input type="radio" class="mode-input" id="generate-mode">
|
<input type="radio" class="mode-input" id="generate-mode">
|
||||||
<i class="mode-icon">
|
<i class="mode-icon">
|
||||||
<div class="status-indicator ripple-element" id="generate-indicator">
|
<div class="status-indicator ripple-element" id="generate-indicator">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 -960 960 960" width="18px" fill="#ffffff"><path d="M480-120q-33 0-56.5-23.5T400-200q0-33 23.5-56.5T480-280q33 0 56.5 23.5T560-200q0 33-23.5 56.5T480-120Zm-80-240v-480h160v480H400Z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 -960 960 960" width="18px" fill="#ffffff"><path d="M480-120q-33 0-56.5-23.5T400-200q0-33 23.5-56.5T480-280q33 0 56.5 23.5T560-200q0 33-23.5 56.5T480-120Zm-80-240v-480h160v480H400Z"/></svg>
|
||||||
</div>
|
</div>
|
||||||
</i>
|
</i>
|
||||||
</label>
|
</label>
|
||||||
<label class="mode-switch" id="hack">
|
<label class="mode-switch" id="hack">
|
||||||
<input type="radio" class="mode-input" id="hack-mode">
|
<input type="radio" class="mode-input" id="hack-mode">
|
||||||
<i class="mode-icon">
|
<i class="mode-icon">
|
||||||
<div class="status-indicator ripple-element" id="hack-indicator">
|
<div class="status-indicator ripple-element" id="hack-indicator">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="19px" viewBox="0 -960 960 960" width="19px" fill="#ffffff"><path d="M424-320q0-81 14.5-116.5T500-514q41-36 62.5-62.5T584-637q0-41-27.5-68T480-732q-51 0-77.5 31T365-638l-103-44q21-64 77-111t141-47q105 0 161.5 58.5T698-641q0 50-21.5 85.5T609-475q-49 47-59.5 71.5T539-320H424Zm56 240q-33 0-56.5-23.5T400-160q0-33 23.5-56.5T480-240q33 0 56.5 23.5T560-160q0 33-23.5 56.5T480-80Z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" height="19px" viewBox="0 -960 960 960" width="19px" fill="#ffffff"><path d="M424-320q0-81 14.5-116.5T500-514q41-36 62.5-62.5T584-637q0-41-27.5-68T480-732q-51 0-77.5 31T365-638l-103-44q21-64 77-111t141-47q105 0 161.5 58.5T698-641q0 50-21.5 85.5T609-475q-49 47-59.5 71.5T539-320H424Zm56 240q-33 0-56.5-23.5T400-160q0-33 23.5-56.5T480-240q33 0 56.5 23.5T560-160q0 33-23.5 56.5T480-80Z"/></svg>
|
||||||
</div>
|
</div>
|
||||||
</i>
|
</i>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<p class="name"></p>
|
<p class="name"></p>
|
||||||
<div class="checkbox-wrapper">
|
<div class="checkbox-wrapper">
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export let modeActive = false;
|
|||||||
// Fetch and render applist
|
// Fetch and render applist
|
||||||
export async function fetchAppList() {
|
export async function fetchAppList() {
|
||||||
try {
|
try {
|
||||||
|
// fetch target list
|
||||||
let targetList = [];
|
let targetList = [];
|
||||||
try {
|
try {
|
||||||
const targetFileContent = await execCommand('cat /data/adb/tricky_store/target.txt');
|
const targetFileContent = await execCommand('cat /data/adb/tricky_store/target.txt');
|
||||||
@@ -19,56 +20,46 @@ export async function fetchAppList() {
|
|||||||
console.error("Failed to read target.txt file:", error);
|
console.error("Failed to read target.txt file:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fetch applist
|
||||||
let applistMap = {};
|
let applistMap = {};
|
||||||
try {
|
const response = await fetch('applist.json');
|
||||||
const applistResult = await execCommand(`cat ${basePath}common/tmp/applist`);
|
const appList = await response.json();
|
||||||
applistMap = applistResult
|
const appNameMap = appList.reduce((map, app) => {
|
||||||
.split("\n")
|
map[app.package_name] = app.app_name;
|
||||||
.reduce((map, line) => {
|
return map;
|
||||||
const match = line.match(/app-name:\s*(.+),\s*package-name:\s*(.+)/);
|
}, {});
|
||||||
if (match) {
|
|
||||||
const appName = match[1].trim();
|
|
||||||
const packageName = match[2].trim();
|
|
||||||
map[packageName] = appName;
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}, {});
|
|
||||||
console.log("Applist loaded successfully.");
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Applist file not found or could not be loaded. Skipping applist lookup.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await execCommand(`
|
// Get installed packages first
|
||||||
pm list packages -3 | awk -F: '{print $2}'
|
let appEntries = [], installedPackages = [];
|
||||||
[ -f "/data/adb/tricky_store/system_app" ] && SYSTEM_APP=$(cat "/data/adb/tricky_store/system_app" | tr '\n' '|' | sed 's/|*$//') || SYSTEM_APP=""
|
try {
|
||||||
pm list packages -s | awk -F: '{print $2}' | grep -Ex "$SYSTEM_APP" 2>/dev/null || true
|
installedPackages = await execCommand(`
|
||||||
`);
|
pm list packages -3 | awk -F: '{print $2}'
|
||||||
const appEntries = result
|
[ -s "/data/adb/tricky_store/system_app" ] && SYSTEM_APP=$(cat "/data/adb/tricky_store/system_app" | tr '\n' '|' | sed 's/|*$//') || SYSTEM_APP=""
|
||||||
.split("\n")
|
[ -z "$SYSTEM_APP" ] || pm list packages -s | awk -F: '{print $2}' | grep -Ex "$SYSTEM_APP" 2>/dev/null || true
|
||||||
.map(line => {
|
`)
|
||||||
const packageName = line.trim();
|
installedPackages = installedPackages.split("\n").map(line => line.trim()).filter(Boolean);
|
||||||
const appName = applistMap[packageName] || null;
|
appEntries = await Promise.all(installedPackages.map(async packageName => {
|
||||||
return { appName, packageName };
|
if (appNameMap[packageName]) {
|
||||||
})
|
return {
|
||||||
.filter(entry => entry.packageName);
|
appName: appNameMap[packageName],
|
||||||
for (const entry of appEntries) {
|
packageName
|
||||||
if (!entry.appName) {
|
};
|
||||||
try {
|
|
||||||
const apkPath = await execCommand(`
|
|
||||||
base_apk=$(pm path ${entry.packageName} | grep "base.apk" | awk -F: '{print $2}' | tr -d '\\r')
|
|
||||||
[ -n "$base_apk" ] || base_apk=$(pm path ${entry.packageName} | grep ".apk" | awk -F: '{print $2}' | tr -d '\\r')
|
|
||||||
echo "$base_apk"
|
|
||||||
`);
|
|
||||||
if (apkPath) {
|
|
||||||
const appName = await execCommand(`${basePath}common/aapt dump badging ${apkPath.trim()} 2>/dev/null | grep "application-label:" | sed "s/application-label://; s/'//g"`);
|
|
||||||
entry.appName = appName.trim() || "Unknown App";
|
|
||||||
} else {
|
|
||||||
entry.appName = "Unknown App";
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
entry.appName = "Unknown App";
|
|
||||||
}
|
}
|
||||||
}
|
const appName = await execCommand(`
|
||||||
|
base_apk=$(pm path ${packageName} | grep "base.apk" | awk -F: '{print $2}')
|
||||||
|
[ -n "$base_apk" ] || base_apk=$(pm path ${packageName} | grep ".apk" | awk -F: '{print $2}')
|
||||||
|
${basePath}common/aapt dump badging $base_apk 2>/dev/null | grep "application-label:" | sed "s/application-label://; s/'//g"
|
||||||
|
`);
|
||||||
|
return {
|
||||||
|
appName: appName.trim() || packageName,
|
||||||
|
packageName
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
appEntries = appList.map(app => ({
|
||||||
|
appName: app.app_name,
|
||||||
|
packageName: app.package_name
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
@@ -108,7 +99,12 @@ export async function fetchAppList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nameElement = appElement.querySelector(".name");
|
const nameElement = appElement.querySelector(".name");
|
||||||
nameElement.innerHTML = `<strong>${appName || "Unknown App"}</strong><br>${packageName}`;
|
nameElement.innerHTML = `
|
||||||
|
<div class="app-info">
|
||||||
|
<div class="app-name"><strong>${appName}</strong></div>
|
||||||
|
<div class="package-name">${packageName}</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
const checkbox = appElement.querySelector(".checkbox");
|
const checkbox = appElement.querySelector(".checkbox");
|
||||||
checkbox.checked = targetList.includes(packageName);
|
checkbox.checked = targetList.includes(packageName);
|
||||||
appListContainer.appendChild(appElement);
|
appListContainer.appendChild(appElement);
|
||||||
|
|||||||
Reference in New Issue
Block a user