2ch-CAPTCHA-MATH

2ch captcha easy solve

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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://greasyfork.org/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; // Продолжение дальнейших событий
        });
    });
})();