XYZT / Youtube +Buttons

// ==UserScript==
// @name         Youtube +Buttons
// @version      1.0
// @description  adding a button's to videos (THUMBNAIL, DOWNLOAD, SOCIAL BLADE)
// @copyright    2021, XYZT (https://xyzt.cz)
// @match        https://www.youtube.com/watch?v=*
// @icon         https://www.google.com/s2/favicons?domain=youtube.com
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @grant        none
// @license      MIT
// ==/UserScript==

// ==OpenUserJS==
// @author       XYZT
// ==/OpenUserJS==

(function() {
    'use strict';

    var XYZT_CLASS = "xyzt_link";
    var XYZT_CSS = `
    .`+XYZT_CLASS+` {
        text-decoration: none;
        padding: 0 1vw;
        margin: 0 .5vw 0 0;
        border: 1px solid dodgerblue;
        border-radius: 10px;
        float: right;
        color: dodgerblue;
        transition: all ease-in-out .2s;
        -o-transition: all ease-in-out .2s;
        -ms-transition: all ease-in-out .2s;
        -moz-transition: all ease-in-out .2s;
        -webkit-transition: all ease-in-out .2s;
    }

    .`+XYZT_CLASS+`:hover {
        border: 1px solid orange;
        color: orange;
    }

    .`+XYZT_CLASS+`:active {
        border: 1px solid red;
        color: red;
    }
    `;

    $(document).ready(function(){
        function addStyles(s=XYZT_CSS, out=document.body){
            let styles = document.createElement("style");
            styles.innerHTML = s;
            out.append(styles);
        }

        function clink(text, href, target=true, cls=XYZT_CLASS){
            let a = document.createElement("a");
            a.textContent = text;
            a.href = href;
            if(target){
                a.target = "_blank";
            }
            a.className = cls;
            return a;
        }

        if(window.location.href.includes("https://www.youtube.com/watch?v=")){
            let XYZT_CHANNEL_ID = $("ytd-channel-name a")[1].href.split("/").reverse()[0];
            let XYZT_VIDEO_ID = window.location.href.match(/watch\?v\=(.*)(?:&)/)[1];

            addStyles();

            let videoTitle = $("h1 yt-formatted-string");

            // create social blade link
            let socialBladeBtn = clink("Social Blade", "https://socialblade.com/youtube/s/?q=" + XYZT_CHANNEL_ID);
            $(videoTitle).append(socialBladeBtn);

            // create download link
            let downloadBtn = clink("Download", window.location.href.replace("youtube.com", "youtubepp.com"));
            $(videoTitle).append(downloadBtn);

            // create thumbnail link
            let thumbnailBtn = clink("Thumbnail", "https://img.youtube.com/vi/" + XYZT_VIDEO_ID + "/0.jpg");
            $(videoTitle).append(thumbnailBtn);
        }
    });
})();