Auto Decline Cookies

This script automates the decline of cookies

< 脚本 Auto Decline Cookies 的反馈

评价:好评 - 脚本运行良好

§
发布于:2025-09-28

The script you create has a critical syntax error in the setInterval() line, which is why it's not working well!

❌ Problematic Line:
const interval = setInterval()(FAC, 1000) //This is invalid syntax.

✅ Fix:
You need to pass the function FAC and the interval delay 1000 as arguments to setInterval, like this:
const interval = setInterval(FAC, 1000);

Anyway great job.

✅ Language-Aware Script

This version detects the language from the browser or page (navigator.language or ) and adjusts the keywords array accordingly.


// ==UserScript==
// @name Auto Decline Cookies (Language Aware)
// @namespace http://tampermonkey.net/
// @version 2025-09-28
// @description Automatically clicks cookie "decline" buttons (supports English and Portuguese)
// @author DeepBlackHole
// @match *://*/*
// @grant none
// @license MIT
// ==/UserScript==

(function () {
'use strict';

// Get the page or browser language (e.g., "en", "pt", etc.)
const lang = (document.documentElement.lang || navigator.language || 'en').toLowerCase();

// Keywords in English
const englishKeywords = [
'Reject all',
'Decline',
'Only essential',
'Continue without accepting',
'Refuse',
'Reject non-essential',
'Do not accept'
];

// Keywords in Portuguese
const portugueseKeywords = [
'Rejeitar tudo',
'Discordo',
'Apenas essencial',
'Continuar sem aceitar',
'Recusar',
'Rejeitar não essencial',
'Não aceitar'
];

// Default to both languages unless narrowed by detection
let keywords = [...englishKeywords, ...portugueseKeywords];

if (lang.startsWith('pt')) {
keywords = [...portugueseKeywords];
} else if (lang.startsWith('en')) {
keywords = [...englishKeywords];
}

const FAC = () => {
const buttons = document.querySelectorAll('button, input[type="button"], a');

for (let btn of buttons) {
const text = (btn.innerText || btn.value || '').trim().toLowerCase();
if (keywords.some(keyword => text.includes(keyword.toLowerCase()))) {
console.log('[AutoDeclineCookies] Clicking button:', text);
btn.click();
return;
}
}
};

const interval = setInterval(FAC, 1000);
setTimeout(() => clearInterval(interval), 15000);
})();

发布留言

登录以发布留言。