Created
October 25, 2018 16:43
-
-
Save unixpickle/31a9e959b1e765c4ab7cb4fee659e9f4 to your computer and use it in GitHub Desktop.
getUserMedia() spoof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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