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
@@ -1,4 +1,4 @@
|
||||
import { basePath, execCommand, floatingBtn } from './main.js';
|
||||
import { basePath, execCommand, floatingBtn, appsWithExclamation, appsWithQuestion } from './main.js';
|
||||
|
||||
const appTemplate = document.getElementById('app-template').content;
|
||||
export const appListContainer = document.getElementById('apps-list');
|
||||
@@ -10,7 +10,7 @@ export async function fetchAppList() {
|
||||
let targetList = [];
|
||||
try {
|
||||
const targetFileContent = await execCommand('cat /data/adb/tricky_store/target.txt');
|
||||
targetList = targetFileContent.split("\n").filter(app => app.trim() !== ''); // Filter out empty lines
|
||||
targetList = processTargetList(targetFileContent);
|
||||
console.log("Current target list:", targetList);
|
||||
} catch (error) {
|
||||
console.error("Failed to read target.txt file:", error);
|
||||
@@ -93,6 +93,25 @@ export async function fetchAppList() {
|
||||
}
|
||||
}
|
||||
|
||||
// Function to save app with ! and ? then process target list
|
||||
function processTargetList(targetFileContent) {
|
||||
appsWithExclamation.length = 0;
|
||||
appsWithQuestion.length = 0;
|
||||
const targetList = targetFileContent
|
||||
.split("\n")
|
||||
.map(app => {
|
||||
const trimmedApp = app.trim();
|
||||
if (trimmedApp.endsWith('!')) {
|
||||
appsWithExclamation.push(trimmedApp.slice(0, -1));
|
||||
} else if (trimmedApp.endsWith('?')) {
|
||||
appsWithQuestion.push(trimmedApp.slice(0, -1));
|
||||
}
|
||||
return trimmedApp.replace(/[!?]/g, '');
|
||||
})
|
||||
.filter(app => app.trim() !== '');
|
||||
return targetList;
|
||||
}
|
||||
|
||||
// Make checkboxes toggleable
|
||||
function toggleableCheckbox() {
|
||||
const appElements = appListContainer.querySelectorAll(".card");
|
||||
|
||||
@@ -20,12 +20,9 @@ const prompt = document.getElementById('prompt');
|
||||
export const floatingBtn = document.querySelector('.floating-btn');
|
||||
|
||||
export const basePath = "set-path";
|
||||
const ADDITIONAL_APPS = [
|
||||
"com.google.android.gms",
|
||||
"io.github.vvb2060.keyattestation",
|
||||
"io.github.vvb2060.mahoshojo",
|
||||
"icu.nullptr.nativetest"
|
||||
];
|
||||
export const appsWithExclamation = [];
|
||||
export const appsWithQuestion = [];
|
||||
const ADDITIONAL_APPS = [ "com.google.android.gms", "io.github.vvb2060.keyattestation", "io.github.vvb2060.mahoshojo", "icu.nullptr.nativetest" ];
|
||||
|
||||
// Variables
|
||||
let e = 0;
|
||||
@@ -112,7 +109,7 @@ export function showPrompt(key, isSuccess = true) {
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// Save configure
|
||||
// Save configure and preserve ! and ? in target.txt
|
||||
document.getElementById("save").addEventListener("click", async () => {
|
||||
const selectedApps = Array.from(appListContainer.querySelectorAll(".checkbox:checked"))
|
||||
.map(checkbox => checkbox.closest(".card").querySelector(".content").getAttribute("data-package"));
|
||||
@@ -122,10 +119,25 @@ document.getElementById("save").addEventListener("click", async () => {
|
||||
});
|
||||
finalAppsList = Array.from(finalAppsList);
|
||||
try {
|
||||
const updatedTargetContent = finalAppsList.join("\n");
|
||||
const modifiedAppsList = finalAppsList.map(app => {
|
||||
if (appsWithExclamation.includes(app)) {
|
||||
return `${app}!`;
|
||||
} else if (appsWithQuestion.includes(app)) {
|
||||
return `${app}?`;
|
||||
}
|
||||
return app;
|
||||
});
|
||||
const updatedTargetContent = modifiedAppsList.join("\n");
|
||||
await execCommand(`echo "${updatedTargetContent}" > /data/adb/tricky_store/target.txt`);
|
||||
console.log("target.txt updated successfully.");
|
||||
showPrompt("prompt.saved_target");
|
||||
for (const app of appsWithExclamation) {
|
||||
await execCommand(`sed -i 's/^${app}$/${app}!/' /data/adb/tricky_store/target.txt`);
|
||||
}
|
||||
for (const app of appsWithQuestion) {
|
||||
await execCommand(`sed -i 's/^${app}$/${app}?/' /data/adb/tricky_store/target.txt`);
|
||||
}
|
||||
console.log("App names modified in target.txt.");
|
||||
} catch (error) {
|
||||
console.error("Failed to update target.txt:", error);
|
||||
showPrompt("prompt.save_error", false);
|
||||
|
||||
Reference in New Issue
Block a user