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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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();
                }
            });
        });
    }
})();