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: move valid kb download operation to JS
This commit is contained in:
@@ -3,7 +3,6 @@ MODPATH=${0%/*}
|
|||||||
ORG_PATH="$PATH"
|
ORG_PATH="$PATH"
|
||||||
SKIPLIST="$MODPATH/tmp/skiplist"
|
SKIPLIST="$MODPATH/tmp/skiplist"
|
||||||
OUTPUT="$MODPATH/tmp/exclude-list"
|
OUTPUT="$MODPATH/tmp/exclude-list"
|
||||||
KBOUTPUT="$MODPATH/tmp/.extra"
|
|
||||||
|
|
||||||
if [ "$MODPATH" = "/data/adb/modules/.TA_utl/common" ]; then
|
if [ "$MODPATH" = "/data/adb/modules/.TA_utl/common" ]; then
|
||||||
MODDIR="/data/adb/modules/.TA_utl"
|
MODDIR="/data/adb/modules/.TA_utl"
|
||||||
@@ -39,11 +38,6 @@ download() {
|
|||||||
PATH="$ORG_PATH"
|
PATH="$ORG_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_kb() {
|
|
||||||
download --output "https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/main/.extra" "$KBOUTPUT"
|
|
||||||
[ -s "$KBOUTPUT" ] || rm -f "$KBOUTPUT"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_xposed() {
|
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" | grep -vxF -f "$OUTPUT" | while read -r PACKAGE; do
|
||||||
APK_PATH=$(pm path "$PACKAGE" | grep "base.apk" | cut -d':' -f2 | tr -d '\r')
|
APK_PATH=$(pm path "$PACKAGE" | grep "base.apk" | cut -d':' -f2 | tr -d '\r')
|
||||||
@@ -152,10 +146,6 @@ get_latest_security_patch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--kb)
|
|
||||||
get_kb
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
--unnecessary)
|
--unnecessary)
|
||||||
get_unnecessary
|
get_unnecessary
|
||||||
exit
|
exit
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ document.getElementById("deselect-unnecessary").addEventListener("click", async
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Function to backup previous keybox and set new keybox
|
// Function to backup previous keybox and set new keybox
|
||||||
async function setKeybox(path) {
|
async function setKeybox(content) {
|
||||||
try {
|
try {
|
||||||
await execCommand(`
|
await execCommand(`
|
||||||
mv -f /data/adb/tricky_store/keybox.xml /data/adb/tricky_store/keybox.xml.bak 2>/dev/null
|
mv -f /data/adb/tricky_store/keybox.xml /data/adb/tricky_store/keybox.xml.bak 2>/dev/null
|
||||||
echo '${path}' > /data/adb/tricky_store/keybox.xml
|
echo '${content}' > /data/adb/tricky_store/keybox.xml
|
||||||
chmod 644 /data/adb/tricky_store/keybox.xml
|
chmod 644 /data/adb/tricky_store/keybox.xml
|
||||||
`);
|
`);
|
||||||
return true;
|
return true;
|
||||||
@@ -100,27 +100,36 @@ export async function aospkb() {
|
|||||||
|
|
||||||
// Function to replace valid kb
|
// Function to replace valid kb
|
||||||
document.getElementById("validkb").addEventListener("click", async () => {
|
document.getElementById("validkb").addEventListener("click", async () => {
|
||||||
setTimeout(async () => {
|
fetch("https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/main/.extra")
|
||||||
await execCommand(`sh ${basePath}common/get_extra.sh --kb`);
|
.then(response => {
|
||||||
}, 100);
|
if (!response.ok) {
|
||||||
const sourcePath = `${basePath}common/tmp/.extra`;
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
await new Promise(resolve => setTimeout(resolve, 300));
|
|
||||||
const fileExists = await execCommand(`[ -f ${sourcePath} ] && echo "exists"`);
|
|
||||||
try {
|
|
||||||
if (fileExists.trim() !== "exists") {
|
|
||||||
throw new Error(".extra file not found");
|
|
||||||
}
|
}
|
||||||
const source = await execCommand(`xxd -r -p ${sourcePath} | base64 -d`);
|
return response.text();
|
||||||
const result = await setKeybox(source);
|
})
|
||||||
if (result) {
|
.then(async data => {
|
||||||
showPrompt("prompt.valid_key_set");
|
if (!data.trim()) {
|
||||||
} else {
|
await aospkb();
|
||||||
throw new Error("Failed to copy valid keybox");
|
showPrompt("prompt.no_valid_fallback", false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
try {
|
||||||
await aospkb();
|
const hexBytes = new Uint8Array(data.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
||||||
showPrompt("prompt.no_valid_fallback", false);
|
const decodedHex = new TextDecoder().decode(hexBytes);
|
||||||
}
|
const source = atob(decodedHex);
|
||||||
|
const result = await setKeybox(source);
|
||||||
|
if (result) {
|
||||||
|
showPrompt("prompt.valid_key_set");
|
||||||
|
} else {
|
||||||
|
throw new Error("Failed to copy valid keybox");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error("Failed to decode keybox data");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(async error => {
|
||||||
|
showPrompt("prompt.no_internet", false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add file selector dialog elements dynamically
|
// Add file selector dialog elements dynamically
|
||||||
|
|||||||
Reference in New Issue
Block a user