Skip to content

Commit

Permalink
feat(browser-extension): prompt to set name to the exported file
Browse files Browse the repository at this point in the history
  • Loading branch information
wanhose committed Oct 11, 2023
1 parent 25b976d commit baabbd9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/browser-extension/src/scripts/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit baabbd9

Please sign in to comment.