YouTube Quick Embed

Redirects any YouTube video to its embedded link on command.

// ==UserScript==
// @name         YouTube Quick Embed
// @namespace    https://naeembolchhi.github.io/
// @version      0.2
// @description  Redirects any YouTube video to its embedded link on command.
// @author       NaeemBolchhi
// @license      GPL-3.0-or-later
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAdhAAAHYQGVw7i2AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAHK9JREFUeJzt3XuUHVWdL/Dvb9c5p/skgvJKACHdCXBHfOFdIemgA3QC6PWuUWfu2OnOqwlMiDA6DHcYhxF1COog4uX6mAuShBlyMSGPlpERxoBDoAGVdIcMGA2CQLo7YN5v0n0eVXv/5o9OMIQ8dp1TdXadc36ftVhkxeqqbyT7V7v23rWLUEO2XzZ9MjN9GlD/HaAmpXCKImogIE2K6K0DmZkBYzQXGdgFxhvGYI0h/dDpTy5Z5fCPIERF0fEPSa7tF8+6lNO4VhFdojw6QxGV/ecxzMZofo01/yTfkL/t7Me6dkWRVYgkqroCsPnS2RNSnrlVeXSpp2hEnNdiZtaB+a2vMe+Mp37YFee1hHChKgoAt85L7eDXvkppfC7leaNdZPB9s92wnjf6ySV3u7i+EHFIdAHYNH7uiNSJuX9KpbwZSqHBdR4AMJr3BEV9+6inF3/LdRYhypXYArB18qy/S6foVqVUo+ssR6K1yQWB/pdR+P0N1N0duM4jRCkSVwC2TZ71P0nRfemUGuU6iw1jOO8H+v5RjSddTyv/qeA6jxBhJKYAvD6l872N4J+l0977XWcphTGm6BuzaNTJhRuoqyvnOo8QNhJRADZfOu2qhkxmvlKUdp2lXIZZm4D/ba9qvPqcxxfsdZ1HiGNxWgC4dXbjDk8/nEqpyykZtSgyzKyDwDycT2f+4uzH/lnWEohEctbqtk656qOe0o+mPHWCqwyVwMzaD/RPiqSuOWvV/Ttd5xHiUE4KwObWGZ9tTKeWkSLPxfVdYIYJfP3EfvZm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Ia+dLQBgJ9S6bzRDVIRAEADu4qlL0dwFxU48pBwm+Y8Y+ygEdUk8QUgIM2XNj2Ryqlvg5Gm+ssltYR484xTWYJdXVp12GECCNxBeCgA9OFdwL4sOssR8R4noBvylp9Uc0SWwAAgFtbUxtzp08z4C8S8CHXeQAMv4+vzDeaVq943HUUIcqV6AJwEAPUP3Hqx4noWgB/gsqPETCAlYrp9jG9y56p8LWFiE1VFIBD9Y+feQZSxekAfRZAC+L9M+wGY5khdc+4nqXrYryOEE5UXQE41KsTOs5OefwJNnQFEV8KYHQEp90EwkoAP+XG7E9lDl/UsqouAId7bXzbGC9FE0A4n5nOI+AcAKeAcQoIGQDvBmAA7AWwm0A7AO4D0GeIXiCje5t7u/pc/hmEqKT/AhkqGV+t9jNqAAAAAElFTkSuQmCC
// @match        http*://*.youtube.com/*
// @match        https://www.youtube.com/*
// @match        https://www.youtube-nocookie.com/*
// @match        https://m.youtube.com/*
// @match        https://music.youtube.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

// Embed Key
const embedKey = ["F11","true"];
/* Video will redirect to embedded link when this button is pressed.
 * You can choose if Control also needs to be pressed or not.
 * In the array above, the first value is the main button, and the second value states if control should be pressed.
 * Second value may only be "true" or "false".
 * */

// URL Scraper
function getUrlVars(adrs) {
    let vars = {};
    adrs.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}

// Return the video ID
function getVideoID() {
    if (window.location.pathname.match(/^\/shorts/)) {
        console.log(window.location.pathname.replace(/^\/shorts\//,''));
        return window.location.pathname.replace(/^\/shorts\//,'');
    } else {
        return getUrlVars(window.location.href).v;
    }
}

document.addEventListener('keydown', function(e) {
    if (e.key !== embedKey[0] || e.ctrlKey.toString() !== embedKey[1]) {return;}

    if (getVideoID() === undefined) {return;}

    window.location.assign('https://www.youtube.com/embed/' + getVideoID());
});