document.write('
The purpose of this page is to access your camera and microphone.
');
var port = chrome.runtime.connect();
var hints = location.href.split('?hints=')[1];
if (hints) {
hints = JSON.parse(hints);
} else {
hints = {
audio: true,
video: true
};
}
navigator.mediaDevices.getUserMedia(hints).then(function(stream) {
stream.getTracks().forEach(function(track) {
track.stop();
});
port.postMessage(hints);
window.close();
}).catch(function(e) {
port.postMessage({
error: e
});
var html = 'Unable to access your camera and microphone.
';
html += 'Please go to following pages and remove "getUserMedia" from blocked-list:
';
html += 'chrome://settings/content/microphone?search=camera
';
html += 'chrome://settings/content/microphone?search=microphone
';
if(e.message && e.message.toString().length) {
html += 'Error Message: ' + e.message + '
';
}
document.body.innerHTML = html;
});