Skip to content

Instantly share code, notes, and snippets.

@z-------------
Last active November 4, 2019 10:03
Show Gist options
  • Save z-------------/11e3617b7658d657f3182b44405c5de3 to your computer and use it in GitHub Desktop.
Save z-------------/11e3617b7658d657f3182b44405c5de3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name YouTube disable polymer
// @namespace https://zackguard.com/
// @version 0.0.1
// @description Disable Polymer on all YouTube pages
// @author Zack Guard
// @match https://www.youtube.com/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function() {
"use strict";
const url = new URL(window.location);
if (url.searchParams.get("disable_polymer") !== "1") {
url.searchParams.append("disable_polymer", "1");
window.location.href = url.toString();
}
document.addEventListener("mouseover", e => {
const target = e.target;
let linkElem;
if (target.tagName === "A" && target.href) {
linkElem = target;
} else if (target.classList.contains("title") && target.parentElement.tagName === "A" && target.parentElement.href) {
linkElem = target.parentElement;
} else if (
target.tagName === "IMG" && target.parentElement.classList.contains("yt-thumb-simple")
|| target.classList.contains("mouseover-img")
|| target.classList.contains("masthead-logo-renderer-logo")
) {
linkElem = target.closest("a");
}
if (linkElem) {
const url = new URL(linkElem.href);
if (url.searchParams.get("disable_polymer") !== "1") {
url.searchParams.append("disable_polymer", "1");
linkElem.href = url.toString();
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment