Initial commit
This commit is contained in:
commit
e90ff542b0
8 changed files with 250 additions and 0 deletions
32
popup.js
Normal file
32
popup.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
const toggle = document.getElementById('toggle');
|
||||
const status = document.getElementById('status');
|
||||
|
||||
chrome.runtime.sendMessage({ action: 'getBlockingState' }, (response) => {
|
||||
if (response && response.enabled !== undefined) {
|
||||
const blockingEnabled = response.enabled;
|
||||
|
||||
if (blockingEnabled) {
|
||||
toggle.classList.add('active');
|
||||
status.textContent = 'Blocking is ON';
|
||||
} else {
|
||||
toggle.classList.remove('active');
|
||||
status.textContent = 'Blocking is OFF';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
toggle.addEventListener('click', function () {
|
||||
const isActive = toggle.classList.toggle('active');
|
||||
|
||||
if (isActive) {
|
||||
status.textContent = 'Blocking is ON';
|
||||
} else {
|
||||
status.textContent = 'Blocking is OFF';
|
||||
}
|
||||
|
||||
chrome.runtime.sendMessage({
|
||||
action: 'toggleBlocking',
|
||||
enabled: isActive
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue