Greasy Fork is available in English.

Auto-Espande Google Search Tools

Mostra il menu Strumenti di ricerca nei risultati di ricerca di Google

// ==UserScript==
// @name           Auto-Espande Google Search Tools
// @description    Mostra il menu Strumenti di ricerca nei risultati di ricerca di Google
// @namespace      https://greasyfork.org/users/237458
// @author         figuccio
// @match          https://*.google.com/*
// @match          https://*.google.it/*
// @version        15.8
// @require        https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @require        https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=19641
// @grant          GM_addStyle
// @grant          GM_setValue
// @grant          GM_getValue
// @run-at         document-start
// @icon           https://www.google.com/s2/favicons?domain=google.it
// @noframes
// @license        MIT
// ==/UserScript==
//Filtro alcuni  risultati potrebbero essere espliciti click automatico su ignora dopo 4sec
setTimeout(function(){
document.querySelector("#appbar > div.zNFAfd > div > div.zRHtD > div.O6QT3d > g-raised-button > div").click();}, 4000);
//icona tema sempre visibile
GM_addStyle('.iOHNLb{opacity:1!important;background-color: ;color:!important;}');

              // Show the Search Tools menu
GM_addStyle("#hdtbMenus{display:block !important;position:absolute !important;top:68px !important;}");
GM_addStyle("#result-stats{display:none!important;}");/* Circa 261.000.000 risultati (0,61 secondi) nascosto */

//////////////
//Accelera la visibilità del menu Strumenti di ricerca rimuovendo l'animazione.
GM_addStyle("#hdtbMenus { transition: none !important; }");
//pulsante Strumenti di ricerca rosso
GM_addStyle("#hdtb-tls { color:red !important;background:green!important; border-radius:12px;border:2px solid red!important}");

//testo altro,immagini.ecc colore rosso spondo arancione
GM_addStyle('#hdtb .hdtb-mitem a {color:red!important;background:orange!important;border-radius:8px;padding:4px 4px;border:2px solid green!important}');

           //altro
GM_addStyle('.hdtb-mitem .GOE98c{color:red!important;background:orange!important;border-radius:8px;padding:4px 4px!important;border:2px solid green!important}');

    //link altro,immagini.maps ecc colore rosso che cambia colore al passaggio mouse diventa verde
GM_addStyle('#hdtb .hdtb-mitem a:hover{color:green!important}');

GM_addStyle('#hdtb-msb {min-width:0px!important}');//pulsanti impostazioni e strumenti avvicinati al pulsante altro
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//colori testo strumenti colore verde Search Tools
GM_addStyle('.hdtb-mn-hd {color:green!important;background:gold!important;border-radius:9px;border:2px solid blue!important}');

//link espansione strumenti colore verde che diventa rosso al passaggio mouse
GM_addStyle('.hdtb-mn-hd:hover {color:red!important}');

//topbar espansioni strumenti colorata Search Tools
GM_addStyle('.WE0UJf {background:#303134!important;width:700px;border-radius:12px;border:1px solid red!important}');//ok
//pulsante tutti
GM_addStyle('#hdtb-msb .hdtb-mitem.hdtb-msel{color:red!important;background:orange!important;border-radius:8px;border:2px solid green!important;padding:4px 4px;border-bottom:6px solid blue!important}');
//triangolini rossi
GM_addStyle('.gTl8xb {border-color:red transparent!important}');
//menu colorato
GM_addStyle('.hdtbItm.hdtbSel, .hdtbItm a,#hdtb-more-mn a,#cdrlnk, .hdtb-mn-o {color:lime!important;background:red !important;}');
GM_addStyle('.hdtb-mn-o {border:2px solid blue!important}');//bordo blu

//no publicita correlate
GM_addStyle('#rcnt .col:nth-of-type(3) {display:none !important;}');

   //le persone anno chiesto anche
GM_addStyle('.OJXvsb.Wnoohf.cUnQKe.kp-blk {display:none !important;}');

//Promemoria sulla privacy di Google
GM_addStyle('#cnsh,#cnso,#cnsi{display:none!important}');
//////////////////////////////////////////////////aggiunto youtube
process();
new MutationObserver(process).observe(document.body || document.documentElement, { childList: true, subtree: true });

