import browser from 'webextension-polyfill' import { readable } from 'svelte/store' async function check(set) { if (window.document.hidden) return const isBlocked = await browser.runtime.sendMessage({ type: 'check', host: window.location.host, }) set(isBlocked) } export const blocked = new readable(false, (set) => { check(set) const interval = setInterval(() => check(set), 1000) return () => clearInterval(interval) })