-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
28 lines (21 loc) · 953 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
chrome.contextMenus.create({"title": "Hide posts from user", "contexts":['selection'],"onclick": genericOnClick});
function genericOnClick(info, tab) {
var selection = [info.selectionText];
chrome.storage.sync.get('blockedUserNames', function(result){
if(result.blockedUserNames == "" || result.blockedUserNames == null) {
chrome.storage.sync.set({'blockedUserNames': selection}, function() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: "refresh"}, function(response) {});
});
});
return;
}
storedValues = result.blockedUserNames;
storedValues.push(selection);
chrome.storage.sync.set({'blockedUserNames': storedValues}, function() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: "refresh"}, function(response) {});
});
});
});
}