ora/src/client/reporter.js

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)
}