You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
improve: web UI JS code
This commit improves the web UI Javascript code.
This commit is contained in:
+50
-31
@@ -1,16 +1,12 @@
|
|||||||
import { exec, toast, fullScreen } from './kernelsu.js';
|
import { fullScreen, exec, toast } from './kernelsu.js';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
fullScreen(true)
|
fullScreen(true)
|
||||||
const rootCss = document.querySelector(':root');
|
|
||||||
|
const rootCss = document.querySelector(':root')
|
||||||
const rezygisk_state = document.getElementById('rezygisk_state')
|
const rezygisk_state = document.getElementById('rezygisk_state')
|
||||||
const rezygisk_settings = document.getElementById("rezygisk_settings")
|
const rezygisk_settings = document.getElementById('rezygisk_settings')
|
||||||
const rezygisk_icon_state = document.getElementById('rezygisk_icon_state')
|
const rezygisk_icon_state = document.getElementById('rezygisk_icon_state')
|
||||||
/* TODO: Implement rezygisk state */
|
|
||||||
rezygisk_settings.removeAttribute("style")
|
|
||||||
rootCss.style.setProperty('--bright', '#3a4857');
|
|
||||||
rezygisk_state.innerHTML = 'ReZygisk is functioning!'
|
|
||||||
rezygisk_icon_state.innerHTML = '<img class="brightc" src="assets/tick.svg">'
|
|
||||||
|
|
||||||
const code_version = document.getElementById('version_code')
|
const code_version = document.getElementById('version_code')
|
||||||
const root_impl = document.getElementById('root_impl')
|
const root_impl = document.getElementById('root_impl')
|
||||||
@@ -18,10 +14,10 @@ import { exec, toast, fullScreen } from './kernelsu.js';
|
|||||||
const is_zygote32_injected = document.getElementById('is_zygote32_injected')
|
const is_zygote32_injected = document.getElementById('is_zygote32_injected')
|
||||||
const is_zygote64_injected = document.getElementById('is_zygote64_injected')
|
const is_zygote64_injected = document.getElementById('is_zygote64_injected')
|
||||||
|
|
||||||
const { errno, stdout, stderr } = await exec('/data/adb/modules/zygisksu/bin/zygisk-ptrace64 info')
|
const ptrace64Cmd = await exec('/data/adb/modules/zygisksu/bin/zygisk-ptrace64 info')
|
||||||
|
|
||||||
if (errno === 0) {
|
if (ptrace64Cmd.errno === 0) {
|
||||||
const lines = stdout.split('\n')
|
const lines = ptrace64Cmd.stdout.split('\n')
|
||||||
|
|
||||||
code_version.innerHTML = lines[0].split('Tracer ')[1].split('-')[0]
|
code_version.innerHTML = lines[0].split('Tracer ')[1].split('-')[0]
|
||||||
|
|
||||||
@@ -29,26 +25,45 @@ import { exec, toast, fullScreen } from './kernelsu.js';
|
|||||||
|
|
||||||
is_zygote64_injected.innerHTML = lines[5].split(': ')[1] === 'yes' ? 'Injected' : 'Not Injected'
|
is_zygote64_injected.innerHTML = lines[5].split(': ')[1] === 'yes' ? 'Injected' : 'Not Injected'
|
||||||
} else {
|
} else {
|
||||||
toast(`Failed to get zygisk-ptrace64 info: ${stderr}`)
|
toast(`zygisk-ptrace64 error (${ptrace64Cmd.errno}): ${ptrace64Cmd.stderr}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { errno: errno32, stdout: stdout32, stderr: stderr32 } = await exec('/data/adb/modules/zygisksu/bin/zygisk-ptrace32 info')
|
const ptrace32Cmd = await exec('/data/adb/modules/zygisksu/bin/zygisk-ptrace32 info')
|
||||||
|
|
||||||
if (errno32 === 0) {
|
if (ptrace32Cmd.errno === 0) {
|
||||||
const lines32 = stdout32.split('\n')
|
const lines32 = ptrace32Cmd.stdout.split('\n')
|
||||||
|
|
||||||
is_zygote32_injected.innerHTML = lines32[5].split(': ')[1] === 'yes' ? 'Injected' : 'Not Injected'
|
is_zygote32_injected.innerHTML = lines32[5].split(': ')[1] === 'yes' ? 'Injected' : 'Not Injected'
|
||||||
} else {
|
} else {
|
||||||
toast(`Failed to get zygisk-ptrace32 info: ${stderr32}`)
|
toast(`zygisk-ptrace32 error (${ptrace32Cmd.errno}): ${ptrace32Cmd.stderr}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_zygote32_injected.innerHTML === 'Not Injected' && is_zygote64_injected.innerHTML === 'Not injected') {
|
||||||
|
rezygisk_state.innerHTML = 'ReZygisk is not functioning!'
|
||||||
|
} else if (is_zygote32_injected.innerHTML === 'Injected' && is_zygote64_injected.innerHTML === 'Injected') {
|
||||||
|
rezygisk_state.innerHTML = 'ReZygisk is fully functioning!'
|
||||||
|
|
||||||
|
rezygisk_settings.removeAttribute('style')
|
||||||
|
rootCss.style.setProperty('--bright', '#3a4857');
|
||||||
|
rezygisk_icon_state.innerHTML = '<img class="brightc" src="assets/tick.svg">'
|
||||||
|
} else {
|
||||||
|
rezygisk_state.innerHTML = 'ReZygisk is partially functioning!'
|
||||||
|
|
||||||
|
rezygisk_settings.removeAttribute('style')
|
||||||
|
rootCss.style.setProperty('--bright', '#ffd000');
|
||||||
|
rezygisk_icon_state.innerHTML = '<img class="brightc" src="assets/warning.svg">'
|
||||||
|
}
|
||||||
|
|
||||||
const modules_list = document.getElementById('modules_list')
|
const modules_list = document.getElementById('modules_list')
|
||||||
|
|
||||||
const { errno: errnoModules, stdout: stdoutModules, stderr: stderrModules } = await exec('find /data/adb/modules -type d -name zygisk -exec dirname {} \\;')
|
const findModulesCmd = await exec('find /data/adb/modules -type d -name zygisk -exec dirname {} \\;')
|
||||||
|
|
||||||
if (errnoModules === 0) {
|
if (findModulesCmd.errno === 0) {
|
||||||
modules_list.removeAttribute("style")
|
const modules = findModulesCmd.stdout.split('\n')
|
||||||
const modules = stdoutModules.split('\n')
|
|
||||||
|
if (modules.length === 0) return;
|
||||||
|
|
||||||
|
modules_list.removeAttribute('style')
|
||||||
|
|
||||||
modules_list.innerHTML +=
|
modules_list.innerHTML +=
|
||||||
`<div class="dimc content" style="font-size: 1.2em;">
|
`<div class="dimc content" style="font-size: 1.2em;">
|
||||||
@@ -57,19 +72,23 @@ import { exec, toast, fullScreen } from './kernelsu.js';
|
|||||||
<br/>`
|
<br/>`
|
||||||
|
|
||||||
for (const module of modules) {
|
for (const module of modules) {
|
||||||
const { errno: errnoZygisk, stdout: stdoutZygisk, stderr: stderrZygisk } = await exec(`ls ${module}/zygisk`)
|
const lsZygiskCmd = await exec(`ls ${module}/zygisk`)
|
||||||
if (errnoZygisk !== 0) continue
|
if (lsZygiskCmd.errno !== 0) {
|
||||||
|
toast(`ls ${module}/zygisk error (${lsZygiskCmd.errno}): ${lsZygiskCmd.stderr}`)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const bitsUsed = []
|
const bitsUsed = []
|
||||||
if (stdoutZygisk.split('\n').find(line => [ 'arm64-v8a.so', 'x86_64.so' ].includes(line))) bitsUsed.push('64 bit')
|
if (lsZygiskCmd.stdout.split('\n').find((line) => [ 'arm64-v8a.so', 'x86_64.so' ].includes(line))) bitsUsed.push('64')
|
||||||
if (stdoutZygisk.split('\n').find(line => [ 'armeabi-v7a.so', 'x86.so' ].includes(line))) bitsUsed.push('32 bit')
|
if (lsZygiskCmd.stdout.split('\n').find((line) => [ 'armeabi-v7a.so', 'x86.so' ].includes(line))) bitsUsed.push('32')
|
||||||
|
|
||||||
if (bitsUsed.length === 0) bitsUsed.push('N/A')
|
if (bitsUsed.length === 0) bitsUsed.push('N/A')
|
||||||
|
|
||||||
const { errno: errnoModule, stdout: stdoutModule, stderr: stderrModule } = await exec(`cat ${module}/module.prop`)
|
const catCmd = await exec(`cat ${module}/module.prop`)
|
||||||
|
|
||||||
if (errnoModule === 0) {
|
if (catCmd.errno === 0) {
|
||||||
const lines = stdoutModule.split('\n')
|
const lines = catCmd.stdout.split('\n')
|
||||||
const name = lines.find(line => line.includes('name=')).split('=')[1]
|
const name = lines.find(line => line.includes('name=')).split('=')[1]
|
||||||
|
|
||||||
modules_list.innerHTML +=
|
modules_list.innerHTML +=
|
||||||
@@ -78,12 +97,12 @@ import { exec, toast, fullScreen } from './kernelsu.js';
|
|||||||
<div class="dimc">${bitsUsed.join(' / ')}</div>
|
<div class="dimc">${bitsUsed.join(' / ')}</div>
|
||||||
</div>`
|
</div>`
|
||||||
} else {
|
} else {
|
||||||
toast(`Failed to get module ${module} info: ${stderrModule}`)
|
toast(`cat ${module} error (${catCmd.errno}): ${catCmd.stderr}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modules_list.innerHTML += '</div>'
|
modules_list.innerHTML += '</div>'
|
||||||
} else {
|
} else {
|
||||||
toast(`Failed to get modules list: ${stderrModules}`)
|
toast(`find error (${findModulesCmd.errno}): ${findModulesCmd.stderr}`)
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
Reference in New Issue
Block a user