2ch-CAPTCHA-MATH

2ch captcha easy solve

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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