Default Resolution - YouTube

Choose the default resolution for YouTube videos!

Stan na 06-06-2024. Zobacz najnowsza wersja.

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

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

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         Default Resolution - YouTube
// @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
// @version      2
// @description  Choose the default resolution for YouTube videos!
// @author       hacker09
// @match        https://m.youtube.com/watch?v=*
// @match        https://www.youtube.com/embed/*
// @match        https://www.youtube.com/watch?v=*
// @icon         https://www.youtube.com/s/desktop/03f86491/img/favicon.ico
// @run-at       document-end
// @grant        GM_getValue
// @grant        GM_setValue
// ==/UserScript==

setTimeout(() => {
  'use strict';
  if (GM_getValue('Default_Desktop_Resolution') === undefined) //If the Default_Resolution wasn't set yet
  { //Starts the if condition
    GM_setValue('Default_Desktop_Resolution', 'hd1080'); //Save the Default YT Desktop Resolution as 1080p
    GM_setValue('Default_Mobile_Resolution', 'tiny'); //Save the Default YT Mobile Resolution as 144p
  } //Finishes the if condition

  document.querySelector(".html5-main-video").addEventListener("play", (ev) => {
    ev.target.closest('#movie_player').setPlaybackQualityRange((navigator.userAgentData.mobile === true) ? GM_getValue('Default_Mobile_Resolution') : (ev.target.closest('#movie_player').getAvailableQualityLevels().includes(GM_getValue('Default_Desktop_Resolution')) === true) ? GM_getValue('Default_Desktop_Resolution') : ev.target.closest('#movie_player').getAvailableQualityLevels()[0]); //If the user is on mobile, use the default mobile resolution, otherwise if the default desktop resolution exists use it, or if it doesn't exist then use the highest resolution available
  }, { once: true });
}, 800);