m.YouTube.com add PIP picture in picture pop-out button

Adds a pop out to PIP button to m.YouTube.com

05.02.2024 itibariyledir. En son verisyonu görün.

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

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 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.

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

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         m.YouTube.com add PIP picture in picture pop-out button
// @namespace    m-youtube-com-pip-button
// @version      1.0
// @description  Adds a pop out to PIP button to m.YouTube.com
// @author       hlorand.hu
// @match        https://m.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @license      https://creativecommons.org/licenses/by-nc-sa/4.0/
// ==/UserScript==


(function() {
    //'use strict';
    function addbutton(){
        document.getElementById("pipbutton").innerHTML = "";

        let button = document.createElement('button');
        button.textContent = "PIP";
        button.className = "speedbutton";

        button.style.margin = "4px";
        button.style.padding = "4px";

        button.style.backgroundColor = "brown";
        button.style.position = "relative";

        button.onclick = function() {
            let video = document.querySelector("video");
            video.requestPictureInPicture();
        };

        let target = document.getElementById("pipbutton");
        target.insertBefore(button, target.firstChild);


    } // end addbuttons

    // Periodically check if the buttons are visible
    // (sometimes YouTube redraws its interface).
    setInterval(()=>{
        // Creating a div that will contain buttons.
        if( document.getElementById("pipbutton") == undefined ){
            let parent = document.querySelector('.related-chips-slot-wrapper'); // placement of buttons
            let wrapper = document.createElement('div');
            wrapper.setAttribute("id","pipbutton");
            parent.insertBefore(wrapper, parent.firstChild);
            addbutton();

        }

    }, 1000);

})();