1
0
mirror of https://github.com/dani/vroom.git synced 2024-06-23 18:19:12 +02:00
vroom/chrome-extension/content.js
Daniel Berteaud 536143bdf0 Update screen sharing
Since Chrome 34, a new API for screen sharing is available (the previous one using the flag will probably be deprecated soon)
This commit adds:
- Source of a simple Chrome extension to use this new API (which is a perfect copy of the sample extension given by &yet here: https://github.com/HenrikJoreteg/getScreenMedia
- Adapt help page
- New modal dialog to prompt user to install the extension from Google Web Store
- Better error messages if you can't share your screen

Should fix #7
2014-05-01 21:35:07 +02:00

15 lines
507 B
JavaScript

/* the chrome content script which can listen to the page dom events */
var channel = chrome.runtime.connect();
channel.onMessage.addListener(function (message) {
console.log('channel message', message);
window.postMessage(message, '*');
});
window.addEventListener('message', function (event) {
if (event.source != window)
return;
if (!event.data && (event.data.type == 'getScreen' || event.data.type == 'cancelGetScreen'))
return;
channel.postMessage(event.data);
});