31 lines
759 B
JavaScript
31 lines
759 B
JavaScript
// ==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, timeout));
|
|
|
|
var e = document.querySelector(query)
|
|
if (!e) continue
|
|
|
|
e.click()
|
|
return
|
|
}
|
|
} |