-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
17 lines (15 loc) · 723 Bytes
/
popup.js
File metadata and controls
17 lines (15 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
document.addEventListener('DOMContentLoaded', function() {
var checkbox = document.getElementById('toggleFeature');
// Load the current state of the feature
chrome.storage.sync.get('enableFeature', function(data) {
checkbox.checked = data.enableFeature !== false; // Set the checkbox state
});
// Save the current state of the feature
checkbox.addEventListener('change', function() {
chrome.storage.sync.set({enableFeature: checkbox.checked});
// Send a message to the content script
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {featureEnabled: checkbox.checked});
});
});
});