Add Android support + now don't block the whole page if a sub-resource is served via CF
This commit is contained in:
parent
e90ff542b0
commit
b73bf5d4ca
7 changed files with 132 additions and 114 deletions
42
popup.js
42
popup.js
|
|
@ -1,32 +1,20 @@
|
|||
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;
|
||||
function render(enabled) {
|
||||
toggle.classList.toggle('active', enabled);
|
||||
toggle.setAttribute('aria-checked', String(enabled));
|
||||
status.textContent = enabled ? 'Blocking is ON' : 'Blocking is OFF';
|
||||
}
|
||||
|
||||
if (blockingEnabled) {
|
||||
toggle.classList.add('active');
|
||||
status.textContent = 'Blocking is ON';
|
||||
} else {
|
||||
toggle.classList.remove('active');
|
||||
status.textContent = 'Blocking is OFF';
|
||||
}
|
||||
}
|
||||
// read and write the state straight from storage, so the toggle works even
|
||||
// if the background page is currently unloaded
|
||||
browser.storage.local.get({ blockingEnabled: true })
|
||||
.then(result => render(result.blockingEnabled))
|
||||
.catch(() => render(true));
|
||||
|
||||
toggle.addEventListener('click', () => {
|
||||
const enabled = !toggle.classList.contains('active');
|
||||
render(enabled);
|
||||
browser.storage.local.set({ blockingEnabled: enabled });
|
||||
});
|
||||
|
||||
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