@@ -15,9 +15,10 @@ var svg_5 = `<svg xmlns="http://www.w3.org/2000/svg" style="fill: red;" width="2
1515var svg_6 = `
1616<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M11.885 14.988l3.104-3.098.011.11c0 1.654-1.346 3-3 3l-.115-.012zm8.048-8.032l-3.274 3.268c.212.554.341 1.149.341 1.776 0 2.757-2.243 5-5 5-.631 0-1.229-.13-1.785-.344l-2.377 2.372c1.276.588 2.671.972 4.177.972 7.733 0 11.985-8.449 11.985-8.449s-1.415-2.478-4.067-4.595zm1.431-3.536l-18.619 18.58-1.382-1.422 3.455-3.447c-3.022-2.45-4.818-5.58-4.818-5.58s4.446-7.551 12.015-7.551c1.825 0 3.456.426 4.886 1.075l3.081-3.075 1.382 1.42zm-13.751 10.922l1.519-1.515c-.077-.264-.132-.538-.132-.827 0-1.654 1.346-3 3-3 .291 0 .567.055.833.134l1.518-1.515c-.704-.382-1.496-.619-2.351-.619-2.757 0-5 2.243-5 5 0 .852.235 1.641.613 2.342z"/></svg>` ;
1717
18+
1819var toolbar_html = `
1920
20- <div class="h4c3r_toolbar">
21+
2122 <div class="h4c3r_toolbar_main" id="toolbar_id_">
2223 <div class="h4c3r_toolbar_item h4c3r_fill">
2324 <span>
@@ -50,20 +51,52 @@ var toolbar_html = `
5051
5152 </div>
5253 </div>
53- </div>
5454
5555 ` ;
5656
57+ var toolbar_hide = `
5758
58- ( function ( ) {
59+ <div class="h4c3r_toolbar_main" id="toolbar_id_">
60+
61+
62+ <div class="h4c3r_toolbar_item h4c3r_show">
63+ <span class="" >
64+ ${ svg_6 }
65+ </span>
66+ </div>
67+
68+ <div class="h4c3r_toolbar_item " id="h4c3r_header" >
69+ <span class="h4c3r_drag" >
70+ ${ svg_3 }
71+ </span>
72+ </div>
73+
74+
75+ </div>
76+
77+ ` ;
78+
79+
80+ function init ( ) {
5981
6082
6183 var hide_toolbar = localStorage . getItem ( 'h4ck3r.hide' ) ;
84+ if ( ! hide_toolbar ) {
85+ localStorage . setItem ( 'h4ck3r.hide' , true ) ;
86+ }
87+
88+ $ ( 'body' ) . prepend ( `<div class="h4c3r_toolbar"></div>` ) ;
6289
63- if ( hide_toolbar != true || hide_toolbar != 1 ) {
64- $ ( 'body' ) . prepend ( toolbar_html ) ;
90+
91+ if ( hide_toolbar == true || hide_toolbar == 1 ) {
92+ $ ( '.h4c3r_toolbar' ) . prepend ( toolbar_html ) ;
93+ } else {
94+ $ ( '.h4c3r_toolbar' ) . prepend ( toolbar_hide ) ;
6595 }
6696
97+ var elmnt = document . getElementById ( "toolbar_id_" ) ;
98+ elmnt . style . top = localStorage . getItem ( 'h4ck3r_position_top' ) ?? '10px' ;
99+ elmnt . style . left = localStorage . getItem ( 'h4ck3r_position_bottom' ) ?? '-120px' ;
67100
68101 var reload_config = localStorage . getItem ( 'h4ck3r.reload' ) ;
69102
@@ -91,10 +124,17 @@ var toolbar_html = `
91124
92125 }
93126
127+ }
128+
129+
130+ ( function ( ) {
131+
132+ init ( ) ;
133+
94134} ) ( )
95135
96136
97- $ ( '.h4c3r_fill' ) . on ( 'click' , ( e ) => {
137+ $ ( '.h4c3r_fill' ) . on ( 'click' , ( e ) => {
98138 fill_email ( ) ;
99139 fill_text ( ) ;
100140 fill_tel ( ) ;
@@ -106,14 +146,38 @@ $('.h4c3r_fill').on('click',(e) => {
106146
107147$ ( '.h4c3r_reset' ) . on ( 'click' , ( e ) => {
108148
109- $ ( "input" ) . val ( '' ) ;
110- $ ( "textarea" ) . val ( '' ) ;
149+ $ ( "input" ) . val ( '' ) ;
150+ $ ( "textarea" ) . val ( '' ) ;
111151
112152} )
113153
114154$ ( '.h4c3r_hide' ) . on ( 'click' , ( e ) => {
115155
116- localStorage . setItem ( 'h4ck3r.hide' , 1 ) ;
156+ console . log ( e ) ;
157+
158+
159+ localStorage . setItem ( 'h4ck3r.hide' , 1 ) ;
160+
161+ $ ( '.h4c3r_toolbar' ) . remove ( ) ;
162+ init ( ) ;
163+
164+ localStorage . setItem ( 'h4ck3r_position_top' , '9px' )
165+ localStorage . setItem ( 'h4ck3r_position_bottom' , '-65px' )
166+
167+ window . location . reload ( )
168+
169+ } )
170+
171+ $ ( '.h4c3r_show' ) . on ( 'click' , ( e ) => {
172+
173+ console . log ( e ) ;
174+
175+ localStorage . setItem ( 'h4ck3r.hide' , 0 ) ;
176+
177+ $ ( '.h4c3r_toolbar' ) . remove ( ) ;
178+ init ( ) ;
179+ window . location . reload ( )
180+
117181
118182} )
119183
@@ -122,16 +186,16 @@ $('#h4c3r_hot_reload').on('click', (e) => {
122186 var reload_config = localStorage . getItem ( 'h4ck3r.reload' ) ;
123187 reload_config = JSON . parse ( reload_config ) ;
124188
125- console . log ( 'click' , reload_config ) ;
126- if ( reload_config ?. do == true ) {
189+ console . log ( 'click' , reload_config ) ;
190+ if ( reload_config ?. do == true ) {
127191 console . log ( '%c hot relaod disabled ' , 'color: #fff; font-size: 40px; background-color: red;' ) ;
128192
129193 $ ( '.h4c3r_hot_reload' ) . html ( svg_4 ) ;
130194
131195 config = { seconds : 5000 , do : false }
132196
133197 localStorage . setItem ( 'h4ck3r.reload' , JSON . stringify ( config ) )
134-
198+
135199 } else {
136200 console . log ( '%c hot relaod enabled ' , 'color: #fff; font-size: 40px; background-color: red;' ) ;
137201
@@ -148,9 +212,9 @@ $('#h4c3r_hot_reload').on('click', (e) => {
148212} ) ;
149213
150214const fill_email = function ( ) {
151-
215+
152216 var sample_email = random_string ( ) + '@yopmail.com' ;
153-
217+
154218 $ ( "input[type='text']" ) . each ( ( i ) => {
155219
156220 var elm = $ ( "input[type='email']" ) [ i ] ;
@@ -164,30 +228,30 @@ const fill_email = function () {
164228
165229const fill_text = function ( ) {
166230
167- $ ( "input[type='text']" ) . each ( ( i ) => {
168-
231+ $ ( "input[type='text']" ) . each ( ( i ) => {
232+
169233 var elm = $ ( "input[type='text']" ) [ i ] ;
170- var str_len = 10 ;
234+ var str_len = 10 ;
171235
172- var max_length = $ ( elm ) . attr ( 'maxlength' ) ;
173-
174- var minlength = $ ( elm ) . attr ( 'minlength' ) ;
236+ var max_length = $ ( elm ) . attr ( 'maxlength' ) ;
175237
176- if ( minlength ) {
177- str_len = minlength + 1 ;
178- }
238+ var minlength = $ ( elm ) . attr ( 'minlength' ) ;
179239
180- if ( max_length ) {
181- str_len = max_length - 1 ;
182- }
240+ if ( minlength ) {
241+ str_len = minlength + 1 ;
242+ }
243+
244+ if ( max_length ) {
245+ str_len = max_length - 1 ;
246+ }
247+
248+ var sample_string = random_string ( str_len ) ;
183249
184- var sample_string = random_string ( str_len ) ;
185-
186250 $ ( elm ) . val ( sample_string ) ;
187251 $ ( elm ) . trigger ( 'change' ) ;
188-
252+
189253 } )
190-
254+
191255}
192256
193257const fill_tel = function ( ) {
@@ -265,17 +329,17 @@ const fill_text_area = function () {
265329function fill_select ( ) {
266330
267331 $ ( "select" ) . each ( ( i ) => {
268-
332+
269333 var elm = $ ( "select" ) [ i ] ;
270334 var $options = $ ( elm ) . find ( 'option' ) ;
271335 var random_val = ~ ~ ( Math . random ( ) * $options . length ) ;
272336 var option = $ ( elm ) . find ( 'option' ) [ random_val ] ;
273337 $ ( elm ) . val ( $ ( option ) . val ( ) ) ;
274338 $ ( elm ) . trigger ( 'change' ) ;
275-
276-
339+
340+
277341 } ) ;
278-
342+
279343}
280344
281345function fill_checkbox ( ) {
@@ -326,11 +390,11 @@ function random_number(length = 8) {
326390
327391function take_screenshot ( ) {
328392
329- $ ( '.h4c3r_toolbar' ) . hide ( ) ;
393+ $ ( '.h4c3r_toolbar' ) . hide ( ) ;
330394
331- html2canvas ( document . body ) . then ( function ( canvas ) {
332- document . body . appendChild ( canvas ) ;
333- } )
395+ html2canvas ( document . body ) . then ( function ( canvas ) {
396+ document . body . appendChild ( canvas ) ;
397+ } )
334398 . then ( ( ) => {
335399 var canvas = document . querySelector ( 'canvas' ) ;
336400 canvas . style . display = 'none' ;
@@ -341,6 +405,6 @@ function take_screenshot() {
341405 a . click ( ) ;
342406 } ) ;
343407
344- $ ( '.h4c3r_toolbar' ) . show ( ) ;
408+ $ ( '.h4c3r_toolbar' ) . show ( ) ;
345409
346410}
0 commit comments