-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopup.js
28 lines (27 loc) · 1.09 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
function deleteFromBlackList(blacklist, blockedAuthors, username) {
blockedAuthors.delete(username);
chrome.storage.sync.set({twignoreAuthors: Array.from(blockedAuthors)}, function() {
renderBlackList(blacklist, blockedAuthors)
})
}
function renderBlackList(blacklist, blockedAuthors) {
blacklist.innerHTML = ''
blockedAuthors.forEach(function(author) {
let item = document.createElement('li');
item.innerHTML = `<span>${author}</span><span style="float: right"><a href="#">Разблокировать</a></span>`
item.addEventListener('click', function () {
deleteFromBlackList(blacklist, blockedAuthors, author)
})
blacklist.appendChild(item)
})
}
window.onload = function() {
let blacklist = document.getElementById('blacklist')
let blockedAuthors = new Set();
chrome.storage.sync.get(['twignoreAuthors'], function(result) {
if (result.twignoreAuthors !== undefined) {
blockedAuthors = new Set(result.twignoreAuthors)
}
renderBlackList(blacklist, blockedAuthors)
})
}