NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Open Youtube video in embedded mode
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Adds a button that opens up the current video in embedded mode, for semi-fullscreen viewing
// @author DecentM
// @match *://www.youtube.com/*
// @grant none
// @license MIT
// ==/UserScript==
((window, document, undefined) => {
'use strict';
const openEmbedded = () => {
const newLocation = document.location.href.replace(/watch\?v\=/g, 'embed/');
document.location.href = newLocation;
};
const main = () => {
const buttons = document.querySelectorAll('.decentm-custom-button--open-embed');
buttons.forEach((button) => {
button.remove();
});
setTimeout(() => {
const spot = document.querySelector('ytd-video-primary-info-renderer > #container > #info');
const button = document.createElement('paper-button');
button.classList.add('ytd-subscribe-button-renderer', 'decentm-custom-button--open-embed');
button.innerHTML = 'Open embedded';
button.onclick = openEmbedded;
spot.appendChild(button);
}, 1000);
};
document.addEventListener('yt-navigate-finish', main);
})(window, window.document);