Skip to content

Commit

Permalink
Merge pull request #503 from KOWX712/new_webui
Browse files Browse the repository at this point in the history
Add action-on-webui support to old root manager.
  • Loading branch information
chiteroman authored Dec 28, 2024
2 parents 5f55280 + 419c077 commit 51b38ea
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
11 changes: 11 additions & 0 deletions module/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,14 @@ if [ -f "/data/adb/pif.json" ]; then
ui_print "- Backup custom pif.json"
mv -f /data/adb/pif.json /data/adb/pif.json.old
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 added module/webroot/assets/RobotoMono-Regular.ttf
Binary file not shown.
14 changes: 14 additions & 0 deletions module/webroot/index.html
Original file line number Diff line number Diff line change
@@ -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 changes: 37 additions & 0 deletions module/webroot/scripts.js
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions module/webroot/styles.css
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 51b38ea

Please sign in to comment.