}
}
+function runCleaner() {
+ var clearCookies = localStorage['cookies'] || CONSTANTS.NO;
+
+ if (clearCookies === CONSTANTS.YES) {
+ clearCookies(clearHistory);
+ } else {
+ clearHistory();
+ }
+}
+
/**
* Executes when the user clicks the browser action. Uses stored values from
* {@code localStorage}
chrome.browserAction.onClicked.addListener(function(tab) {
// Get the value from localStorage
var showPrompt = localStorage['prompt'] || CONSTANTS.YES;
- var clearCookies = localStorage['cookies'] || CONSTANTS.NO;
// The confirmation message to ask
var message = chrome.i18n.getMessage('confirmPrompt');
if (!confirm(message))
return;
}
- if (clearCookies === CONSTANTS.YES) {
- clearCookies(clearHistory);
- } else {
- clearHistory();
- }
+ runCleaner();
+});
+
+chrome.alarms.create(CONSTANTS.CLEANER_ALARM, {
+ // First fire 10 minutes from now.
+ 'when': Date.now() + (10 * 60 * 1000),
+ 'periodInMinutes': 24 * 60
+});
+
+chrome.alarms.onAlarm.addListener(function(alarm) {
+ var autoCleaner = localStorage['autoclear'] || CONSTANTS.NO;
+ if (autoCleaner === CONSTANTS.YES)
+ runCleaner();
+ console.log('running');
});