Skip to content

Instantly share code, notes, and snippets.

@chelovekula
Forked from unixpickle/spoof.js
Created March 5, 2019 14:36
Show Gist options
  • Save chelovekula/6ac6e879e27784b6694d1d4b9835737a to your computer and use it in GitHub Desktop.
Save chelovekula/6ac6e879e27784b6694d1d4b9835737a to your computer and use it in GitHub Desktop.
getUserMedia() spoof
function fakeGetUserMedia(options) {
var canvas = document.createElement('canvas');
canvas.width = 640;
canvas.height = 480;
var result = new Promise((resolve, reject) => {
setTimeout(() => {
var ctx = canvas.getContext('2d');
ctx.font = '100px sans-serif';
ctx.fillText('💩', 200, 200);
resolve(canvas.captureStream(30));
}, 100);
});
return result;
}
navigator.getUserMedia = fakeGetUserMedia;
navigator.webkitGetUserMedia = fakeGetUserMedia;
navigator.mediaDevices.getUserMedia = fakeGetUserMedia;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment