}
/**
- * Executes when the user clicks the browser action. Uses stored values from
- * {@code localStorage}
+ * Callback from other pages (like the popup).
*/
-chrome.browserAction.onClicked.addListener(function(tab) {
- // Get the value from localStorage
- chrome.storage.sync.get('prompt', function(s) {
- var showPrompt = s.prompt || CONSTANTS.YES;
-
- // The confirmation message to ask
- var message = chrome.i18n.getMessage('confirmPrompt');
-
- // Clear cookies, and then clear the history
- if (showPrompt === CONSTANTS.YES) {
- if (!confirm(message))
- return;
+chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
+ switch (request?.action) {
+ case 'runCleaner':
+ runCleaner();
+ break;
}
- runCleaner();
- });
});
chrome.alarms.get(CONSTANTS.CLEANER_ALARM, function(a) {
--- /dev/null
+/**
+ * @fileoverview Executes when the user clicks the browser action.
+ */
+
+import {CONSTANTS} from './background.js';
+
+async function init() {
+ const {prompt = CONSTANTS.YES} = await chrome.storage.sync.get('prompt');
+
+ if (prompt === CONSTANTS.YES) {
+ // The confirmation message to ask.
+ const message = chrome.i18n.getMessage('confirmPrompt');
+
+ if (!confirm(message)) {
+ window.close();
+ return;
+ }
+ }
+
+ // Notify background page to do the actual clear.
+ await chrome.runtime.sendMessage({action: 'runCleaner'});
+
+ window.close();
+}
+init();
javascript/background.js
javascript/clearhistory.js
javascript/options.js
+javascript/popup.js
javascript/util.js
views/background.html
views/options.html
+views/popup.html
"options_page": "views/options.html",
"browser_action": {
"default_icon": "images/icon32.png",
- "default_title": "__MSG_title__"
+ "default_title": "__MSG_title__",
+ "default_popup": "views/popup.html"
},
"icons": {
"16": "images/icon16.png",
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <script type='module' src='../javascript/popup.js'></script>
+ </head>
+<body bgcolor='black'>
+</body>
+</html>