Google Search Category Sanity

Adds a bar of search category links that STAY IN ORDER!

Versión del día 20/09/2023. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Google Search Category Sanity
// @namespace    https://greasyfork.org/en/users/1148791-vuccala
// @icon         https://archive.org/download/userscripticon/userscripticon.png
// @author       Vuccala
// @version      0.4
// @description  Adds a bar of search category links that STAY IN ORDER!
// @match        https://*.google.*/search*
// @grant        none
// @license      MIT
// @run-at       document-body
// ==/UserScript==

(function() {
    'use strict';

    // Get the current URL's query string
    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    const copiedQueryString = urlParams.get('q');

    const goog = window.location.origin;

    // Create the links
    const textsearch = document.createElement('a');
    textsearch.href = `${goog}/search?q=${copiedQueryString}&tbs=li:1`;
    textsearch.textContent = 'Web';

    const imagesearch = document.createElement('a');
    imagesearch.href = `${goog}/search?q=${copiedQueryString}&tbm=isch`;
    imagesearch.textContent = 'Images';

    const videosearch = document.createElement('a');
    videosearch.href = `${goog}/search?q=${copiedQueryString}&tbm=vid`;
    videosearch.textContent = 'Videos';

    const mapsearch = document.createElement('a');
    mapsearch.href = `https://maps.google.com/maps?q=${copiedQueryString}`;
    mapsearch.textContent = 'Maps';

    const booksearch = document.createElement('a');
    booksearch.href = `${goog}/search?q=${copiedQueryString}&tbm=bks`;
    booksearch.textContent = 'Books';

    const newssearch = document.createElement('a');
    newssearch.href = `${goog}/search?q=${copiedQueryString}&tbm=nws`;
    newssearch.textContent = 'News';

    const youtube = document.createElement('a');
    youtube.href = `https://www.youtube.com/results?search_query=${copiedQueryString}`;
    youtube.textContent = 'YouTube';

    const trsearch = document.createElement('a');
    trsearch.href = `https://translate.google.com/?text=${copiedQueryString}`;
    trsearch.textContent = 'Translate';

  // Create a div element
    const betterbar = document.createElement('div');
    betterbar.style.cssText = `
        position: absolute;
        top: 75px;
        left: 0;
        width: 100%;
        background-color: #DDD2;
        padding: 13px;
        font-size: 16px;
        font-weight: bold;
        z-index: 3;
    `;
    betterbar.appendChild(textsearch); betterbar.appendChild(document.createTextNode(' | '));
    betterbar.appendChild(imagesearch); betterbar.appendChild(document.createTextNode(' | '));
    betterbar.appendChild(videosearch); betterbar.appendChild(document.createTextNode(' | '));
    betterbar.appendChild(mapsearch); betterbar.appendChild(document.createTextNode(' | '));
    betterbar.appendChild(newssearch); betterbar.appendChild(document.createTextNode(' | '));
    betterbar.appendChild(booksearch); betterbar.appendChild(document.createTextNode(' | '));
    betterbar.appendChild(trsearch); betterbar.appendChild(document.createTextNode(' | '));
    betterbar.appendChild(youtube);

    // Create a spacer div to push down the content
    const spacerDiv = document.createElement('div');
    spacerDiv.style.cssText = `
        height: 36px;
    `;

    // Insert the spacer div before the content
    document.body.insertBefore(spacerDiv, document.body.firstChild);

    // Insert the div at the top of the page
    document.body.insertBefore(betterbar, spacerDiv.nextSibling);
})();