Last active
October 30, 2020 22:12
-
-
Save joao-neves95/c3ce160c9b5d96aa202f43e746814d53 to your computer and use it in GitHub Desktop.
Enhancer for YouTube - Script - Remove Consent Pop-Up
This file contains 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
/* | |
* By: João Neves (SHIVAYL) | |
* https://github.com/joao-neves95 | |
* | |
* Description: | |
* Script for the Enhancer for YouTube™ extension to remove the new consent pop-up on tab load. | |
* | |
* Version: 1.1.0 | |
* | |
* Licensed under the AGPL v3: https://www.gnu.org/licenses/agpl-3.0.html | |
*/ | |
/** | |
* @param { number } maxCount Max number of times. 1 time per 500 miliseconds. | |
* @param { number } count | |
*/ | |
const removePopUp = (maxCount = (10 * 2), count = 0) => { | |
setTimeout(() => { | |
try { | |
document.getElementById( 'consent-bump' ).remove(); | |
setTimeout(() => { | |
if (window.location.pathname !== '/watch') { | |
return; | |
} | |
document.getElementById( 'movie_player' ).click(); | |
}, 500); | |
} catch(e) { | |
if (count == maxCount) { | |
return; | |
} | |
// Recursively repeat until it finds the popup and removes the element. | |
removePopUp(maxCount, ++count); | |
} | |
}, 500); | |
} | |
const main = () => { | |
removePopUp(); | |
}; | |
main(); | |
window.onpopstate = main; | |
window.onhashchange = main; | |
window.addEventListener('click', main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment