From baabbd90391e2b0539dcb324d7c7b656c4855120 Mon Sep 17 00:00:00 2001 From: wanhose Date: Wed, 11 Oct 2023 08:50:02 +0200 Subject: [PATCH] feat(browser-extension): prompt to set name to the exported file --- packages/browser-extension/src/scripts/options.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/browser-extension/src/scripts/options.js b/packages/browser-extension/src/scripts/options.js index 9419877..707cdc6 100644 --- a/packages/browser-extension/src/scripts/options.js +++ b/packages/browser-extension/src/scripts/options.js @@ -119,15 +119,17 @@ async function handleDeleteClick(event) { function handleExportClick() { const anchor = document.createElement('a'); const now = new Date(); - const day = now.getUTCDay().toString().padStart(2, '0'); - const month = now.getUTCMonth().toString().padStart(2, '0'); + const day = now.getDate().toString().padStart(2, '0'); + const month = now.getMonth().toString().padStart(2, '0'); const year = now.getUTCFullYear(); const text = exclusionList.join('\n'); + const defaultTitle = `${year}${month}${day}`; + const customTitle = window.prompt('Enter a file name', defaultTitle); const blob = new Blob([text], { type: 'octet/stream' }); const url = window.URL.createObjectURL(blob); anchor.href = url; - anchor.download = `${year}${month}${day}.cdm`; + anchor.download = `${customTitle || defaultTitle}.cdm`; anchor.click(); window.URL.revokeObjectURL(url); }