Greasy Fork is available in English.

YT-FIXED

Fixes media skip keys and adds volume control hotkeys (ALT+1|2|3|4|)

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         YT-FIXED
// @namespace    https://www.youtube.com/Zimekk
// @version      2.0
// @icon         https://www.youtube.com/s/desktop/80e4974c/img/favicon_144.png
// @description  Fixes media skip keys and adds volume control hotkeys (ALT+1|2|3|4|)
// @author       Zimeh
// @match        *://*.youtube.com/*
// @run-at       document-end
// @grant        GM_getResourceText
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @grant        GM_getResourceURL
// @grant        GM_xmlhttpRequest
// ==/UserScript==

setInterval(function() {
    const volumes = ['0.01', '0.1', '0.5', '1']

    function setVol(vol) {
        var data = sessionStorage['yt-player-volume'] ? JSON.parse(sessionStorage['yt-player-volume']) : JSON.parse(localStorage['yt-player-volume'])
        var subData = JSON.parse(data.data)
        if (!vol) vol = subData.volume / 100
        document.getElementsByTagName('video')[0].volume = vol
        subData.volume = vol * 100
        data.data = JSON.stringify(subData)
        localStorage['yt-player-volume'] = sessionStorage['yt-player-volume'] = JSON.stringify(data)
    }

    if (!window.navigator.mediaSession.metadata.canSkip) {

        window.navigator.mediaSession.metadata.canSkip = true

        window.navigator.mediaSession.setActionHandler('previoustrack', function() {
            if (document.getElementsByClassName('ytp-prev-button')[0] && document.getElementsByClassName('ytp-prev-button')[0].style.display !== 'none') document.getElementsByClassName('ytp-prev-button')[0].click();
            else history.back()
        });

        window.navigator.mediaSession.setActionHandler('nexttrack', function() {
            document.getElementsByClassName('ytp-next-button')[0].click()
        });

        document.addEventListener('keydown', (event) => {
            const code = parseInt(event.key) - 1
            if (!isNaN(code) && volumes[code] && event.altKey) setVol(volumes[code])
        })
    }

    if (document.getElementsByTagName('video')[0]) setVol()
}, 1000)