@@ -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 ( ) {
@@ -26,57 +25,21 @@ async function updateStatus() {
2625 const installedOnly = document . querySelectorAll ( '.installed-only' ) ;
2726 if ( version ) {
2827 versionText . textContent = version ;
29- notInstalled . classList . add ( 'hidden' ) ;
30- working . classList . remove ( 'hidden' ) ;
3128 kpmModule . refreshKpmList ( ) ;
3229 initRehook ( ) ;
33- document . querySelector ( '#superkey md-outlined-text-field' ) . value = superkey ;
3430 installedOnly . forEach ( el => el . removeAttribute ( 'hidden' ) ) ;
3531 } else {
36- versionText . textContent = getString ( 'status_not_installed' ) ;
37- notInstalled . classList . remove ( 'hidden' ) ;
38- working . classList . add ( 'hidden' ) ;
3932 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- }
4733 }
34+ notInstalled . classList . toggle ( 'hidden' , version ) ;
35+ working . classList . toggle ( 'hidden' , ! version ) ;
4836}
4937
5038export function escapeShell ( cmd ) {
5139 if ( cmd === '' || cmd === null || cmd === undefined ) return '""' ;
5240 return '"' + cmd . replace ( / [ \\ " $ ` ' [ \] ] / g, '\\$&' ) + '"' ;
5341}
5442
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-
8043export async function initInfo ( ) {
8144 const result = await exec ( 'uname -r && getprop ro.build.version.release && getprop ro.build.fingerprint && getenforce' ) ;
8245 if ( import . meta. env . DEV ) { // vite debug
@@ -117,7 +80,7 @@ async function updateRehookStatus() {
11780
11881 let modeName = 'target' , modeId = null ;
11982
120- const result = await exec ( `kpatch ${ escapeShell ( superkey ) } rehook_status` , { env : { PATH : `${ modDir } /bin` } } ) ;
83+ const result = await exec ( `kpatch rehook_status` , { env : { PATH : `${ modDir } /bin` } } ) ;
12184 const mode = result . stdout . split ( '\n' ) . find ( line => line . includes ( 'mode: ' ) ) ;
12285 if ( mode ) {
12386 modeId = parseInt ( mode . split ( ':' ) [ 1 ] . trim ( ) ) ;
@@ -132,7 +95,7 @@ async function updateRehookStatus() {
13295
13396function setRehookMode ( mode ) {
13497 exec ( `
135- kpatch ${ escapeShell ( superkey ) } rehook ${ mode } && echo ${ mode } > ${ persistDir } /rehook` ,
98+ kpatch rehook ${ mode } && echo ${ mode } > ${ persistDir } /rehook` ,
13699 { env : { PATH : `${ modDir } /bin:$PATH` } }
137100 ) . then ( ( result ) => {
138101 if ( result . errno !== 0 ) {
@@ -181,46 +144,7 @@ document.addEventListener('DOMContentLoaded', async () => {
181144 language . onclick = ( ) => languageDialog . show ( ) ;
182145 languageDialog . querySelector ( '.cancel' ) . onclick = ( ) => languageDialog . close ( ) ;
183146
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-
222147 // patch/unpatch
223- const patchTextField = document . querySelector ( '#superkey md-outlined-text-field' ) ;
224148 document . getElementById ( 'embed' ) . onclick = patchModule . embedKPM ;
225149 document . getElementById ( 'start' ) . onclick = ( ) => {
226150 document . querySelector ( '.trailing-btn' ) . style . display = 'none' ;
@@ -231,10 +155,6 @@ document.addEventListener('DOMContentLoaded', async () => {
231155 document . querySelector ( '.trailing-btn' ) . style . display = 'none' ;
232156 patchModule . patch ( "unpatch" ) ;
233157 }
234- patchTextField . addEventListener ( 'focus' , ( ) => {
235- const pageContent = patchTextField . closest ( '.page-content' ) ;
236- pageContent . scrollTo ( { top : pageContent . scrollHeight , behavior : 'smooth' } ) ;
237- } ) ;
238158
239159 // reboot
240160 const rebootMenu = document . getElementById ( 'reboot-menu' ) ;
@@ -248,7 +168,6 @@ document.addEventListener('DOMContentLoaded', async () => {
248168 } ) ;
249169 document . getElementById ( 'reboot-fab' ) . onclick = ( ) => reboot ( ) ;
250170
251- updateBtnState ( superkey ) ;
252171 getMaxChunkSize ( ) ;
253172
254173 await loadTranslations ( ) ;
0 commit comments