-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
41 lines (30 loc) · 1.16 KB
/
popup.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
window.onload = function () {
document.getElementById('save').onclick = function() {
var value = document.getElementById('term').value;
chrome.storage.sync.get({storedTerms: []}, function(data){
console.log(data);
var storedTerms = data.storedTerms;
/*************** TO DO *****************/
// check if term is already in the array
// if not in array, push
storedTerms.push(value);
// if in array, display error message
chrome.storage.sync.set({storedTerms: storedTerms}, function () {
/*************** TO DO *****************/
// let the user know the term was added successfully
// clear the input field
chrome.storage.sync.get('storedTerms', function (data) {
document.getElementById('term').value = '';
});
});
})
}
document.getElementById('viewTerms').onclick = function() {
chrome.tabs.create({'url':'manage.html'});
}
document.getElementById('deleteTerms').onclick = function() {
chrome.storage.sync.clear(function(){
});
}
// when a page loads, loop through storedTerms and search DOM for those terms and hide them
}