JVC Cloudflare Bypass

Propose d'activer 1.1.1.1 sur jeuxvideo.com pour éviter les captchas

目前为 2025-02-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         JVC Cloudflare Bypass
// @namespace    https://jeuxvideo.com/
// @version      1.6
// @description  Propose d'activer 1.1.1.1 sur jeuxvideo.com pour éviter les captchas
// @author       HulkDu92 (modified by Bard)
// @match        *://www.jeuxvideo.com/*
// @grant        GM_xmlhttpRequest
// @connect      cloudflare.com
// @run-at       document-end
// @license      MIT
// @icon         https://image.noelshack.com/fichiers/2025/06/5/1738891409-68747470733a2f2f74616d6e762e696d6769782e6e65742f63665f6279706173735f6c6f676f2e706e67.png
// ==/UserScript==

(function() {
    'use strict';

    const WARP_STATUS_KEY = "jvcWarpStatus";
    const CLOUDFLARE_TRACE_URL = "https://cloudflare.com/cdn-cgi/trace";
    const WARP_BUTTON_URL = "https://1.1.1.1/";

    /**
     * Vérifie si Warp est activé et stocke le résultat dans sessionStorage.
     * Affiche le bouton si Warp est désactivé.
     */
    function checkWarpStatus() {
        const storedStatus = sessionStorage.getItem(WARP_STATUS_KEY);

        if (storedStatus !== null) {
            if (storedStatus === "false") showButton();
            return;
        }

        GM_xmlhttpRequest({
            method: "GET",
            url: CLOUDFLARE_TRACE_URL,
            onload: response => {
                const warpActive = response.responseText.includes("warp=on");
                sessionStorage.setItem(WARP_STATUS_KEY, warpActive.toString());

                if (!warpActive) showButton();
            }
        });
    }

    /**
     * Crée et affiche le bouton permettant d’activer Warp.
     */
    function showButton() {
        injectStyles();
        const button = createButton();

        // Tente d'insérer le bouton dans l'en-tête utilisateur
        const targetElement = document.querySelector('.header__globalUser');
        if (targetElement) {
            targetElement.insertBefore(button, targetElement.firstChild);
        } else {
            // Si l'élément cible est introuvable, afficher le bouton en position fixe
            console.warn("Element cible non trouvé, affichage en position fixed.");
            Object.assign(button.style, {
                position: "fixed",
                bottom: "20px",
                right: "20px",
                zIndex: "9999"
            });
            document.body.appendChild(button);
        }
    }

    /**
     * Injecte les styles CSS du bouton dans la page.
     */
    function injectStyles() {
        const style = document.createElement("style");
        style.textContent = `
            .btn-transparent {
                background-color: transparent !important;
                border: none !important;
               // padding: 5px !important;
                cursor: pointer !important;
            }

            .btn-transparent:hover {
                background-color: rgba(255, 0, 0, 0.1) !important;
            }
        `;
        document.head.appendChild(style);
    }

    /**
     * Crée un bouton avec une icône SVG et un lien vers 1.1.1.1.
     * @returns {HTMLElement} Le bouton créé.
     */
    function createButton() {
        const button = document.createElement("button");
        button.type = "button";
        button.className = "btn-transparent";
        button.title = "Bloquer Captcha 🛇";
        button.appendChild(createIcon());
        button.onclick = () => window.open(WARP_BUTTON_URL, "_blank");
        return button;
    }

    /**
     * Crée une icône SVG représentant un cadenas ouvert.
     * @returns {SVGElement} L'élément SVG créé.
     */
    function createIcon() {
        const svgNS = 'http://www.w3.org/2000/svg';
        const icon = document.createElementNS(svgNS, 'svg');

        icon.setAttribute("viewBox", "0 0 26 26");
        icon.setAttribute("width", "23");
        icon.setAttribute("height", "23");
        icon.style.fill = '#FF3C00';

        const path = document.createElementNS(svgNS, 'path');
        path.setAttribute('d', 'M7 0C4.79 0 2.878.917 1.687 2.406C.498 3.896 0 5.826 0 7.906V11h3V7.906c0-1.58.389-2.82 1.031-3.625C4.674 3.477 5.541 3 7 3c1.463 0 2.328.45 2.969 1.25c.64.8 1.031 2.06 1.031 3.656V9h3V7.906c0-2.092-.527-4.044-1.719-5.531C11.09.888 9.206 0 7 0zm2 10c-1.656 0-3 1.344-3 3v10c0 1.656 1.344 3 3 3h14c1.656 0 3-1.344 3-3V13c0-1.656-1.344-3-3-3H9zm7 5a2 2 0 0 1 2 2c0 .738-.404 1.372-1 1.719V21c0 .551-.449 1-1 1c-.551 0-1-.449-1-1v-2.281c-.596-.347-1-.98-1-1.719a2 2 0 0 1 2-2z');

        icon.appendChild(path);
        return icon;
    }


    checkWarpStatus();
})();