-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
executable file
·46 lines (36 loc) · 925 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
let clearing = false
// Listen for our extension icon to be clicked then open options page
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.runtime.openOptionsPage()
})
function clearHistory() {
if (clearing) {
return
}
clearing = true
let domains = []
chrome.storage.sync.get({ domains: [] }, options => {
domains = options.domains
// Loop through each banned domain and delete all history entries for it
domains.forEach(function(domain) {
chrome.history.search(
{
text: domain
},
historyItems => {
historyItems.forEach(historyItem => {
chrome.history.deleteUrl({
url: historyItem.url
})
})
}
)
})
clearing = false
})
}
chrome.alarms.create('checkNewTasks', {
periodInMinutes: 1
})
chrome.alarms.onAlarm.addListener(clearHistory)
clearHistory()