-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
53 lines (42 loc) · 1.22 KB
/
main.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
47
48
49
50
51
52
53
// https://sites.google.com/site/tredashx/
function set(key, value){
localStorage.setItem(key, Number(value))
}
function get(key){
return Number(localStorage.getItem(key))
}
function playBadge(){
console.log('enabled history logging')
chrome.browserAction.setBadgeText({text: '▶'});
}
function stopBadge(){
console.log('disabled history logging')
chrome.browserAction.setBadgeText({text: '■'})
}
chrome.runtime.onInstalled.addListener(function(details){
if(details.reason == "install"){
alert('Quick start: Click the extension icon to enable/disable history logging. Play badge = History Enabled; Stop badge = History Disabled')
set('step', 1)
set('stop', 1)
stopBadge()
}
});
chrome.browserAction.onClicked.addListener(function (){ // will not be used after first install unless its clicked for the first time
set('step', get('step') + 1)
if (get('step') == 1){
stopBadge()
set('stop', 1)
}
if (get('step') == 2){
set('step', 0)
playBadge()
set('stop', 0)
}
})
chrome.history.onVisited.addListener(function(item) {
if (get('stop') == 1) {
console.log('stop is on')
chrome.history.deleteUrl({"url": item.url});
}
});
// tre-x was here