Auto-Espande Google Search Tools

Mostra il menu Strumenti di ricerca nei risultati di ricerca di Google +link colorati

当前为 2020-07-31 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Auto-Espande Google Search Tools
// @description Mostra il menu Strumenti di ricerca nei risultati di ricerca di Google +link colorati
// @namespace   https://greasyfork.org/users/237458
// @author      figuccio
// @include      /https:\/\/www\.google\.(com?(\.[a-z]{2})?|[a-z]{2})\/.*/
// @version     12.5
// @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
// @noframes
// ==/UserScript==
(function() {
    'use strict';
    /* globals $, waitForKeyElements */
//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}');

    //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 arancione
//GM_addStyle('#slim_appbar.ab_tnav_wrp{background:orange!important;width:700px;border-radius:12px;}');//non funziona piu
GM_addStyle('body.vasq .WE0UJf {background:green!important;width:700px;border-radius:12px;border:2px dotted red!important}');//funziona

//link ricerca google colorati di rosso
GM_addStyle('a:visited {color:black !important}');
//GM_addStyle('a:link {color:red !important}');

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

GM_addStyle('.mn-dwn-arw {border-color:red transparent!important}');//triangolini rossi
//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
//Accelera la visibilità del menu Strumenti di ricerca rimuovendo l'animazione.
GM_addStyle("#hdtbMenus { transition: none !important; }");
// Mostra il menu Strumenti di ricerca.
waitForKeyElements("#hdtb-tls", clickNodeUntilItSticks);
function clickNodeUntilItSticks(jNode) {
  var searchToolbar = $("#hdtbMenus")[0];
  var sanityCount = 1;
  var menusVisiblePoller = setInterval(function() {
    if (
      sanityCount < 20 &&
      searchToolbar.offsetWidth === 0 &&
      searchToolbar.offsetHeight === 0
    ) {
      jNode[0].click();
    } else {
      clearInterval(menusVisiblePoller);
    }
  },88 );
}
})();
//no publicita correlate
GM_addStyle('#rcnt .col:nth-of-type(3) {display:none !important;}');

//funzione endless google
const centerElement = "#center_col";
const loadWindowSize = 1.6;
const filtersAll = ["#foot", "#bottomads"];
const filtersCol = filtersAll.concat(["#extrares", "#imagebox_bigimages"]);

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: 90%;
  margin: 1em 3em;
}
`;

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));

    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);

            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")) {
                // end of results
                window.removeEventListener("scroll", onScrollDocumentEnd);
                nextPageLoading = false;
                return;
            }

            pageNumber++;
            nextPageLoading = false;

        });
}

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);
}
document.addEventListener("DOMContentLoaded", init);

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