forked from tapaswenipathak/Blacklist-By-Words
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProcessKeywords.js
43 lines (37 loc) · 1.28 KB
/
ProcessKeywords.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
//Thanks : http://stackoverflow.com/questions/5364062/how-can-i-save-information-locally-in-my-chrome-extension
function save() {
var block_keywords = document.getElementById("block_keywords").value;
current_status.innerHTML = " Saving...";
chrome.storage.sync.set({"HidePost_block_keywords": block_keywords}, function() {
var current_status = document.getElementById("current_status");
current_status.innerHTML = " Saved";
setTimeout(function() {
current_status.innerHTML = "";
}, 750);
});
}
function restore() {
chrome.storage.sync.get("HidePost_block_keywords", function(response) {
var block_keywords = response["HidePost_block_keywords"];
if (!block_keywords) {
block_keywords = getSampleblock_keywords();
}
document.getElementById("block_keywords").value = block_keywords;
});
}
//Insert sample words
function getSampleblock_keywords() {
var sampleblock_keywords = [
"Intolerance",
"BJP",
"Congress",
"Modi",
"Intolerant",
"Communal"
];
return sampleblock_keywords.join(", ");
}
document.addEventListener("DOMContentLoaded", function() {
restore();
document.getElementById("save").addEventListener('click', save);
});