YouTube Alternative frontends

10/21/2023, 2:15:40 PM

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        YouTube Alternative frontends
// @namespace   Violentmonkey Scripts
// @match       *://www.youtube.com/watch?v=*
// @grant       none
// @version     1.1
// @author      -
// @description 10/21/2023, 2:15:40 PM
// @require https://code.jquery.com/jquery-3.7.1.min.js
// @run-at document-end
 // @license GPLv3
// ==/UserScript==
setInterval(
  function() {
    let subButton = document.querySelector("#subscribe-button")
    let videoId = window.location.href;
    videoId = videoId.substring(videoId.search("=") + 1)
    let frontendLinks =
    [
      ["Piped", "https://piped.video/watch?v=" + videoId],
      ["Invidious", "https://yewtu.be/watch?v=" + videoId]
    ];


    let button;
    let youtubeButtonAttrs = 'class="yt-spec-button-shape-next yt-spec-button-shape-next--filled yt-spec-button-shape-next--mono yt-spec-button-shape-next--size-m" type="button" id="dropdownMenuButton" aria-haspopup="true" aria-expanded="false" style="padding: 10px; margin: 10px;"'
    for (let i = 0; i < frontendLinks.length; i++){
      button = $("#" + frontendLinks[i][0])
      if (button){
        button.remove()
      }
      button = $(
        `
          <div class="style-scope ytd-watch-metadata"id="${frontendLinks[i][0]}">
            <button ${youtubeButtonAttrs}>
              <a href="${frontendLinks[i][1]}" target="_blank">
                ${frontendLinks[i][0]}
              </a>
            </button>
          </div>
        `
      )
      subButton.parentNode.insertBefore(button[0], subButton);
    }
  },
  3000
)