您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Overrides Discord Web webcam with your screen share stream (mirrored preview locally, normal to others).
// ==UserScript== // @name Discord Screen Share as Webcam // @namespace https://greasyfork.org/users/fdslalkad // @version 1.0 // @description Overrides Discord Web webcam with your screen share stream (mirrored preview locally, normal to others). // @author Your Name // @match https://discord.com/* // @grant none // @run-at document-start // @license MIT // ==/UserScript== (() => { // Store original getUserMedia if (!window._originalGetUserMedia) { window._originalGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices); } let fakeStream = null; // Request screen share stream once and save it navigator.mediaDevices.getDisplayMedia({ video: true, audio: false }).then((stream) => { fakeStream = stream; console.log("Screen capture stream ready for override."); // Create a mirrored preview video for local user const previewVideo = document.createElement('video'); previewVideo.style.position = 'fixed'; previewVideo.style.bottom = '10px'; previewVideo.style.right = '10px'; previewVideo.style.width = '320px'; previewVideo.style.zIndex = 9999; previewVideo.style.transform = 'scaleX(-1)'; // mirror horizontally locally previewVideo.autoplay = true; previewVideo.muted = true; previewVideo.srcObject = stream; document.body.appendChild(previewVideo); }).catch((err) => { console.error("Failed to get screen capture:", err); }); // Override getUserMedia to provide fake stream navigator.mediaDevices.getUserMedia = function (constraints) { if (constraints && constraints.video && fakeStream) { console.log("Returning fake screen capture stream."); return Promise.resolve(fakeStream); } return window._originalGetUserMedia(constraints); }; console.log("getUserMedia overridden to provide screen share stream."); })();