]> git.wh0rd.org - chrome-ext/clearhistory-advance-fork.git/blame - javascript/popup.js
popup: move prompt from background page to popup page
[chrome-ext/clearhistory-advance-fork.git] / javascript / popup.js
CommitLineData
a3c71eeb
MF
1/**
2 * @fileoverview Executes when the user clicks the browser action.
3 */
4
5import {CONSTANTS} from './background.js';
6
7async function init() {
8 const {prompt = CONSTANTS.YES} = await chrome.storage.sync.get('prompt');
9
10 if (prompt === CONSTANTS.YES) {
11 // The confirmation message to ask.
12 const message = chrome.i18n.getMessage('confirmPrompt');
13
14 if (!confirm(message)) {
15 window.close();
16 return;
17 }
18 }
19
20 // Notify background page to do the actual clear.
21 await chrome.runtime.sendMessage({action: 'runCleaner'});
22
23 window.close();
24}
25init();