Unlock Brainly Answers

This script allows you to unlock the main answer to Brainly questions in a simple and direct way, without simulating a Pro account. It uses a technique based on simulated anonymous access, bypassing view restrictions and displaying the full answer — no login or incognito tab required.

// ==UserScript==
// @name         Unlock Brainly Answers
// @name:pt-BR   Desbloquear Respostas Brainly
// @name:en-US   Unlock Brainly Answers
// @name:es-ES   Desbloquear Respuestas de Brainly
// @name:fr-FR   Débloquer les Réponses de Brainly
// @name:zh-CN   解锁 Brainly 答案
// @name:ar-SA   فتح إجابات Brainly
// @namespace    DesbloquearRespostasBrainly
// @version      1.1
// @description   This script allows you to unlock the main answer to Brainly questions in a simple and direct way, without simulating a Pro account. It uses a technique based on simulated anonymous access, bypassing view restrictions and displaying the full answer — no login or incognito tab required.
// @description:pt-Br   Este script permite desbloquear a resposta principal das perguntas no Brainly de forma simples e direta, sem simular uma conta Pro. Ele utiliza uma técnica baseada em acesso anônimo simulado, contornando as restrições de visualização e exibindo a resposta completa — sem precisar fazer login ou abrir guia anônima.
// @description:zh-Cn   该脚本可以简单直接地解锁 Brainly 上问题的主要答案,无需模拟 Pro 账户。它使用一种模拟匿名访问的技术,绕过查看限制并显示完整答案 —— 无需登录或打开无痕窗口。
// @description:es-ES   Este script permite desbloquear la respuesta principal de las preguntas en Brainly de forma simple y directa, sin simular una cuenta Pro. Utiliza una técnica basada en el acceso anónimo simulado, eludiendo las restricciones de visualização y mostrando la respuesta completa — sin necesidad de iniciar sesión ni abrir una pestaña de incógnito.
// @homepage     https://ko-fi.com/l4pisd4silv4#
// @license      MIT
// @author       L4pisD4Silv4
// @match        *://*.brainly.com.br/*
// @match        *://*.brainly.com/*
// @match        *://brainly.com/*
// @match        *://brainly.co.id/*
// @match        *://brainly.in/*
// @match        *://brainly.ph/*
// @match        *://brainly.ro/*
// @match        *://brainly.lat/*
// @match        *://brainly.pl/*
// @icon         https://img.icons8.com/?size=512&id=DBQ34fANpy5j&format=png
// @grant        GM_xmlhttpRequest
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        GM_setValue
// @connect      *
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    const languageData = {
        'pt-BR': {
            name: 'Português Brasil',
            menu: {
                language: 'Idioma',
                support: '🙌 Apoie-me',
                reload: '🔁 Recarregar Página'
            }
        },
        'en-US': {
            name: 'English',
            menu: {
                language: 'Language',
                support: '🙌 Support Me',
                reload: '🔁 Reload Page'
            }
        },
        'es-ES': {
            name: 'Español',
            menu: {
                language: 'Idioma',
                support: '🙌 Apóyame',
                reload: '🔁 Recargar página'
            }
        },
        'fr-FR': {
            name: 'Français',
            menu: {
                language: 'Langue',
                support: '🙌 Soutiens-moi',
                reload: '🔁 Recharger la page'
            }
        },
        'zh-CN': {
            name: '中文',
            menu: {
                language: '语言',
                support: '🙌 支持我',
                reload: '🔁 重新加载页面'
            }
        },
        'ar-SA': {
            name: 'العربية',
            menu: {
                language: 'اللغة',
                support: ' 🙌 ادعمني',
                reload: '🔁 إعادة تحميل الصفحة'
            }
        }
    };

    const supportImage = 'https://i.imgur.com/qn1xxfD.png';
    let currentLang = GM_getValue('lang') || Object.keys(languageData)[0];
    let menuIDs = { language: null, support: null, reload: null };

    const initializeUnlocker = () => {
        const limparTudo = () => {
            document.cookie.split(";").forEach(cookie => {
                const [key] = cookie.split('=');
                if (key.trim().match(/^(session|auth)/i)) {
                    document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
                }
            });
            try {
                localStorage.clear();
                indexedDB.deleteDatabase('Brainly');
            } catch(e) {}
            window.__BRAZIL_SESSION__ = undefined;
            window.__USER_DATA__ = undefined;
        };
        const originalOpen = XMLHttpRequest.prototype.open;
        XMLHttpRequest.prototype.open = function(method, url) {
            if (url.includes('/api/auth/check')) {
                this.addEventListener('load', () => {
                    if (this.readyState === 4) {
                        Object.defineProperty(this, 'responseText', {
                            value: JSON.stringify({ isAuthenticated: false })
                        });
                    }
                });
            }
            originalOpen.apply(this, arguments);
        };
        const observer = new MutationObserver(mutations => {
            mutations.forEach(mutation => {
                mutation.addedNodes.forEach(node => {
                    if (node.nodeType === 1) {
                        if (node.classList?.contains('sg-modal') || node.classList?.contains('paywall')) {
                            node.remove();
                        }
                        if (node.classList?.contains('brn-answer__content--locked')) {
                            node.style.cssText = 'filter:none!important; opacity:1!important;';
                        }
                    }
                });
            });
        });
        const css = `
            .brn-answer__content--locked,
            .js-paywall,
            .blurred-container,
            .sg-overlay {
                filter: none !important;
                opacity: 1 !important;
                pointer-events: auto !important;
            }
            [data-test="paid-content"] { display: block !important; }
        `;
        document.head.insertAdjacentHTML('beforeend', `<style>${css}</style>`);
        limparTudo();
        observer.observe(document.body, { childList: true, subtree: true });
        setInterval(limparTudo, 3000);
    };

