diff --git a/CHANGELOG.md b/CHANGELOG.md index 789793d..de4d0bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Download on script completion on Chrome. - Download file date string. +- Download via popup on Edge. +- Close notification dialog when script downloaded directly. ## 0.1.2 - 2025-06-17 diff --git a/CHANGELOG.rec.md b/CHANGELOG.rec.md index e042b12..4297033 100644 --- a/CHANGELOG.rec.md +++ b/CHANGELOG.rec.md @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Download on script completion on Chrome. - Download file date string. +- Download via popup on Edge. +- Close notification dialog when script downloaded directly. ## 0.1.2 - 2025-06-17 diff --git a/source/Background/index.ts b/source/Background/index.ts index 8e6caf5..9401275 100644 --- a/source/Background/index.ts +++ b/source/Background/index.ts @@ -30,7 +30,6 @@ import { REPORT_OBJECT, RESET_ZEST_SCRIPT, SESSION_STORAGE, - SET_SAVE_SCRIPT_ENABLE, STOP_RECORDING, ZEST_SCRIPT, } from '../utils/constants'; @@ -249,11 +248,6 @@ async function handleMessage( } break; } - case SET_SAVE_SCRIPT_ENABLE: - Browser.storage.sync.set({ - zapenablesavescript: zestScript.getZestStatementCount() > 0, - }); - break; default: // Handle unknown request type diff --git a/source/Popup/index.tsx b/source/Popup/index.tsx index 238930b..8505312 100644 --- a/source/Popup/index.tsx +++ b/source/Popup/index.tsx @@ -25,7 +25,6 @@ import { GET_ZEST_SCRIPT, IS_FULL_EXTENSION, RESET_ZEST_SCRIPT, - SET_SAVE_SCRIPT_ENABLE, STOP_RECORDING, UPDATE_TITLE, ZAP_START_RECORDING, @@ -57,9 +56,6 @@ const loginUrlInput = document.getElementById( const scriptNameInput = document.getElementById( 'script-name-input' ) as HTMLInputElement; -const saveScriptButton = document.getElementById( - 'save-script' -) as HTMLButtonElement; function sendMessageToContentScript(message: string, data = ''): void { Browser.tabs.query({active: true, currentWindow: true}).then((tabs) => { @@ -90,14 +86,12 @@ function startedAnimation(): void { async function restoreState(): Promise { console.log('Restore state'); - await Browser.runtime.sendMessage({type: SET_SAVE_SCRIPT_ENABLE}); optionsIcon.title = OPTIONS; downloadIcon.title = DOWNLOAD; Browser.storage.sync .get({ zaprecordingactive: false, zapscriptname: '', - zapenablesavescript: false, }) .then((items) => { if (items.zaprecordingactive) { @@ -111,11 +105,6 @@ async function restoreState(): Promise { } else { done?.classList.add('invisible'); } - if (!items.zapenablesavescript) { - saveScriptButton.classList.add('disabled'); - } else { - saveScriptButton.classList.remove('disabled'); - } }); } @@ -189,7 +178,14 @@ function openHelpPage(): void { closePopup(); } -function downloadZestScript(zestScriptJSON: string, title: string): void { +function downloadZestScript( + zestScriptJSON: string, + title: string, + statementCount: number +): void { + if (statementCount === 0) { + return; + } if (title === '') { scriptNameInput?.focus(); return; @@ -211,11 +207,12 @@ async function handleSaveScript(): Promise { zaprecordingactive: false, }); if (storageItems.zaprecordingactive) { + sendMessageToContentScript(ZAP_STOP_RECORDING); await Browser.runtime.sendMessage({type: STOP_RECORDING}); } Browser.runtime.sendMessage({type: GET_ZEST_SCRIPT}).then((items) => { const msg = items as ZestScriptMessage; - downloadZestScript(msg.script, msg.title); + downloadZestScript(msg.script, msg.title, msg.statementCount); }); } diff --git a/source/Popup/styles.scss b/source/Popup/styles.scss index e2640f2..9b55c1e 100644 --- a/source/Popup/styles.scss +++ b/source/Popup/styles.scss @@ -275,11 +275,6 @@ html { color: var(--primary); } &:hover {color: var(--primary);} - - &.disabled { - pointer-events: none; - opacity: 0.5; - } } @keyframes waves { diff --git a/source/types/zestScript/ZestScript.ts b/source/types/zestScript/ZestScript.ts index dab806b..9395669 100644 --- a/source/types/zestScript/ZestScript.ts +++ b/source/types/zestScript/ZestScript.ts @@ -22,6 +22,7 @@ import Browser from 'webextension-polyfill'; interface ZestScriptMessage { script: string; title: string; + statementCount: number; } class ZestScript { @@ -93,7 +94,11 @@ class ZestScript { return new Promise((resolve) => { Browser.storage.sync.get({zapscriptname: this.title}).then((items) => { this.title = items.zapscriptname as string; - resolve({script: this.toJSON(), title: this.title}); + resolve({ + script: this.toJSON(), + title: this.title, + statementCount: this.getZestStatementCount(), + }); }); }); } diff --git a/source/utils/constants.ts b/source/utils/constants.ts index 2ff7a81..bc5bbc8 100644 --- a/source/utils/constants.ts +++ b/source/utils/constants.ts @@ -38,7 +38,6 @@ export const DEFAULT_WINDOW_HANDLE = 'windowHandle1'; export const ZAP_STOP_RECORDING = 'zapStopRecording'; export const ZAP_START_RECORDING = 'zapStartRecording'; -export const SET_SAVE_SCRIPT_ENABLE = 'setSaveScriptEnable'; export const ZEST_SCRIPT = 'zestScript'; export const STOP_RECORDING = 'stopRecording';