mirror of
https://github.com/cupcakearmy/ora.git
synced 2024-11-01 00:34:11 +01:00
18 lines
446 B
JavaScript
18 lines
446 B
JavaScript
|
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)
|
||
|
})
|