|
// ==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=/"; |
|
} |
|
})(); |