Search code examples
javascripthtmlwebrtc

Block WebRTC via JavaScript


Is it possible somehow to block accesing to WebRTC API via JavaScript in Chrome?

I have a page, where I can call JavaScript code before other part of page is loaded and I need to disable WebRTC API that will be called later.

For example, maybe I can override some WebRTC classes or methods? If I want to disable document.write, I can easily do with next code

document.write = null;

Any ideas?


Solution

  • Sure:

    navigator.mediaDevices.getUserMedia =
    navigator.webkitGetUserMedia =
    navigator.mozGetUserMedia =
    navigator.getUserMedia =
    webkitRTCPeerConnection =
    RTCPeerConnection = undefined;
    

    Should work in all browsers.