-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
28 lines (24 loc) · 1.27 KB
/
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
27
28
document.addEventListener('DOMContentLoaded', function () {
var videosDarkModeCheckbox = document.getElementById('videosCheckbox');
var imagesDarkModeCheckbox = document.getElementById('imagesCheckbox');
chrome.storage.sync.get('videosCheckbox', function (data) {
videosDarkModeCheckbox.checked = data.videosCheckbox || false;
});
chrome.storage.sync.get('imagesCheckbox', function (data) {
imagesDarkModeCheckbox.checked = data.imagesCheckbox || false;
});
videosDarkModeCheckbox.addEventListener('change', function () {
chrome.storage.sync.set({ 'videosCheckbox': videosDarkModeCheckbox.checked });
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, { videosDarkMode: videosDarkModeCheckbox.checked });
});
});
imagesDarkModeCheckbox.addEventListener('change', function () {
chrome.storage.sync.set({ 'imagesCheckbox': imagesDarkModeCheckbox.checked });
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, { imagesDarkMode: imagesDarkModeCheckbox.checked });
});
});
});