The following script does what I want it to do but not as fast as I'd like it to do it. :-)
The goal is always show the search tools that become visible when the Search Tools button is clicked on Google Search results.
I can't get waitForKeyElements
to work without applying a timer.
WaitForKeyElements was made for this purpose so I feel like I'm missing something.
This script works, sort of, but takes too long and seems brittle:
// ==UserScript==
// @name GollyJer's Expand Google Search Tools
// @namespace gollyjer.com
// @version 1.0
// @include /^https?\:\/\/(www|news|maps|docs|cse|encrypted)\.google\./
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
function expandSearchTools () {
// Fires too soon?
// var searchToolsButton = document.getElementById("hdtb-tls");
// searchToolsButton.click();
// Working but distracting.
setTimeout(
function(){
var searchToolsButton = document.getElementById("hdtb-tls");
searchToolsButton.click();
}, 1000);
}
waitForKeyElements ("#ires", expandSearchTools);