webui: add MMRL check

- guide user to fix error in MMRL
- request permission directly in newer version
This commit is contained in:
KOWX712 2025-02-11 02:17:44 +08:00
parent bf1217e9e7
commit 55ed35cb89

View File

@ -27,11 +27,37 @@ async function runAction() {
output.appendChild(lineElement);
});
} catch (error) {
output.innerHTML = '[!] Error: Fail to execute action.sh';
console.error('Script execution failed:', error);
if (typeof ksu !== 'undefined' && ksu.mmrl) {
output.innerHTML = '[!] Please allow permission in MMRL settings<br><br>[-] Settings<br>[-] Security<br>[-] Allow JavaScript API<br>[-] Play Integrity Fix<br>[-] Enable Allow Advanced KernelSU API';
} else {
output.innerHTML = '[!] Error: Fail to execute action.sh';
}
}
}
// Function to check if running in MMRL
function checkMMRL() {
if (typeof ksu !== 'undefined' && ksu.mmrl) {
// Set status bars theme based on device theme
try {
$playintegrityfix.setLightStatusBars(!window.matchMedia('(prefers-color-scheme: dark)').matches)
} catch (error) {
console.log("Error setting status bars theme:", error)
}
// Request API permission, supported version: 33045+
try {
$playintegrityfix.requestAdvancedKernelSUAPI();
} catch (error) {
console.log("Error requesting API:", error);
}
} else {
console.log("Not running in MMRL environment.");
}
}
document.addEventListener('DOMContentLoaded', async () => {
checkMMRL();
setTimeout(runAction, 200);
});