-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
66 lines (54 loc) · 1.87 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var container = document.getElementById('ordered-list');
chrome.storage.sync.get(['repo'], (repo) => {
console.log(repo.repo);
if (!repo.repo)
document.getElementById('name').innerHTML = 'rj200113/Test-repo';
else document.getElementById('name').innerHTML = repo.repo;
});
function getNotification() {
chrome.storage.sync.get('key', (result) => {
const arr = result.key;
arr.forEach((element) => {
var detail = {
title: element.title,
url: element.url,
};
localStorage.setItem(element.title, JSON.stringify(detail));
});
for (var i = 0; i < localStorage.length; i++) {
var detail = JSON.parse(localStorage.getItem(localStorage.key(i)));
const list = document.createElement('li');
list.classList.add('list-group-item');
list.classList.add('d-flex');
list.classList.add('justify-content-between');
list.classList.add('align-items-start');
const link = document.createElement('a');
const heading = document.createElement('div');
const subheading = document.createElement('div');
subheading.classList.add('fw-bold');
heading.classList.add('ms-2');
heading.classList.add('me-auto');
heading.innerText = detail.title;
heading.appendChild(subheading);
link.innerHTML = 'detail.title';
link.href = detail.url;
link.innerText = 'Click here';
subheading.appendChild(link);
list.appendChild(heading);
container.appendChild(list);
}
});
}
getNotification();
// setInterval(getNotification, 2000);
// window.addEventListener('storage', getNotification);
var btn = document.getElementById('btn');
btn.addEventListener('click', () => {
chrome.storage.sync.remove(['key'], function () {
// Your code
// This is an asyn function
localStorage.clear();
container.innerHTML = '';
console.log('deleted');
});
});