Stoat Chat FPS Unlocker

Снимает лимит 15 FPS в Stoat Chat (LiveKit)

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Stoat Chat FPS Unlocker
// @namespace    http://tampermonkey.net/
// @license MIT
// @version      1.0
// @description  Снимает лимит 15 FPS в Stoat Chat (LiveKit)
// @match        *://*.stoat.chat/*
// @match        *://stoat.inkazap.space/*
// @match        *://localhost/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // 1. Перехват WebRTC параметров
    const originalSetParameters = RTCRtpSender.prototype.setParameters;
    RTCRtpSender.prototype.setParameters = function(parameters) {
        if (parameters && parameters.encodings) {
            parameters.encodings.forEach(function(enc) {
                if (enc.maxFramerate) enc.maxFramerate = 60;
                if (enc.maxBitrate) {
                    if (enc.rid === 'q') enc.maxBitrate = 1500000;
                    else if (enc.rid === 'h') enc.maxBitrate = 6000000;
                    else enc.maxBitrate = Math.max(enc.maxBitrate, 6000000);
                }
            });
        }
        return originalSetParameters.apply(this, arguments);
    };

    // 2. Принудительный contentHint = 'motion' для демонстрации экрана
    setInterval(() => {
        document.querySelectorAll('video').forEach(video => {
            if (video.srcObject) {
                video.srcObject.getVideoTracks().forEach(track => {
                    if (track.kind === 'video' && track.contentHint !== 'motion') {
                        track.contentHint = 'motion';
                    }
                });
            }
        });
    }, 2000);

    console.log('[Stoat FPS Unlocker] Активен: 60 FPS / 6 Mbps / motion');
})();