🌐 delete cookies 🍪

Page load and... what ? No cookie ? Net is now marvelous !

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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.3
// @description  Page load and... what ? No cookie ? Net is now marvelous !
// @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");
			};
		};
	};
	window.addEventListener('load', refuse, false);
})();