// ==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
// @include https://www.google.tld/*
// @version 14.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.com
// @noframes
// ==/UserScript==
//icona tema sempre visibile
GM_addStyle('.iOHNLb{opacity:1!important;background-color: ;color:!important;}');
/*
// Show the Search Tools menu.N qualsiasi data y ultima ora
if(document.URL.search("&tbo=") == -1) {
window.location.search += "&tbo=1";
if(document.URL.search("&tbs=") == -1) {
window.location.search += "&tbs=qdr:N";
}
}
*/
// Show the Search Tools menu
GM_addStyle(`
#hdtbMenus {
display: block !important;
position: absolute !important;
top: 68px !important;
}
#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}");
//link 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
//link espansione strumenti colore verde
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 verde
GM_addStyle('.WE0UJf {background:green!important;width:700px;border-radius:12px;border:2px dotted 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;}');
//scrollbar nera
(function() {var css = "";
css += [
"/*####----BROWSER SCROLL BAR----####*/",
"::-webkit-scrollbar {",
"background: -webkit-linear-gradient(40deg , #040404 , #0C0C0C , #040404 100%)!important;",
"border-left: 1px solid #1A1A1A !important; width:19px!important;",
"}",
"::-webkit-scrollbar-thumb {background-color: #272727!important;border-radius: 16px!important;box-shadow: inset 0 0 0 2px green!important;}",
///////////////////pulsanti sotto freccine su e giu
"::-webkit-scrollbar-button { background-color: red; }",
///////////////////////freccia nera sopra
"::-webkit-scrollbar-button:vertical:decrement {",
"background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QgFDgo6IB/FRgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAc0lEQVQoz+XRoQ2DYBiE4YfUkEDqEfW1TNA5EFUdAM0aTNEpSKqwKAZogkJgmpDUgPkFqFa3py757r1PHP+jEgPqb4ELGizocf0EnHDHO0ALHjhvQ4eNT3BDgSPmcE8RoQ1lOyhHhRgjXpjCtwwdnr864go2lhOp4XYeZgAAAABJRU5ErkJggg==)!important;",
"background-size: cover!important;",
"background-repeat: no-repeat!important;",
"}",
////////////////////freccia nera sotto
"::-webkit-scrollbar-button:vertical:increment {",
"background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QgFDgUlKo/UfAAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAaUlEQVQoz+XPsQmDUAAE0NfHFdI7gZ1kEmdI6Q6WTuEUQiZIl8o0CYGAvYUg3+aXitZ6zcFxx91xbOR44oMO78jfqGdLoQQVekwYEPBHictaW4pHNAeMaHDdmlngFUMtbnv/1fjh7iSYAfRHFgTlUa3mAAAAAElFTkSuQmCC)!important;",
"background-size: cover!important;",
"background-repeat: no-repeat!important;",
"}",
].join("\n");
if (typeof GM_addStyle != "undefined") {
GM_addStyle(css);
} else if (typeof PRO_addStyle != "undefined") {
PRO_addStyle(css);
} else if (typeof addStyle != "undefined") {
addStyle(css);
} else {
var node = document.createElement("style");
node.type = "text/css";
node.appendChild(document.createTextNode(css));
var heads = document.getElementsByTagName("head");
if (heads.length > 0) {
heads[0].appendChild(node);
} else {
// no head yet, stick it whereever
document.documentElement.appendChild(node);
}
}
})();
//////////////////////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
})();
/////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);
//////////////////////////////////