X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=javascript%2Fclearhistory.js;h=bae6a7a09f06ced0edc577ea35d5bb58771698d3;hb=a3c71eebbda67bf92f5f419dc39f76df1d27835b;hp=6cfa78562e94de461488ec642c1ce8bb13e4c0c1;hpb=c930a5d63083025d1ffe5dc29b08583b9ff44049;p=chrome-ext%2Fclearhistory-advance-fork.git diff --git a/javascript/clearhistory.js b/javascript/clearhistory.js index 6cfa785..bae6a7a 100644 --- a/javascript/clearhistory.js +++ b/javascript/clearhistory.js @@ -143,24 +143,14 @@ function runCleaner() { } /** - * 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) {