// **ATUALIZAÇÃO** pop-ups irritantes removidos automaticamente
        setInterval(() => {
            document.querySelectorAll('[data-testid="registration_toplayer_close_button"], .sg-dialog__close-button[aria-label="Close this dialog window"]').forEach(btn => {
                if (btn && btn.click) btn.click();
            });
        }, 500);

    const initializeLanguageSystem = () => {
        const updateLanguage = (lang) => {
            currentLang = lang;
            GM_setValue('lang', lang);
            GM_unregisterMenuCommand(menuIDs.language);
            GM_unregisterMenuCommand(menuIDs.support);
            GM_unregisterMenuCommand(menuIDs.reload);
            registerMenuCommands();
        };
        const registerMenuCommands = () => {
            menuIDs.language = GM_registerMenuCommand(
                languageData[currentLang].menu.language,
                showLanguageModal
            );
            menuIDs.support = GM_registerMenuCommand(
                languageData[currentLang].menu.support,
                showSupportModal
            );
            menuIDs.reload = GM_registerMenuCommand(
                languageData[currentLang].menu.reload,
                () => window.location.reload(true)
            );
        };
        const showLanguageModal = () => {
            const modal = document.createElement('div');
            modal.className = 'lang-modal';
            const validLanguages = ['pt-BR', 'en-US', 'es-ES', 'fr-FR', 'zh-CN', 'ar-SA'];
            validLanguages.forEach(lang => {
                const btn = document.createElement('button');
                btn.className = 'lang-option';
                btn.textContent = languageData[lang].name;
                btn.onclick = () => {
                    updateLanguage(lang);
                    modal.remove();
                };
                modal.appendChild(btn);
            });
            document.body.appendChild(modal);
            document.addEventListener('click', (e) => {
                if (!modal.contains(e.target)) modal.remove();
            });
        };
        const showSupportModal = () => {
            const container = document.createElement('div');
            const overlay = document.createElement('div');
            overlay.style.cssText = `
                position: fixed !important;
                top: 0 !important;
                left: 0 !important;
                width: 100vw !important;
                height: 100vh !important;
                backdrop-filter: blur(5px) brightness(0.8) !important;
                -webkit-backdrop-filter: blur(5px) brightness(0.8) !important;
                z-index: 9998 !important;
                transition: all 0.5s ease !important;
            `;
            container.style.cssText = `
                position: fixed !important;
                top: 50% !important;
                left: 50% !important;
                transform: translate(-50%, -50%) scale(0.75) !important;
                width: 1948px !important;
                height: 940px !important;
                background-image: url(${supportImage}) !important;
                background-size: cover !important;
                background-position: center !important;
                z-index: 9999 !important;
                opacity: 0 !important;
                transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1) !important;
            `;
            setTimeout(() => {
                container.style.opacity = '1';
                container.style.transform = 'translate(-50%, -50%) scale(0.75)';
            }, 50);
            const criarBotao = (src, x, y, w, h, link) => {
                const btn = document.createElement('img');
                btn.src = src;
                btn.style.position = 'absolute';
                btn.style.left = `${x}px`;
                btn.style.top = `${y}px`;
                btn.style.width = `${w}px`;
                btn.style.height = `${h}px`;
                btn.style.transition = 'transform 0.3s ease';
                btn.style.cursor = 'pointer';
                btn.addEventListener('mouseenter', () => btn.style.transform = 'scale(1.1)');
                btn.addEventListener('mouseleave', () => btn.style.transform = 'scale(1)');
                btn.addEventListener('click', () => {
                    if (link) window.open(link, '_blank');
                    else {
                        container.remove();
                        overlay.remove();
                    }
                });
                return btn;
            };
            container.appendChild(criarBotao('https://i.imgur.com/6C466vU.png', 985, 649, 132, 150, 'https://linktr.ee/L4pisD4Silv4'));
            container.appendChild(criarBotao('https://i.imgur.com/T32os95.png', 1308, 651, 426, 116, 'https://ko-fi.com/l4pisd4silv4'));
            container.appendChild(criarBotao('https://i.imgur.com/HbC1dXb.png', 1773, 788, 52, 52));
            document.body.appendChild(overlay);
            document.body.appendChild(container);
        };
        GM_addStyle(`
            .lang-modal {
                position: fixed !important;
                top: 50% !important;
                left: 50% !important;
                transform: translate(-50%, -50%) !important;
                width: 300px !important;
                padding: 10px !important;
                background: #1e1e1e !important;
                border: 1px solid #444 !important;
                border-radius: 8px !important;
                z-index: 99999 !important;
                color: #fff !important;
            }
            .lang-option {
                margin: 6px 0 !important;
                padding: 12px !important;
                width: 100% !important;
                border: none !important;
                border-radius: 6px !important;
                background: #333 !important;
                color: #fff !important;
                cursor: pointer !important;
                transition: all 0.3s ease !important;
            }
            .lang-option:hover {
                background: #444 !important;
                transform: scale(1.02) !important;
            }
            .hover-zoom {
                transition: transform 0.2s ease !important;
                cursor: pointer !important;
            }
            .hover-zoom:hover {
                transform: scale(1.15) !important;
            }
        `);
        registerMenuCommands();
    };

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', () => {
            initializeUnlocker();
            initializeLanguageSystem();
        });
    } else {
        initializeUnlocker();
        initializeLanguageSystem();
    }

    setInterval(() => {
        if (document.querySelector('.brn-answer__content--locked')) {
            window.location.reload(true);
        }
    }, 5000);
})();