// ==UserScript== // @name Enable the Built-In PiP button on Youtube Media Control // @namespace http://youtube.com/ // @version 1.4 // @description Enable the built-in Picture-in-Picture (PiP) button (with custom SVG) in the Youtube Media player. // @match *://www.youtube.com/* // @grant none // @author jayzee8bp // @icon https://www.youtube.com/s/desktop/932eb6a8/img/favicon.ico // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/463641/Enable%20the%20Built-In%20PiP%20button%20on%20Youtube%20Media%20Control.user.js // @updateURL https://update.greasyfork.icu/scripts/463641/Enable%20the%20Built-In%20PiP%20button%20on%20Youtube%20Media%20Control.meta.js // ==/UserScript== (function() { 'use strict'; const pipButton = document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-right-controls > button.ytp-pip-button.ytp-button"); let boolCondPip = false // creating events for toggling color const togglePipColor = () => { boolCondPip = !boolCondPip; console.log(boolCondPip); pipButton.querySelector("svg").setAttribute('fill', (boolCondPip ? '#ff0000' : '#fff')); }; // removing svg, then add the svg (https://www.svgrepo.com/svg/347276/picture-in-picture) pipButton.removeAttribute('style'); pipButton.innerHTML = ' '; // attaching events to elements pipButton.addEventListener('click', togglePipColor); })();