-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
26 lines (23 loc) · 900 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
26
document.addEventListener('DOMContentLoaded', function() {
const noteInput = document.getElementById('noteInput');
const saveButton = document.getElementById('saveButton');
// Load saved note for the current URL
browser.tabs.query({ active: true, currentWindow: true }).then(tabs => {
const currentUrl = tabs[0].url;
browser.storage.local.get(currentUrl).then(data => {
if (data[currentUrl]) {
noteInput.value = data[currentUrl];
}
});
});
// Save note to local storage for the current URL
saveButton.addEventListener('click', function() {
browser.tabs.query({ active: true, currentWindow: true }).then(tabs => {
const currentUrl = tabs[0].url;
const note = noteInput.value;
const data = {};
data[currentUrl] = note;
browser.storage.local.set(data);
});
});
});