🌐 delete cookies 🍪

Agrees to the cookies dialog to make it disappear forever.

当前为 2023-12-10 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         🌐 delete cookies 🍪
// @name:fr      🌐 suppression de l'avertissement des cookies 🍪
// @namespace    https://greasyfork.org/en/users/876222-zzz-the-hacker
// @version      2.1
// @description  Agrees to the cookies dialog to make it disappear forever.
// @description:fr  Confirme l'acceptation des cookies pour le faire disparaître définitivement.
// @author       zzz le hacker
// @match        *://*/*
// @grant        none
// @icon         https://www.hebergeur-image.fr/uploads/20231210/7a28ab28a8e9a4bea32b6918aa65a39ef5dea1fb.png
// ==/UserScript==

(function () {
	"use strict";
	let notif = (message, time, icon) => {
		let div = document.createElement("div");
		div.style = "background-color: white; color: black; font-family: monospace; display: flex; justify-content: center; align-items: center; position: absolute; max-width: 400px; left: -420px; top: 20px; border: 1px solid black; border-radius: 10px; z-index: 100000; transition: left 1s cubic-bezier(0.6, 0.59, 0, 0.99) 0s; padding: 20px;";
		div.innerHTML = message;
		document.body.appendChild(div);
		let img = document.createElement("img");
		img.src = icon;
		img.style = "width: 60px; margin-left: 10px; border: 1px black solid; border-radius: 10px;";
		div.appendChild(img);
		setTimeout(() => {
			div.style.left = "20px";
			setTimeout(() => {
				div.style.left = "-500px";
				setTimeout(() => {
					div.remove();
				}, 1500);
			}, time);
		}, 100);
	};
	let searchHTML = (element, callback) => {
		callback(element);
		[...element.childNodes].forEach(child => {
			if (child.innerHTML !== undefined && child.outerHTML !== undefined) searchHTML(child, callback);
		});
	};
	let onlyText = (element) => {
		var nodes = element.childNodes;
		for (var i = 0; i < nodes.length; i++) {
			if (nodes[i].nodeType !== 3) {
				return false;
			}
		}
		return true;
	}
	let refuse = () => {
		let h = [...document.getElementsByClassName("QS5gu sy4vM")];
		let condition = (h.length !== 0);
		if (condition) {
			h[0].click();
			notif("cookie refused !", 3000, "https://www.hebergeur-image.fr/uploads/20231210/7a28ab28a8e9a4bea32b6918aa65a39ef5dea1fb.png");
		} else {
			let rejectList = ["Refuser", "Refuser tous les cookies", "Refuser les cookies", "Rejeter", "Refuse", "Reject all cookies", "Reject cookies", "Decline", "Continuer sans accepter", "Continue without accepting", "Tout refuser", "Decline all"];
			let acceptList = ["Accepter", "Accepter tous les cookies", "Autoriser", "Valider", "Accept", "Accept all cookies", "Allow", "Confirm"];
			let RbuttonsList = [];
			let AbuttonsList = [];
			searchHTML(document.body, (child) => {
				rejectList.forEach(e => {
					if (child.innerHTML.includes(e)) if (onlyText(child)) if (!RbuttonsList.includes(child)) RbuttonsList.push(child);
				});
				acceptList.forEach(e => {
					if (child.innerHTML.includes(e)) if (onlyText(child)) if (!AbuttonsList.includes(child)) AbuttonsList.push(child);
				});
			});
			console.log([RbuttonsList, AbuttonsList]);
			if (RbuttonsList.length !== 0) {
				RbuttonsList.forEach(element => {
					element.click();
					notif("cookie refused !", 3000, "https://www.hebergeur-image.fr/uploads/20231210/7a28ab28a8e9a4bea32b6918aa65a39ef5dea1fb.png");
				});
			} else {
				if (AbuttonsList.length !== 0) notif("An error appeared when searching for the refuse cookies button: you can refer to the author of the script via greasyfork and tell him on which site you encountered this problem.", 8000, "https://www.hebergeur-image.fr/uploads/20231210/dab7ba5c2cb28fa94bf21c19b963050aff336b91.png");
				else notif("No cookies found on this page.", 3000, "https://www.hebergeur-image.fr/uploads/20231210/c4c756d82cb08cf29b91df0d4d863e51984bb925.png");
			};
		};
	};
	document.addEventListener('DOMContentLoaded', refuse, false);
})();