// ==UserScript== // @name Twitch PiP button // @namespace https://github.com/valery-kirichenko // @description Add picture in picture button to twitch.tv player. // @author Valery Kirichenko, Konopielko // @license This script uses Material Symbols which are available under the Apache License Version 2.0. // @homepage https://github.com/valery-kirichenko/twitch-pip-button // @match *://www.twitch.tv/* // @match *://player.twitch.tv/* // @version 2.0 // @grant none // @downloadURL https://update.greasyfork.icu/scripts/24538/Twitch%20PiP%20button.user.js // @updateURL https://update.greasyfork.icu/scripts/24538/Twitch%20PiP%20button.meta.js // ==/UserScript== var playerReady = setInterval(function () { if ( document.getElementsByClassName("player-controls__right-control-group")[1] ) { clearInterval(playerReady); var btn = document.createElement("button"); btn.innerHTML = '
'; var btn2 = document.createElement("button"); btn2.innerHTML = btn.innerHTML; document .getElementsByClassName("player-controls__right-control-group")[0] .insertBefore( btn2, document.getElementsByClassName( "player-controls__right-control-group" )[0].lastElementChild ); document .getElementsByClassName("player-controls__right-control-group")[1] .insertBefore( btn, document.getElementsByClassName( "player-controls__right-control-group" )[1].lastElementChild ); btn.addEventListener("click", function () { document.querySelector("video").requestPictureInPicture(); }); } }, 100);