2017-03-12 14:59:11 +00:00
|
|
|
browser.idle.onStateChanged.addListener((state) => {
|
2017-02-07 23:31:13 +00:00
|
|
|
if (state == 'idle') {
|
2017-03-12 14:59:11 +00:00
|
|
|
browser.storage.local.get('days').then((res) => {
|
2017-02-08 22:51:07 +00:00
|
|
|
var days = res.days || 0;
|
2017-03-12 14:59:11 +00:00
|
|
|
if (days !== 0) {
|
2017-02-07 23:31:13 +00:00
|
|
|
var end = new Date();
|
|
|
|
end.setHours(0);
|
|
|
|
end.setMinutes(0);
|
|
|
|
end.setSeconds(0);
|
|
|
|
end.setMilliseconds(0);
|
2017-02-08 23:07:13 +00:00
|
|
|
end.setDate(end.getDate() - days);
|
2017-02-07 23:31:13 +00:00
|
|
|
browser.history.deleteRange({startTime: 0, endTime: end.getTime()});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|