-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
21 lines (18 loc) · 862 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
document.addEventListener('DOMContentLoaded', function () {
var toggleButton = document.getElementById('toggleButton');
// Check the current state and update the button
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { action: 'getState' }, function(response) {
if (response && response.zenReadEnabled) {
toggleButton.classList.add('active');
}
});
});
toggleButton.addEventListener('click', function () {
var isActive = toggleButton.classList.contains('active');
toggleButton.classList.toggle('active', !isActive);
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { action: 'toggleZenRead' });
});
}, false);
});