firstProject

createButtonForDownloadYoutubeVideo

Від 31.01.2020. Дивіться остання версія.

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.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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.

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

// ==UserScript==
// @name         firstProject
// @namespace    https://up.mewf.ru/
// @version      0.3
// @description  createButtonForDownloadYoutubeVideo
// @author       Klastor
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==
(function() {
    console.log("запустилассь функция");
    localStorage.setItem("linkNow", "https://www.youtube.com");
    window.addEventListener("hashchange", test());
    function test() {
        console.log("запустилассь функция test");

        if (localStorage.getItem("linkNow") != window.location.href) {
            console.log("зашли в иф функции тест");
            localStorage.setItem("oldLink", localStorage.getItem("linkNow"));
            localStorage.setItem("linkNow", window.location.href);
            let links = window.document.location.href.replace("w.y", "w.ssy");
            createButton(links);
        } else {
            console.log("елс функции тест");
            setTimeout(test, 60000);
        }
    }
    function createButton(links) {
        console.log("запустилассь функция links");

        if (!document.getElementsByTagName("butn")) {
            console.log("зашли в иф функция links");

            let btn = document.createElement("a");
            btn.href = links;
            btn.target = "_blank";
            btn.name = "butn";
            btn.title = "Скачать видео";
            //<!-- _______________________________________________________ -->
            let image = document.createElement("img");
            image.src =   "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGlkPSJGbGF0IiBoZWlnaHQ9IjUxMiIgdmlld0JveD0iMCAwIDUxMiA1MTIiIHdpZHRoPSI1MTIi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wIDAgMSAtMzItMzJ2LTQ4eiIgZGF0YS1vcmlnaW5hbD0iI0MzQzZDNyI+PC9wYXRoPjxwYXRoIGQ9Im0yNDggMTYwaC0xNmE4IDggMCAwIDEgMC0xNmgxNmE4IDggMCAwIDEgMCAxNnoiIGRhdGEtb3JpZ2luYWw9IiNDM0M2QzciPjwvcGF0aD48L2c+PHBhdGggZD0ibTE4NC44NzkgNDIzLjk5NSA1NS4yOTMtNjQuNjExLTMxLjk5OC4zNTEtMS4wNTUtOTUuOTk0LTQ3Ljk5Ny41MjggMS4wNTUgOTUuOTk0LTMxLjk5OC4zNTF6IiBmaWxsPSIjZjc5NTM5IiBkYXRhLW9yaWdpbmFsPSIjRjc5NTM5IiBjbGFzcz0iYWN0aXZlLXBhdGgiIGRhdGEtb2xkX2NvbG9yPSIjZjc5NTM5IiBzdHlsZT0iZmlsbDojRTJEN0NEIj48L3BhdGg+PC9nPiA8L3N2Zz4=";
            image.name = "icon";
            image.alt = "download-icon";
            image.style.objectFit = "contain";
            image.style.height = "24px";
            image.style.width = "24px";
            image.style.borderRadius = "10px";
            //<!-- _______________________________________________________ -->
            let pismo = document.createElement("p");
            pismo.innerHTML = "скачать";
            pismo.setAttribute("style","width: 65px;float:right;text-decoration: none;font-size: 1.3rem;font-weight: 500;display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;text-transform: uppercase;letter-spacing: -1px;color: #606060");
            //<!-- _______________________________________________________ -->
            btn.append(image);
            btn.append(pismo);
            document.querySelector("menu-container").insertAdjacentElement("beforeBegin", btn);
        } else {
            console.log("зашли в елс функция links");
            let btn2 = document.getElementsByTagName("butn");
            btn2.href = links;
            console.log(btn2);
        }
    }
})();