WebRTC media source switcher

Forcefully chose a specific webrtc input/output audio/video device

当前为 2020-04-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         WebRTC media source switcher
// @namespace    https://daniil.it
// @version      0.1
// @description  Forcefully chose a specific webrtc input/output audio/video device
// @author       Daniil Gentili <[email protected]>
// @match        https://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var hidden = {
        enumerateDevices: navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices)
    }
    console.log("Lmao");
    navigator.mediaDevices.enumerateDevices = () => hidden.enumerateDevices().then(res => {
        var temp = {};
        var tempLabels = {};
        for (var i = 0; i < res.length; i++) {
            if (!temp[res[i].kind]) {
                temp[res[i].kind] = [];
                tempLabels[res[i].kind] = "Choose a "+res[i].kind+" device:\n";
            }
            temp[res[i].kind].push(res[i])
            tempLabels[res[i].kind] += temp[res[i].kind].length+": "+res[i].label+"\n"
        }
        console.log(temp)
        var newRes = [];

        for (let [key, value] of Object.entries(tempLabels)) {
            var choice = prompt(value);
            newRes.push(temp[key][choice-1]);
        }

        return newRes;
    })
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址