Skip to content

Instantly share code, notes, and snippets.

@xPaw
Last active July 31, 2024 07:01
Show Gist options
  • Save xPaw/65e7abcf5c1db5cfc1114fbc2bb66632 to your computer and use it in GitHub Desktop.
Save xPaw/65e7abcf5c1db5cfc1114fbc2bb66632 to your computer and use it in GitHub Desktop.

Revisions

  1. xPaw revised this gist Jul 29, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix-discord-audio-capture.user.js
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@
    // @version 1.0.0
    // @description Disable audio processing when broadcasting, force 60 FPS capture
    // @match https://discord.com/*
    // @icon https://discord.com/favicon.ico
    // @downloadURL https://gist.github.com/xPaw/65e7abcf5c1db5cfc1114fbc2bb66632/raw/fix-discord-audio-capture.user.js
    // @icon data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%235865F2' d='M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24Zm0 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20ZM11 6v12a1 1 0 1 1-2 0V6a1 1 0 1 1 2 0ZM7 9v6a1 1 0 1 1-2 0V9a1 1 0 1 1 2 0Zm8-1v8a1 1 0 1 1-2 0V8a1 1 0 1 1 2 0Zm4 3v3a1 1 0 1 1-2 0v-3a1 1 0 1 1 2 0Z'/%3E%3C/svg%3E
    // @grant unsafeWindow
    // ==/UserScript==

  2. xPaw revised this gist Jul 29, 2024. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions fix-discord-audio-capture.user.js
    Original file line number Diff line number Diff line change
    @@ -25,10 +25,5 @@ unsafeWindow.navigator.mediaDevices.getDisplayMedia = function monkeyPatchedGetD
    };
    }

    if (constraints.video.frameRate === 30)
    {
    constraints.video.frameRate = 60;
    }

    return originalGetDisplayMedia.apply(this, [constraints]);
    };
  3. xPaw revised this gist Jul 29, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix-discord-audio-capture.user.js
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@
    // @description Disable audio processing when broadcasting, force 60 FPS capture
    // @match https://discord.com/*
    // @icon https://discord.com/favicon.ico
    // @downloadURL https://gist.github.com/xPaw/65e7abcf5c1db5cfc1114fbc2bb66632/raw/fix-discord-audio-capture.user.js
    // @grant unsafeWindow
    // ==/UserScript==

    @@ -22,7 +23,6 @@ unsafeWindow.navigator.mediaDevices.getDisplayMedia = function monkeyPatchedGetD
    echoCancellation: false,
    noiseSuppression: false,
    };
    //constraints.systemAudio = 'include';
    }

    if (constraints.video.frameRate === 30)
  4. xPaw created this gist Jul 29, 2024.
    34 changes: 34 additions & 0 deletions fix-discord-audio-capture.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    // ==UserScript==
    // @name Fix audio quality in Discord screen capture
    // @namespace xpaw-fix-discord-audio-capture
    // @author xPaw
    // @version 1.0.0
    // @description Disable audio processing when broadcasting, force 60 FPS capture
    // @match https://discord.com/*
    // @icon https://discord.com/favicon.ico
    // @grant unsafeWindow
    // ==/UserScript==

    const originalGetDisplayMedia = unsafeWindow.navigator.mediaDevices.getDisplayMedia;

    /** @param {DisplayMediaStreamOptions} constraints */
    unsafeWindow.navigator.mediaDevices.getDisplayMedia = function monkeyPatchedGetDisplayMedia(constraints)
    {
    if (constraints.audio === true)
    {
    constraints.audio =
    {
    autoGainControl: false,
    echoCancellation: false,
    noiseSuppression: false,
    };
    //constraints.systemAudio = 'include';
    }

    if (constraints.video.frameRate === 30)
    {
    constraints.video.frameRate = 60;
    }

    return originalGetDisplayMedia.apply(this, [constraints]);
    };