diff options
| author | Jibon Costa <jiboncosta57@gmail.com> | 2020-03-26 13:39:02 +0600 |
|---|---|---|
| committer | Jibon Costa <jiboncosta57@gmail.com> | 2020-03-26 13:39:02 +0600 |
| commit | e000c457c8f0b6b58d6b1575ad69e0e30bc7f1c8 (patch) | |
| tree | d11f5c1beb94c7339b947421848f018ecca275eb /content_script.js | |
| download | bbb-recorder-e000c457c8f0b6b58d6b1575ad69e0e30bc7f1c8.tar.gz bbb-recorder-e000c457c8f0b6b58d6b1575ad69e0e30bc7f1c8.zip | |
first commit
Diffstat (limited to 'content_script.js')
| -rw-r--r-- | content_script.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/content_script.js b/content_script.js new file mode 100644 index 0000000..680ac6c --- /dev/null +++ b/content_script.js @@ -0,0 +1,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 = 'bbbrecorder' + window.postMessage({ type: 'REC_CLIENT_PLAY', data: { url: window.location.origin } }, '*') +} |
