Skip to content

Instantly share code, notes, and snippets.

@DVDAndroid
Created November 7, 2020 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DVDAndroid/11022efcce7ee74b75b60e5bd1ecb1a4 to your computer and use it in GitHub Desktop.
Save DVDAndroid/11022efcce7ee74b75b60e5bd1ecb1a4 to your computer and use it in GitHub Desktop.
tampermonkery userscript to remove google and youtube popups
// ==UserScript==
// @name Google&Youtube consent cookie inject
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.google.com/*
// @match https://www.youtube.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
if ('storage' in navigator && 'estimate' in navigator.storage) {
navigator.storage.estimate().then(function(estimate) {
const quota = estimate.quota;
const usage = estimate.usage;
if(quota < 12000000000){
var domain = window.location.hostname.substring(3,20);
setCookie("CONSENT", "YES+IT.it+V13+BX", 365, domain);
if (domain === ".youtube.com") {
window.addEventListener('load', function() {
var x = function() {
setTimeout(function() {
var signIn = document.getElementsByTagName("ytd-popup-container");
if (signIn.length > 0) {
signIn = signIn[0];
if (signIn != undefined && signIn.innerHTML.indexOf("https://support.google.com/youtube/?p=sign_in") != -1){
signIn.parentNode.removeChild(signIn);
}
}
var consentDialog = document.getElementById("consent-bump");
if (consentDialog != undefined) {
consentDialog.parentNode.removeChild(consentDialog);
}
x();
}, 1000);
};
x();
}, false);
}
}
});
} else {
console.log('[G&Y Cookie] Can not detect')
}
function setCookie(cname, cvalue, exdays, ddomain) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires="+d.toUTCString();
var domain = "domain="+ddomain;
var secure = "secure";
var samesite = "samesite=None";
document.cookie = cname + "=" + cvalue + ";" + secure +";"+samesite+";"+ domain +";" +expires + ";path=/";
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment