-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
24 lines (20 loc) · 824 Bytes
/
Copy pathpopup.js
File metadata and controls
24 lines (20 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// popup.js
document.addEventListener('DOMContentLoaded', function () {
const checkbox = document.getElementById('credit-score-toggle');
chrome.storage.local.get('creditScoreState', function (result) {
if (result.creditScoreState !== undefined) {
checkbox.checked = result.creditScoreState;
}
});
checkbox.addEventListener('change', function () {
chrome.storage.local.set({ 'creditScoreState': checkbox.checked }, function () {
console.log('State saved: ' + checkbox.checked);
// After saving, reload the active tab
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs[0]) {
chrome.tabs.reload(tabs[0].id);
}
});
});
});
});