Y2Mate.tools

This userscript assists Y2Mate.tools to convert video links online.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Y2Mate.tools
// @namespace   https://y2mate.tools/
// @version     2.1.6
// @author      BetaTester704
// @description This userscript assists Y2Mate.tools to convert video links online.
// @match       *://*.youtube.com/*
// @license     Unlicense
// @run-at      document-end
// @grant       GM_xmlhttpRequest
// ==/UserScript==

if (document.domain === 'www.youtube.com') {
    setInterval(check, 1000)

    function check() {
        const elem = document.getElementById("y2mate_downloader")
        if (elem === null && document.readyState === 'complete') {
            addButton()
        }
    }

    function addButton() {

        var params = new URLSearchParams(document.location.search);
        var youtubeId = params.get('v');

        const icon = 'https://y2mate.tools/theme/youtube/images/logo.png';
        const gotoy2mate = "https://www.youtube-y2mate.com/watch?v="+youtubeId;
        const div_embed = document.querySelector(`.ytd-page-manager #info #info-contents:not([hidden]) #top-level-buttons-computed,.ytd-page-manager #actions .actions-inner #top-level-buttons-computed,.ytd-page-manager #actions #actions-inner #top-level-buttons-computed`);

        const target = '_blank';
        const start = `border: none;margin: 0px -8px 0px 0px;background: inherit;cursor: pointer;position: relative;flex: 1;display: flex;align-items: center;justify-content: right`;

        if (div_embed) {
            let div_elem = document.createElement('div');
            div_elem.id = "y2mate_downloader"
            div_elem.innerHTML += `<a href="${gotoy2mate}" style="cursor:pointer" target="${target}"><button style="${start}" type="button" title="Convert with Y2Mate.tools"><img style="border-radius: 3px; width: 45px; height: 35px;" src="${icon}">`

            for (var i = 0; i < div_embed.childNodes.length; i++) {
                div_embed.childNodes[2].before(div_elem);
            }
        }
    }
}