Merge pull request #503 from KOWX712/new_webui

Add action-on-webui support to old root manager.
This commit is contained in:
chiteroman 2024-12-28 15:40:44 +01:00 committed by GitHub
commit 51b38eab0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 89 additions and 0 deletions

View File

@ -65,3 +65,14 @@ if [ -f "/data/adb/pif.json" ]; then
ui_print "- Backup custom pif.json" ui_print "- Backup custom pif.json"
mv -f /data/adb/pif.json /data/adb/pif.json.old mv -f /data/adb/pif.json /data/adb/pif.json.old
fi fi
# give exec perm to action.sh
chmod +x "$MODPATH/action.sh"
# action.sh, ap 10927, ksu 11981
if { [ "$KSU" = "true" ] && [ "$KSU_VER_CODE" -ge 11981 ]; } ||
{ [ "$APATCH" = "true" ] && [ "$APATCH_VER_CODE" -ge 10927 ]; }; then
# we dont need the webui workaround
# since manager has action
rm -rf "$MODPATH/webroot"
fi

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;
}
}