I wrote a UserScript that forces YouTube to load the old site style by appending a setting to the URL. That works fine, but for some reason it also targets embedded videos and makes them not work. I'm trying to get the script to only effect YouTube as a site and not interfere with embedded videos on other pages. The current script is as follows:
// ==UserScript==
// @name Disable YouTube Polymer
// @include *://*.youtube.com/*
// @exclude *://*.youtube.com/embed/*
// @run-at document-start
// @grant none
// ==/UserScript==
try {
var url = window.location.href;
if(!url.includes("embed")) {
document.execCommand('Stop');
var url = document.location.toString();
if (!url.includes("disable_polymer")) {
var separator = url.indexOf('?') !== -1 ? "&" : "?";
document.location.replace(url + separator + "disable_polymer=true");
}
}
} catch (e) {}
I suspect that it may have to do with the fact that I'm taking the URL from the window location. I think I had a different way of getting the URL before, but I can't remember it.
Forgive me if I'm not asking the question correctly; I don't know enough about this domain to do so.