YouTube Alternative frontends

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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
)