-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclipboard.js
45 lines (40 loc) · 1.92 KB
/
clipboard.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
const renderClipboard = () => {
chrome.storage.local.get(null, (items) => {
const localStorageClipboard = document.querySelector('#localStorage-clipboard');
if (items?.localStorageClipboard) {
let tableData = '';
tableData = '<br>' + '<div class="table-responsive"><table class="table table-sm">';
tableData += '<thead><tr><th scope="col">Key</th><th scope="col">Value</th></tr></thead><tbody>';
Object.entries(items?.localStorageClipboard).forEach(e => {
tableData += `<tr><td>${e[0]}</td><td>${e[1]}</td></tr>`;
});
tableData += '</tbody></table></div>';
localStorageClipboard.innerHTML = tableData;
} else {
localStorageClipboard.innerHTML = 'Nothing Here ...';
}
const sessionStorageClipboard = document.querySelector('#sessionStorage-clipboard');
if (items?.sessionStorageClipboard) {
let tableData2 = '';
tableData2 = '<br>' + '<div class="table-responsive"><table class="table table-sm">';
tableData2 += '<thead><tr><th scope="col">Key</th><th scope="col">Value</th></tr></thead><tbody>';
Object.entries(items?.sessionStorageClipboard).forEach(e => {
tableData2 += `<tr><td>${e[0]}</td><td>${e[1]}</td></tr>`;
});
tableData2 += '</tbody></table></div>';
sessionStorageClipboard.innerHTML = tableData2;
} else {
sessionStorageClipboard.innerHTML = 'Nothing Here ...';
}
});
};
chrome.storage.onChanged.addListener((changes, namespace) => {
renderClipboard();
});
renderClipboard();
document.querySelector('#clear-localStorage-clipboard').onclick = () => {
chrome.storage.local.remove("localStorageClipboard");
};
document.querySelector('#clear-sessionStorage-clipboard').onclick = () => {
chrome.storage.local.remove("sessionStorageClipboard");
};