function process(mutations) {
  let q,
    queryElement = document.querySelector('input[name="q"]');		// selector for the Google search input textbox

  if (queryElement?.value) q = encodeURIComponent(queryElement.value);
  else if (q = location.href.match(/^.+?(?:[#/&?](?:q|query))=(.+?)(?:|&.+|\|.+)$/)) q = q[1];

  let link = document.querySelector(`a[href*='tbm=vid']`);

  if (q && link?.href) {
    link.href = 'https://www.youtube.com/results?search_query=' + q;
    //link.textContent = link.textContent.replace(/\S+/, 'YouTube');;
    link.textContent = 'YouTube';
    console.log('create', link.textContent);
  }
}
///ricerche correlate
GM_addStyle('#brs {display:none !important;}');

GM_addStyle('.commercial-unit-desktop-top {display:none !important;}');

      ///////////////cookie consent//////////////
(function(){
"use strict";
if (document.readyState != 'loading') consent();
else document.addEventListener('DOMContentLoaded', consent);

function consent() {
  var e=document.querySelector('#introAgreeButton');
  if (!e) e=document.querySelector('div.jw8mI button#zV9nZe.tHlp8d, div.VDity button#L2AGLb.tHlp8d');
  e && e.click();
  }

})();

/////////colori menu ingranaggio e menu che compare quando clicco tipo su qualsiasi data ecc
GM_addStyle('.gLSAk {background-color:!important;color:!important;border:2px solid green!important}');

//di nuovo publicita e correlati a destra
GM_addStyle('#rhs {display:none !important;}');

GM_addStyle('.YTDezd {display:none !important;}');


/////scorrimento pagine senza ricarica endless google
  if (location.href.indexOf("tbm=isch") !== -1) // NOTA: non eseguire la ricerca di immagini
    return;
if (window.top !== window.self) // NOTA: non eseguire su iframe
    return;
const centerElement = "#center_col";
const loadWindowSize = 1.6;
const filtersAll = ["#foot", "#bottomads"];
const filtersCol = filtersAll.concat(["#extrares", "#imagebox_bigimages"]);
let msg = "";

const css = `
.page-number {
  position: relative;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
	margin-bottom: 2em;
	color: red;
}
.page-number::before {
  content: "";
  background-color: green;
  height: 1px;
  width: 100%;
  margin: 1em 3em;
}
.endless-msg {
  position:fixed;
  bottom:0;
  left:0;
  padding:5px 10px;
  background: darkred;
  color: white;
  font-size: 11px;
  display: none;
}
.endless-msg.shown {
  display:block;
}
`;

let pageNumber = 1;
let prevScrollY = 0;
let nextPageLoading = false;

function requestNextPage() {
    nextPageLoading = true;
    let nextPage = new URL(location.href);
    if (!nextPage.searchParams.has("q")) return;

    nextPage.searchParams.set("start", String(pageNumber * 10));
    !msg.classList.contains("shown") && msg.classList.add("shown");
    fetch(nextPage.href)
        .then(response => response.text())
        .then(text => {
            let parser = new DOMParser();
            let htmlDocument = parser.parseFromString(text, "text/html");
            let content = htmlDocument.documentElement.querySelector(centerElement);

            content.id = "col_" + pageNumber;
            filter(content, filtersCol);

            content.style.marginLeft = '0';

            let pageMarker = document.createElement("div");
            pageMarker.textContent = String(pageNumber + 1);
            pageMarker.className = "page-number";

            let col = document.createElement("div");
            col.className = "next-col";
            col.appendChild(pageMarker);
            col.appendChild(content);
            document.querySelector(centerElement).appendChild(col);

            if (!content.querySelector("#rso")) {
                // fine dei risultati
                window.removeEventListener("scroll", onScrollDocumentEnd);
                nextPageLoading = false;
                msg.classList.contains("shown") && msg.classList.remove("shown");
                return;
            }

            pageNumber++;
            nextPageLoading = false;
            msg.classList.contains("shown") && msg.classList.remove("shown");
        });
}

function onScrollDocumentEnd() {
    let y = window.scrollY;
    let delta = y - prevScrollY;
    if (!nextPageLoading && delta > 0 && isDocumentEnd(y)) {
        requestNextPage();
    }
    prevScrollY = y;
}

function isDocumentEnd(y) {
    return y + window.innerHeight * loadWindowSize >= document.body.clientHeight;
}

function filter(node, filters) {
    for (let filter of filters) {
        let child = node.querySelector(filter);
        if (child) {
            child.parentNode.removeChild(child);
        }
    }
}

function init() {
    prevScrollY = window.scrollY;
    window.addEventListener("scroll", onScrollDocumentEnd);
    filter(document, filtersAll);
    let style = document.createElement("style");
    style.type = "text/css";
    style.appendChild(document.createTextNode(css));
    document.head.appendChild(style);
    msg = document.createElement("div");
    msg.setAttribute("class", "endless-msg");
    msg.innerText = "Caricamento pagina successiva...";
    document.body.appendChild(msg);
}

document.addEventListener("DOMContentLoaded", init);

//////////////////////30risultati per pagina
(function() {
  'use strict';
  if (GM_getValue('Amount of results to Show') === undefined) //Se la quantità di risultati da mostrare non è definita
  {GM_setValue('Amount of results to Show', 30);} //Imposta la quantità predefinita di risultati da mostrare come 30/100

  if (location.pathname === '/search' && location.href.match('&num=' + GM_getValue('Amount of results to Show') + '&newwindow=') === null)
  {location.href = location.href += '&num=' + GM_getValue('Amount of results to Show') + '&newwindow=';} //Reindirizza per aggiungere le scelte dell'utente
})();
/////////////////////////////////////////////////////////////////////////////////////////