@@ -15,7 +15,6 @@ const rehookMode = [
1515 "minimal" // 2
1616]
1717
18- export let superkey = localStorage . getItem ( 'kp-next_superkey' ) || '' ;
1918export let MAX_CHUNK_SIZE = 96 * 1024 ;
2019
2120async function updateStatus ( ) {
@@ -30,20 +29,12 @@ async function updateStatus() {
3029 working . classList . remove ( 'hidden' ) ;
3130 kpmModule . refreshKpmList ( ) ;
3231 initRehook ( ) ;
33- document . querySelector ( '#superkey md-outlined-text-field' ) . value = superkey ;
3432 installedOnly . forEach ( el => el . removeAttribute ( 'hidden' ) ) ;
3533 } else {
3634 versionText . textContent = getString ( 'status_not_installed' ) ;
3735 notInstalled . classList . remove ( 'hidden' ) ;
3836 working . classList . add ( 'hidden' ) ;
3937 installedOnly . forEach ( el => el . setAttribute ( 'hidden' , '' ) ) ;
40- if ( superkey ) {
41- updateSuperkey ( '' ) ;
42- updateBtnState ( false ) ;
43- const failedDialog = document . getElementById ( 'authentication-failed-dialog' ) ;
44- failedDialog . show ( ) ;
45- failedDialog . querySelector ( '.confirm' ) . onclick = ( ) => failedDialog . close ( ) ;
46- }
4738 }
4839}
4940
@@ -52,31 +43,6 @@ export function escapeShell(cmd) {
5243 return '"' + cmd . replace ( / [ \\ " $ ` ' [ \] ] / g, '\\$&' ) + '"' ;
5344}
5445
55- function updateSuperkey ( key ) {
56- superkey = key ;
57- document . querySelectorAll ( '.password-field' ) . forEach ( field => {
58- field . value = key ;
59- } ) ;
60- localStorage . setItem ( 'kp-next_superkey' , key ) ;
61- exec ( `
62- key="${ btoa ( key ) } "
63- if [ -n "$key" ]; then
64- echo "$key" > /data/adb/kp-next/key
65- if [ -f "${ modDir } /unresolved" ]; then
66- rm -f "${ modDir } /unresolved"
67- busybox nohup sh "${ modDir } /service.sh" &
68- fi
69- else
70- rm -f /data/adb/kp-next/key
71- fi
72- ` , { env : { PATH : '/data/adb/ksu/bin:/data/adb/magisk:$PATH' } } ) ;
73- }
74-
75- function updateBtnState ( value ) {
76- document . querySelector ( '#superkey-dialog .confirm' ) . disabled = ! value ;
77- document . getElementById ( 'start' ) . disabled = ! value ;
78- }
79-
8046export async function initInfo ( ) {
8147 const result = await exec ( 'uname -r && getprop ro.build.version.release && getprop ro.build.fingerprint && getenforce' ) ;
8248 if ( import . meta. env . DEV ) { // vite debug
@@ -117,7 +83,7 @@ async function updateRehookStatus() {
11783
11884 let modeName = 'target' , modeId = null ;
11985
120- const result = await exec ( `kpatch ${ escapeShell ( superkey ) } rehook_status` , { env : { PATH : `${ modDir } /bin` } } ) ;
86+ const result = await exec ( `kpatch rehook_status` , { env : { PATH : `${ modDir } /bin` } } ) ;
12187 const mode = result . stdout . split ( '\n' ) . find ( line => line . includes ( 'mode: ' ) ) ;
12288 if ( mode ) {
12389 modeId = parseInt ( mode . split ( ':' ) [ 1 ] . trim ( ) ) ;
@@ -132,7 +98,7 @@ async function updateRehookStatus() {
13298
13399function setRehookMode ( mode ) {
134100 exec ( `
135- kpatch ${ escapeShell ( superkey ) } rehook ${ mode } && echo ${ mode } > ${ persistDir } /rehook` ,
101+ kpatch rehook ${ mode } && echo ${ mode } > ${ persistDir } /rehook` ,
136102 { env : { PATH : `${ modDir } /bin:$PATH` } }
137103 ) . then ( ( result ) => {
138104 if ( result . errno !== 0 ) {
@@ -181,46 +147,7 @@ document.addEventListener('DOMContentLoaded', async () => {
181147 language . onclick = ( ) => languageDialog . show ( ) ;
182148 languageDialog . querySelector ( '.cancel' ) . onclick = ( ) => languageDialog . close ( ) ;
183149
184- // visibility toggle for SuperKey text field
185- document . querySelectorAll ( '.password-field' ) . forEach ( field => {
186- const toggleBtn = field . querySelector ( 'md-icon-button[toggle]' ) ;
187- if ( toggleBtn ) {
188- toggleBtn . addEventListener ( 'change' , ( ) => {
189- field . type = toggleBtn . selected ? 'password' : 'text' ;
190- } ) ;
191- }
192- } ) ;
193-
194- // Superkey
195- const superkeyDialog = document . getElementById ( 'superkey-dialog' ) ;
196- const clearSuperkeyDialog = document . getElementById ( 'clear-superkey-dialog' ) ;
197- document . getElementById ( 'authenticate' ) . addEventListener ( 'click' , ( e ) => {
198- e . stopPropagation ( ) ;
199- superkeyDialog . show ( ) ;
200- } ) ;
201- document . querySelectorAll ( '.password-field' ) . forEach ( input => {
202- input . oninput = ( ) => updateBtnState ( input . value ) ;
203- } ) ;
204- superkeyDialog . querySelector ( '.cancel' ) . onclick = ( ) => superkeyDialog . close ( ) ;
205- superkeyDialog . querySelector ( '.confirm' ) . onclick = ( ) => {
206- const value = superkeyDialog . querySelector ( '.password-field' ) . value ;
207- updateSuperkey ( value ) ;
208- updateBtnState ( value ) ;
209- updateStatus ( ) ;
210- superkeyDialog . close ( ) ;
211- }
212- document . getElementById ( 'clear-superkey' ) . onclick = ( ) => clearSuperkeyDialog . show ( ) ;
213- clearSuperkeyDialog . querySelector ( '.cancel' ) . onclick = ( ) => clearSuperkeyDialog . close ( ) ;
214- clearSuperkeyDialog . querySelector ( '.confirm' ) . onclick = ( ) => {
215- clearSuperkeyDialog . close ( ) ;
216- updateSuperkey ( '' ) ;
217- updateBtnState ( '' ) ;
218- updateStatus ( ) ;
219- navigateToHome ( ) ;
220- }
221-
222150 // patch/unpatch
223- const patchTextField = document . querySelector ( '#superkey md-outlined-text-field' ) ;
224151 document . getElementById ( 'embed' ) . onclick = patchModule . embedKPM ;
225152 document . getElementById ( 'start' ) . onclick = ( ) => {
226153 document . querySelector ( '.trailing-btn' ) . style . display = 'none' ;
@@ -231,10 +158,6 @@ document.addEventListener('DOMContentLoaded', async () => {
231158 document . querySelector ( '.trailing-btn' ) . style . display = 'none' ;
232159 patchModule . patch ( "unpatch" ) ;
233160 }
234- patchTextField . addEventListener ( 'focus' , ( ) => {
235- const pageContent = patchTextField . closest ( '.page-content' ) ;
236- pageContent . scrollTo ( { top : pageContent . scrollHeight , behavior : 'smooth' } ) ;
237- } ) ;
238161
239162 // reboot
240163 const rebootMenu = document . getElementById ( 'reboot-menu' ) ;
@@ -248,7 +171,6 @@ document.addEventListener('DOMContentLoaded', async () => {
248171 } ) ;
249172 document . getElementById ( 'reboot-fab' ) . onclick = ( ) => reboot ( ) ;
250173
251- updateBtnState ( superkey ) ;
252174 getMaxChunkSize ( ) ;
253175
254176 await loadTranslations ( ) ;
0 commit comments