From 6a3c6e74c5006d5b69f57661187776525f227646 Mon Sep 17 00:00:00 2001 From: Joe Jarvis Date: Tue, 7 Feb 2017 18:31:13 -0500 Subject: [PATCH] Added addon files --- README.md | 6 ++++++ background.js | 15 +++++++++++++++ icons/icon-48.png | Bin 0 -> 846 bytes icons/icon-96.png | Bin 0 -> 1709 bytes manifest.json | 21 +++++++++++++++++++++ options.html | 13 +++++++++++++ options.js | 16 ++++++++++++++++ 7 files changed, 71 insertions(+) create mode 100644 background.js create mode 100644 icons/icon-48.png create mode 100644 icons/icon-96.png create mode 100644 manifest.json create mode 100644 options.html create mode 100644 options.js diff --git a/README.md b/README.md index 306ff7c..dc479db 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/background.js b/background.js new file mode 100644 index 0000000..215d6ca --- /dev/null +++ b/background.js @@ -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()}); + } + }); + } +}); diff --git a/icons/icon-48.png b/icons/icon-48.png new file mode 100644 index 0000000000000000000000000000000000000000..e4044b4bd462fb83156777582ca255756d443593 GIT binary patch literal 846 zcmV-U1F`&xP)7pp+MGKN5 zrO=J_Z*VKER>2p#b0Jc75y8-Ap|InVR^ z-FxnNc@8~#{J*J1j`tLf;V_=T!*~dN_#MCCXMBsVaJ}0P00uFGAFw`6<0Agdh_{Yc%Np3uF)@)N{v!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(t&2~JrtI0|O*%~&jr@RfD8bT{wiL5Ql{y^G7h9c^gWqD~vKaUQNukhQ> zCU4WeGW0tF#F;%A4ICVD$})=e3avzuwv|UHk@JU{N4DRDv&VjpOG_Q_4!UG5mN9^AF*s}99fD=#p9Xx6 zZX(KXZBq}tg>2A;cJ#RYlC`$=y9g@(^N9qA) zA|HL5jI8}9A#-^8lwl%~NF)-8L?V$$Boc{4B3k|hA + + + + + +
+ + +
+ + + diff --git a/options.js b/options.js new file mode 100644 index 0000000..fd2d4a8 --- /dev/null +++ b/options.js @@ -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);