-
Notifications
You must be signed in to change notification settings - Fork 62
/
content_script.js
23 lines (21 loc) · 823 Bytes
/
content_script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
window.onload = () => {
if (window.recorderInjected) return
Object.defineProperty(window, 'recorderInjected', { value: true, writable: false })
// Setup message passing
const port = chrome.runtime.connect(chrome.runtime.id)
port.onMessage.addListener(msg => window.postMessage(msg, '*'))
window.addEventListener('message', event => {
// Relay client messages
if (event.source === window && event.data.type) {
port.postMessage(event.data)
}
if(event.data.type === 'PLAYBACK_COMPLETE'){
port.postMessage({ type: 'REC_STOP' }, '*')
}
if(event.data.downloadComplete){
document.querySelector('html').classList.add('downloadComplete')
}
})
document.title = 'puppetcam'
window.postMessage({ type: 'REC_CLIENT_PLAY', data: { url: window.location.origin } }, '*')
}