Created
September 10, 2020 11:40
-
-
Save jankapunkt/70e2f15ab3ae4efe8cd3686365f3630d to your computer and use it in GitHub Desktop.
Greasemonkey UserScript Youtube hide consent panel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name youtube consent block | |
// @namespace https://*youtube.com | |
// @version 1 | |
// @include http* | |
// @grant none | |
// @license MIT | |
// ==/UserScript== | |
//consentBump.style.display = 'none'; | |
//ironOverlayBackdrop.style.display = 'none'; | |
const config = { attributes: true, childList: true, subtree: true } | |
let backdropHidden = false | |
let consentHidden = false | |
let observer = undefined | |
const callback = function(mutationsList, observer) { | |
for(let mutation of mutationsList) { | |
if (mutation.type === 'childList') { | |
if (mutation.target.id === 'consent-bump') { | |
mutation.target.style.display = 'none' | |
consentHidden = true | |
} | |
if (mutation.target.tagName === 'IRON-OVERLAY-BACKDROP') { | |
mutation.target.style.display = 'none' | |
backdropHidden = true | |
} | |
} | |
} | |
if (backdropHidden && consentHidden) { | |
observer.disconnect() | |
console.log('consent successfully hidden') | |
} | |
} | |
observer = new MutationObserver(callback) | |
observer.observe(document.documentElement, { | |
childList: true, | |
subtree: true | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment