Added addon files

This commit is contained in:
Joe Jarvis 2017-02-07 18:31:13 -05:00
parent 84f3df05ba
commit 6a3c6e74c5
7 changed files with 71 additions and 0 deletions

View file

@ -1,2 +1,8 @@
# HistoryCleaner
Firefox addon that deletes history older than a specified amount of days.
This addon is inspired by and is a WebExtension port of [Expire History By Days](https://addons.mozilla.org/en-US/firefox/addon/expire-history-by-days/).
Set the number of days to keep history items in the options page. Setting it to 0 will disable history deletion. The deletion will occur when the browser goes idle (after about 1 minute of inactivity).
The icon is from [Material Design Icons](https://materialdesignicons.com/)

15
background.js Normal file
View file

@ -0,0 +1,15 @@
browser.idle.onStateChanged.addListener(function(state) {
if (state == 'idle') {
browser.storage.local.get('days', function(res) {
if (res.days != 0) {
var end = new Date();
end.setHours(0);
end.setMinutes(0);
end.setSeconds(0);
end.setMilliseconds(0);
end.setDate(end.getDate() - res.days);
browser.history.deleteRange({startTime: 0, endTime: end.getTime()});
}
});
}
});

BIN
icons/icon-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

BIN
icons/icon-96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

21
manifest.json Normal file
View file

@ -0,0 +1,21 @@
{
"manifest_version": 2,
"name": "History Cleaner",
"version": "1",
"description": "Deletes history older than a specified amount of days.",
"icons": {
"48": "icons/icon-48.png",
"96": "icons/icon-96.png"
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"history",
"storage",
"idle"
],
"options_ui": {
"page": "options.html"
}
}

13
options.html Normal file
View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form>
<label>Number of days to keep history (set to 0 to disable): <input id="days" type="number"></label>
<input id="submit" type="submit" value="Save">
</form>
<script src="options.js"></script>
</body>
</html>

16
options.js Normal file
View file

@ -0,0 +1,16 @@
function saveOptions(e) {
browser.storage.local.set({
days: document.querySelector("#days").value
});
e.preventDefault();
}
function restoreOptions() {
var gettingItem = browser.storage.local.get('days');
gettingItem.then((res) => {
document.querySelector("#days").value = res.days || '0';
});
}
document.addEventListener('DOMContentLoaded', restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);