Arch-A

A simplistic tampermonkey script that sends a highlighted piece of text to Google search or performs additional actions on Brainly.com question pages

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         Arch-A
// @namespace    https://github.com/DevilGlitch/ArchA
// @version      A.3.5.6
// @description  A simplistic tampermonkey script that sends a highlighted piece of text to Google search or performs additional actions on Brainly.com question pages
// @author       TheLostMoon. (Brainly script from ExtraTankz & Gradyn Wursten)
// @license      MIT
// @match        https://course.apexlearning.com/*
// @match        https://brainly.com/question/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Google Search
    if (window.location.host === 'course.apexlearning.com') {
        let highlightedText = '';
        let container = null;

        window.addEventListener('mouseup', event => {
            console.log('Mouse up event detected');
            runArchA();
        });

        // Function to send the request to Google search and display the response
        function runArchA() {
            highlightedText = window.getSelection().toString();
            if (!highlightedText) return;

            // Replace spaces with plus signs
            const query = highlightedText.replace(/\s+/g, '+');

            const searchUrl = `https://www.google.com/search?q=${query}`;

            // Open the Google search in a new tab
            window.open(searchUrl);

            // Deselect the selected text
            window.getSelection().removeAllRanges();
        }
    }

    // Brainly.com Question Page
    if (window.location.host === 'brainly.com') {
        // Remove unwanted elements after DOMContentLoaded
        document.addEventListener('DOMContentLoaded', function() {
            const unwantedElements = [
                '.brn-expanded-bottom-banner',
                '.brn-brainly-plus-box',
                '.brn-fullscreen-toplayer',
                '.sg-overlay.sg-overlay--dark',
            ];

            unwantedElements.forEach(selector => {
                const element = document.querySelector(selector);
                if (element) {
                    element.remove();
                }
            });
        });
    }
})();