-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
25 lines (24 loc) · 1006 Bytes
/
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
document.addEventListener('DOMContentLoaded', function() {
// Display saved highlights
chrome.storage.local.get({highlights: []}, function(result) {
let highlightsDiv = document.getElementById('highlights');
result.highlights.reverse().forEach(function(highlight) {
let div = document.createElement('div');
div.className = 'highlight';
div.innerHTML = `
<p>${highlight.text}</p>
<p class="date">${new Date(highlight.date).toLocaleString()}</p>
<a href="${highlight.url}" class ="url" target="_blank">${highlight.url}</a>
`;
highlightsDiv.appendChild(div);
});
});
// Handle the "Clear All" button
document.getElementById('clear-button').addEventListener('click', function() {
if (confirm("Are you sure you want to clear all highlights?")) {
chrome.storage.local.set({highlights: []}, function() {
document.getElementById('highlights').innerHTML = ''; // Clear the displayed highlights
});
}
});
});