// ==UserScript== // @name Google Shut Up! // @namespace http://tampermonkey.net/ // @version 0.1.9.1 // @description Remove annoying cookies popup on google and youtube login popup on youtube! Thanks to him https://github.com/uBlockOrigin/uAssets/issues/7842#issuecomment-694298400 // @author You // @include /^https\:\/\/[a-z]*\.(google|youtube)\.[a-z]*/ // @grant none // @run-at document-start // @downloadURL none // ==/UserScript== (function() { //console.log("Google Shut Up: Start"); //https://stackoverflow.com/a/45956628---- //youtube wtf events //new layout > 2017 window.addEventListener("yt-navigate-finish", function(event) { window.dispatchEvent(new Event('locationchange')) }); //old layout < 2017 window.addEventListener("spfdone", function(e) { window.dispatchEvent(new Event('locationchange')) }); window.addEventListener("load",function(){ dismissLogin(); },{once:true}); function cookieIsSet(){ return document.cookie.match(/CONSENT\=YES\+EN\.en\+V13\+BX/) !== null; } function siteIsRefreshable(){ return document.URL.match(/^https\:\/\/(accounts\.(google|youtube)\.com|www\.google\.com\/recaptcha)/i) === null; } function isYoutube(){ return document.URL.match(/^https\:\/\/www\.youtube\.com/i) !== null; } window.addEventListener('locationchange', function(){ if(!cookieIsSet()){ cookieInjection(); } dismissLogin(); }); //if cookie is unset then inject it if(!cookieIsSet()){ cookieInjection(); } dismissLogin(); function cookieInjection(){ //cookie injection document.cookie = "CONSENT=YES+EN.en+V13+BX; expires=Fri, 01 Jan 2038 00:00:00 GMT; domain="+document.URL.match(/^https\:\/\/[a-z]*\.((google|youtube)\.[\.a-z]*)/)[1]+"; path =/; Secure"; //reload on accounts.google.com pages causes infinite loop if(siteIsRefreshable()){ //refresh page to avoid cookie's popup //console.log("Google Shut Up: cookie refresh"); location.reload(); } } //Link: https://github.com/uBlockOrigin/uAssets/issues/7842#issuecomment-694298400 //Source: https://gist.githubusercontent.com/pixeltris/b79707fa8a704e0058c7f1af83d5935a/raw/Yt.js //Thanks to this guy! function dismissLogin(){ try { window.ytInitialPlayerResponse.auxiliaryUi.messageRenderers.upsellDialogRenderer.isVisible = false; //console.log("Google Shut Up: dismissed login popup"); } catch (e){ } } })();