Greasy Fork is available in English.

Auto-Expand Google Search Tools [pure javascript]

Show the Search Tools on Google search results instead of result-count and query-speed.

Per 01-12-2024. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name        Auto-Expand Google Search Tools [pure javascript]
// @description Show the Search Tools on Google search results instead of result-count and query-speed.
// @namespace   gsAutoExp
// @license     MIT
// @version     1.5
// @match       https://www.google.com/*
// @icon        https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant       GM_addStyle
// ==/UserScript==

/* Inspired by GollyJer's Auto-Expand Google Search Tools v 1.4
   https://greasyfork.org/en/scripts/13968-gollyjer-s-auto-expand-google-search-tools  */

/* globals $, waitForKeyElements */

// Hide the Search Tools button.
GM_addStyle('#hdtb-tls { display: none !important; }');

// Speed up visibility of the Seach Tools menu by removing the animation.
GM_addStyle('#hdtbMenus { transition: none !important; }');

// Show the Search Tools menu.
waitForKeyElements('#hdtb-tls', clickUntilItSticks);

function clickUntilItSticks(element) {
  var searchToolbar = document.getElementById('hdtbMenus'); // Use getElementById to select the element
  console.log('searchToolbar', searchToolbar);
  var sanityCount = 1;

  // Use setInterval to repeatedly check the condition
  var menusVisiblePoller = setInterval(function () {
    // Check whether the element is still invisible and increment sanityCount
    if (sanityCount < 20 && searchToolbar.offsetWidth === 0 && searchToolbar.offsetHeight === 0) {
      element.click(); // Trigger the click
      sanityCount++; // Increment the sanity counter
    } else {
      clearInterval(menusVisiblePoller); // Stop polling once the condition is met or the sanity limit is reached
    }
  }, 88);
}

/* Credit to https://github.com/CoeJoder/waitForKeyElements.js v1.3 */

function waitForKeyElements(selectorOrFunction, callback, waitOnce, interval, maxIntervals) {
    if (typeof waitOnce === "undefined") {
        waitOnce = true;
    }
    if (typeof interval === "undefined") {
        interval = 300;
    }
    if (typeof maxIntervals === "undefined") {
        maxIntervals = -1;
    }
    if (typeof waitForKeyElements.namespace === "undefined") {
        waitForKeyElements.namespace = Date.now().toString();
    }
    var targetNodes = (typeof selectorOrFunction === "function")
            ? selectorOrFunction()
            : document.querySelectorAll(selectorOrFunction);

    var targetsFound = targetNodes && targetNodes.length > 0;
    if (targetsFound) {
        targetNodes.forEach(function(targetNode) {
            var attrAlreadyFound = `data-userscript-${waitForKeyElements.namespace}-alreadyFound`;
            var alreadyFound = targetNode.getAttribute(attrAlreadyFound) || false;
            if (!alreadyFound) {
                var cancelFound = callback(targetNode);
                if (cancelFound) {
                    targetsFound = false;
                }
                else {
                    targetNode.setAttribute(attrAlreadyFound, true);
                }
            }
        });
    }

    if (maxIntervals !== 0 && !(targetsFound && waitOnce)) {
        maxIntervals -= 1;
        setTimeout(function() {
            waitForKeyElements(selectorOrFunction, callback, waitOnce, interval, maxIntervals);
        }, interval);
    }
}