Add action-on-webui

Add `action-on-webui` support to old version KernelSU and Apatch users. Old version Magisk users are able to use KSUWebUIStandalone to run `action.sh` through WebUI.
This commit is contained in:
KOWX712 2024-12-26 12:56:19 +08:00
parent 5f552802b4
commit 420ebda8bc
4 changed files with 78 additions and 0 deletions

Binary file not shown.

14
module/webroot/index.html Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Play Integrity Fix</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<link rel="stylesheet" type="text/css" href="/mmrl/insets.css" />
<script type="module" crossorigin src="scripts.js"></script>
</head>
<body>
<div class="output">[+] Fetching pif.json, please wait...</div>
</body>
</html>

37
module/webroot/scripts.js Normal file
View File

@ -0,0 +1,37 @@
// Execute shell commands with ksu.exec
async function execCommand(command) {
const callbackName = `exec_callback_${Date.now()}`;
return new Promise((resolve, reject) => {
window[callbackName] = (errno, stdout, stderr) => {
delete window[callbackName];
errno === 0 ? resolve(stdout) : reject(stderr);
};
ksu.exec(command, "{}", callbackName);
});
}
// Function to run the script and display its output
async function runAction() {
const output = document.querySelector('.output');
try {
const scriptOutput = await execCommand("sh /data/adb/modules/playintegrityfix/action.sh");
output.innerHTML = '';
const lines = scriptOutput.split('\n');
lines.forEach(line => {
const lineElement = document.createElement('div');
lineElement.style.whiteSpace = 'pre-wrap';
lineElement.textContent = line;
if (line === '') {
lineElement.innerHTML = '&nbsp;';
}
output.appendChild(lineElement);
});
} catch (error) {
output.innerHTML = '[!] Error: Fail to execute action.sh';
console.error('Script execution failed:', error);
}
}
document.addEventListener('DOMContentLoaded', async () => {
setTimeout(runAction, 200);
});

27
module/webroot/styles.css Normal file
View File

@ -0,0 +1,27 @@
@font-face {
font-family: 'Mono';
src: url('assets/RobotoMono-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
body {
font-family: 'Mono';
padding-top: var(--window-inset-top);
padding-bottom: var(--window-inset-bottom);
}
.output {
font-size: 14px;
left: 10px;
width: calc(100vw - 20px);
white-space: nowrap;
word-break: break-all;
}
@media (prefers-color-scheme: dark) {
body {
background-color: #121212;
color: #fff;
}
}