-
-
Save chelovekula/6ac6e879e27784b6694d1d4b9835737a 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