MCPcopy
hub / github.com/KOWX712/Tricky-Addon-Update-Target-List / setupSystemAppMenu

Function setupSystemAppMenu

webui/scripts/menu_option.js:83–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81
82// Function to add system app
83export async function setupSystemAppMenu() {
84 const dialog = document.getElementById('add-system-app-dialog');
85 document.getElementById("add-system-app").onclick = () => {
86 renderSystemAppList();
87 dialog.show();
88 }
89
90 // Add system app button
91 document.getElementById("add-system-app-button").onclick = async () => {
92 const input = document.getElementById("system-app-input");
93 const packageName = input.value.trim();
94 if (packageName) {
95 exec(`pm list packages -s | grep -q ${packageName}`)
96 .then(({ errno }) => {
97 if (errno !== 0) {
98 showPrompt(getString("prompt_system_app_not_found"), false);
99 } else {
100 exec(`
101 touch "/data/adb/tricky_store/system_app"
102 echo "${packageName}" >> "/data/adb/tricky_store/system_app"
103 echo "${packageName}" >> "/data/adb/tricky_store/target.txt"
104 `)
105 input.value = "";
106 dialog.close();
107 refreshAppList();
108 }
109 });
110 }
111 }
112
113 document.getElementById('cancel-add-system-app').onclick = () => dialog.close();
114
115 // Display current system app list and remove button
116 async function renderSystemAppList() {
117 const systemAppList = document.querySelector(".current-system-app-list");
118 const systemAppListContent = document.querySelector(".current-system-app-list-content");
119 systemAppListContent.innerHTML = "";
120 const { errno, stdout } = await exec(`[ -f "/data/adb/tricky_store/system_app" ] && cat "/data/adb/tricky_store/system_app" | sed '/^#/d; /^$/d'`);
121 if (errno !== 0 || stdout.trim() === "") {
122 systemAppList.style.display = "none";
123 } else {
124 stdout.split("\n").forEach(app => {
125 if (app.trim() !== "") {
126 systemAppListContent.innerHTML += `
127 <div class="system-app-item">
128 <span>${app}</span>
129 <md-filled-icon-button class="remove-system-app-button">
130 <md-icon>delete</md-icon>
131 </md-filled-icon-button>
132 </div>
133 `;
134 }
135 });
136 }
137
138 // Remove button listener
139 document.querySelectorAll(".remove-system-app-button").forEach(button => {
140 button.onclick = () => {

Callers 1

main.jsFile · 0.90

Calls 4

showPromptFunction · 0.90
getStringFunction · 0.90
refreshAppListFunction · 0.90
renderSystemAppListFunction · 0.85

Tested by

no test coverage detected