-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.html
32 lines (31 loc) · 918 Bytes
/
background.html
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
<!DOCTYPE HTML>
<title>Background</title>
<script>
// initialize the store
if (!localStorage['savedLinks']) {
localStorage.setItem('savedLinks', JSON.stringify([]));
}
if (!localStorage['options']) {
localStorage.setItem('options', JSON.stringify({faviconDisabled : true}));
}
function bookmark(tab) {
var links = JSON.parse(localStorage['savedLinks']);
if (!links) { var links = []; }
chrome.tabs.remove(tab.id);
var linkObject = function createLinkObject() {
var result = {
url: tab.url,
title: tab.title,
favicon: tab.favIconUrl,
}
var date = new Date();
result.date = date.getTime();
return result;
}();
links.push(linkObject);
localStorage.setItem('savedLinks', JSON.stringify(links));
}
chrome.browserAction.onClicked.addListener(function(tab) {
bookmark(tab);
});
</script>