@@ -25,7 +25,6 @@ import {
2525 GET_ZEST_SCRIPT ,
2626 IS_FULL_EXTENSION ,
2727 RESET_ZEST_SCRIPT ,
28- SET_SAVE_SCRIPT_ENABLE ,
2928 STOP_RECORDING ,
3029 UPDATE_TITLE ,
3130 ZAP_START_RECORDING ,
@@ -57,9 +56,6 @@ const loginUrlInput = document.getElementById(
5756const scriptNameInput = document . getElementById (
5857 'script-name-input'
5958) as HTMLInputElement ;
60- const saveScriptButton = document . getElementById (
61- 'save-script'
62- ) as HTMLButtonElement ;
6359
6460function sendMessageToContentScript ( message : string , data = '' ) : void {
6561 Browser . tabs . query ( { active : true , currentWindow : true } ) . then ( ( tabs ) => {
@@ -90,14 +86,12 @@ function startedAnimation(): void {
9086
9187async function restoreState ( ) : Promise < void > {
9288 console . log ( 'Restore state' ) ;
93- await Browser . runtime . sendMessage ( { type : SET_SAVE_SCRIPT_ENABLE } ) ;
9489 optionsIcon . title = OPTIONS ;
9590 downloadIcon . title = DOWNLOAD ;
9691 Browser . storage . sync
9792 . get ( {
9893 zaprecordingactive : false ,
9994 zapscriptname : '' ,
100- zapenablesavescript : false ,
10195 } )
10296 . then ( ( items ) => {
10397 if ( items . zaprecordingactive ) {
@@ -111,11 +105,6 @@ async function restoreState(): Promise<void> {
111105 } else {
112106 done ?. classList . add ( 'invisible' ) ;
113107 }
114- if ( ! items . zapenablesavescript ) {
115- saveScriptButton . classList . add ( 'disabled' ) ;
116- } else {
117- saveScriptButton . classList . remove ( 'disabled' ) ;
118- }
119108 } ) ;
120109}
121110
@@ -189,7 +178,14 @@ function openHelpPage(): void {
189178 closePopup ( ) ;
190179}
191180
192- function downloadZestScript ( zestScriptJSON : string , title : string ) : void {
181+ function downloadZestScript (
182+ zestScriptJSON : string ,
183+ title : string ,
184+ statementCount : number
185+ ) : void {
186+ if ( statementCount === 0 ) {
187+ return ;
188+ }
193189 if ( title === '' ) {
194190 scriptNameInput ?. focus ( ) ;
195191 return ;
@@ -211,11 +207,12 @@ async function handleSaveScript(): Promise<void> {
211207 zaprecordingactive : false ,
212208 } ) ;
213209 if ( storageItems . zaprecordingactive ) {
210+ sendMessageToContentScript ( ZAP_STOP_RECORDING ) ;
214211 await Browser . runtime . sendMessage ( { type : STOP_RECORDING } ) ;
215212 }
216213 Browser . runtime . sendMessage ( { type : GET_ZEST_SCRIPT } ) . then ( ( items ) => {
217214 const msg = items as ZestScriptMessage ;
218- downloadZestScript ( msg . script , msg . title ) ;
215+ downloadZestScript ( msg . script , msg . title , msg . statementCount ) ;
219216 } ) ;
220217}
221218
0 commit comments