2ch-CAPTCHA-MATH

2ch captcha easy solve

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         2ch-CAPTCHA-MATH
// @license      GPL-3.0-or-later; https://www.gnu.org/licenses/gpl-3.0.txt
// @version      0.1
// @author       Master2ch
// @description  2ch captcha easy solve
// @homepageURL  https://t.me/Master2ch
// @author       Master2ch
// @match        *://2ch.hk/*
// @namespace    https://greatest.deepsurf.us/ru/users/1120123
// ==/UserScript==

(function() {
    'use strict';

    function solveEquation(equation) {
        const parts = equation.split(/([\+\-\*\/=])/); // Используется регулярное выражение для разделения уравнения по операторам
        const operand1 = parts[0].trim() === "?" ? null : parseInt(parts[0].trim());
        const operator = parts[1].trim();
        const operand2 = parts[2].trim() === "?" ? null : parseInt(parts[2].trim());
        const result = parts[4].trim() === "?" ? null : parseInt(parts[4].trim());

        if (operand1 === null) {
            switch (operator) {
                case "/":
                case "\\":
                    return result * operand2;
                case "*":
                    return result / operand2;
                case "+":
                    return result - operand2;
                case "-":
                    return result + operand2;
            }
        } else if (operand2 === null) {
            switch (operator) {
                case "/":
                case "\\":
                    return operand1 / result;
                case "*":
                    return result / operand1;
                case "+":
                    return result - operand1;
                case "-":
                    return operand1 - result;
            }
        } else if (result === null) {
            switch (operator) {
                case "/":
                case "\\":
                    return operand1 / operand2;
                case "*":
                    return operand1 * operand2;
                case "+":
                    return operand1 + operand2;
                case "-":
                    return operand1 - operand2;
            }
        }
    }

    // Получаем все элементы с классом .captcha__val.input
    var inputElements = document.querySelectorAll('.captcha__val.input');

    // Добавляем обработчик события input к каждому элементу
    inputElements.forEach(function(inputElement) {
        inputElement.maxLength = 20;
        var pattern = /\s*([\d]+|\?)\s*[-+*/\\]\s*([\d]+|\?)\s*=\s*([\d]+|\?)\s/g; // Паттерн для поиска символа '=', числа и пробела с параметром жадности
        inputElement.addEventListener('input', function(event) {
            var enteredText = event.target.value;

            if (pattern.test(enteredText)) {
                console.log('REPLACE !!!!!!!!');
                event.target.value = solveEquation(enteredText);
            }

            return true; // Продолжение дальнейших событий
        });
    });
})();