samantas5855 / WebRTC effects remover

// ==UserScript==
// @name         WebRTC effects remover
// @namespace    https://github.com/edisionnano
// @version      0.1
// @updateURL https://openuserjs.org/meta/samantas5855/WebRTC_effects_remover.meta.js
// @description  Forcefully disable webrtc effects
// @author       Samantas5855
// @match        https://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var hidden = {
        enumerateDevices: navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices),
        getUserMedia: navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices),
    }
    navigator.mediaDevices.getUserMedia = constraints => navigator.mediaDevices.enumerateDevices().then(devices => {
        for (let x = 0; x < devices.length; x++) {
            if (devices[x].kind == "audioinput" && constraints.audio) {
                if (constraints.audio === true) constraints.audio = {}
                constraints.audio.autoGainControl = {exact: false}
                constraints.audio.channelCount = {exact: 2}
                constraints.audio.echoCancellation = {exact: false}
                //constraints.audio.latency = {exact: 0}
                constraints.audio.noiseSuppression = {exact: false}
                //constraints.audio.sampleRate = {exact: 48000}
                //constraints.audio.latency = {exact: 16}
                //constraints.audio.latency = {exact: 1.0}
            }
        }
        return hidden.getUserMedia(constraints)
    })
})();