mirror of
https://github.com/cupcakearmy/ora.git
synced 2024-12-23 00:16:29 +00:00
20 lines
504 B
JavaScript
20 lines
504 B
JavaScript
|
import browser from 'webextension-polyfill'
|
||
|
|
||
|
let lastReported = 0
|
||
|
|
||
|
function logActivity() {
|
||
|
const now = Date.now()
|
||
|
// Limit reports to once every second
|
||
|
if (now - lastReported < 1000) return
|
||
|
lastReported = now
|
||
|
browser.runtime.sendMessage({
|
||
|
type: 'report',
|
||
|
})
|
||
|
}
|
||
|
|
||
|
export function init() {
|
||
|
window.document.addEventListener('mousemove', logActivity, false)
|
||
|
window.document.addEventListener('keydown', logActivity, false)
|
||
|
window.document.addEventListener('scroll', logActivity, false)
|
||
|
}
|