"optionsPrompt": {"message": "Prompt before deleting"},
"optionsCookies": {"message": "Clear cookies too"},
"optionsSaved": {"message": "Preferences saved!"},
+ "optionsAutoclear": {"message": "Automatically purge old entries"},
"confirmPrompt": {"message": "Are you sure you want to delete the history?"},
"notificationTitle": {"message": "History deleted successfully!"},
"notificationTime": {
}
#opt-time,
#opt-prompt,
-#opt-cookies {
+#opt-cookies,
+#opt-autoclear {
background-color: white;
clear: left;
margin: 5px auto;
* @type {string}
* @const
*/
- NO: 'no'
+ NO: 'no',
+
+ CLEANER_ALARM: 'auto-cleaner'
};
}
}
+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');
});
$('#optionsTimeFor')[0].innerText = chrome.i18n.getMessage('optionsTimeFor');
$('#optionsTimeStart')[0].innerText = chrome.i18n.getMessage('optionsTimeStart');
$('#optionsCookies')[0].innerText = chrome.i18n.getMessage('optionsCookies');
+ $('#optionsAutoclear')[0].innerText = chrome.i18n.getMessage('optionsAutoclear');
$('#optionsSaved > b')[0].innerText = chrome.i18n.getMessage('optionsSaved');
// Bind all the callbacks
var showPrompt = localStorage['prompt'] ||
(localStorage['prompt'] = CONSTANTS.YES);
var clearCookies = localStorage['cookies'] || CONSTANTS.NO;
+ var autoClear = localStorage['autoclear'] || CONSTANTS.NO;
$('input[name=timeStart]')[0].checked = (timeStart === CONSTANTS.YES);
$('input[name=time][value="' + time + '"]')[0].checked = true;
$('input[name=prompt]')[0].checked = (showPrompt === CONSTANTS.YES);
$('input[name=cookies]')[0].checked = (clearCookies === CONSTANTS.YES);
+ $('input[name=autoclear]')[0].checked = (autoClear === CONSTANTS.YES);
}
/**
"version": "1.5.0",
"description": "__MSG_description__",
"permissions": [
+ "alarms",
"tabs",
"history",
"cookies",
</div>
</div>
<hr>
+ <div id="opt-autoclear">
+ <div class="opt-name">
+ <b> </b>
+ </div>
+ <div class="opt-value">
+ <div class="opt-option">
+ <input name="autoclear" class="opt-chk" type="checkbox">
+ <div class="opt-label" id="optionsAutoclear"></div>
+ </div>
+ </div>
+ </div>
+ <hr>
<div id="optionsSaved">
<b></b>
</div>