client for blocking

This commit is contained in:
2020-09-20 22:24:57 +02:00
parent c078f3150e
commit 77564060e2
12 changed files with 81 additions and 22 deletions

44
src/client/index.js Normal file
View File

@@ -0,0 +1,44 @@
import browser from 'webextension-polyfill'
let wrapper
function init() {
wrapper = window.document.createElement('div')
Object.assign(wrapper.style, {
display: 'none',
position: 'fixed',
top: '0',
left: '0',
width: '100vw',
height: '100vh',
backgroundColor: '#ffffff',
zIndex: '999999999',
})
wrapper.classList.add('ora--wrapper')
wrapper.classList.add('hidden')
const inner = window.document.createElement('div')
Object.assign(inner.style, {
fontFamily: `-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif`,
margin: '3em auto',
width: '100%',
maxWidth: '20em',
})
inner.innerHTML = `
<h1>Overtime ⏱</h1>
<p>You have no time left on this website 🥺</p>
`
wrapper.appendChild(inner)
window.document.body.appendChild(wrapper)
}
async function check() {
if (window.document.hidden) return
console.log('Checking')
const isBlocked = await browser.runtime.sendMessage(window.location.host)
wrapper.style.display = isBlocked ? 'initial' : 'none'
}
init()
setInterval(check, 5000)
check()