From d47a59d1883ba11d2581ea2527f8ed8dd89c85f4 Mon Sep 17 00:00:00 2001 From: ryuku Date: Thu, 16 Jun 2022 09:30:23 +1000 Subject: [PATCH] added greasemonkey script --- yt-auto-reject.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 yt-auto-reject.js diff --git a/yt-auto-reject.js b/yt-auto-reject.js new file mode 100644 index 0000000..64107c0 --- /dev/null +++ b/yt-auto-reject.js @@ -0,0 +1,31 @@ +// ==UserScript== +// @name YouTube Reject All +// @version 1 +// @grant none +// ==/UserScript== + +var retryLimit = 5 // seconds + +var query +if (!window.location.href.includes("consent.youtube.com")) { + if (!window.location.href.includes("youtube.com")) return + query = '[aria-label="Reject the use of cookies and other data for the purposes described"]' +} else { + query = '[aria-label="Reject all"]' +} + +window.addEventListener('load', consentMonitor); +async function consentMonitor() { + var retryTotal = retryLimit * 1000 + const timeout = 100 + + for(var i = 0; i < retryTotal; i += timeout) { + await new Promise(r => setTimeout(r, 100)); + + var e = document.querySelector(query) + if (!e) continue + + e.click() + return + } +} \ No newline at end of file