From 55ed35cb892329dc041c6a305fda46ae621a8a34 Mon Sep 17 00:00:00 2001 From: KOWX712 Date: Tue, 11 Feb 2025 02:17:44 +0800 Subject: [PATCH] webui: add MMRL check - guide user to fix error in MMRL - request permission directly in newer version --- module/webroot/scripts.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/module/webroot/scripts.js b/module/webroot/scripts.js index 8ce7185..dc9fe12 100644 --- a/module/webroot/scripts.js +++ b/module/webroot/scripts.js @@ -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

[-] Settings
[-] Security
[-] Allow JavaScript API
[-] Play Integrity Fix
[-] 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); }); \ No newline at end of file