Consistent I'm Feeling Lucky macro for Google

Made a workaround Greasemonkey script:

// ==UserScript==
// @name         Google IFL
// @match        https://*.google.com/*?lucky=*
// @match        http://*.google.com/*?lucky=*
// ==/UserScript==

document.getElementById("gsr").style.display = 'none'; // optional. shows blank screen before forwarding. just looks better imo.
document.getElementById("gbqfq").focus();
var pathname = document.URL;
var start = pathname.indexOf("?lucky=");
var searchterm = pathname.substring(start+7);
document.getElementById("gbqfq").value = decodeURI(searchterm);
var btnLucky = document.getElementsByName('btnI')[0];
btnLucky.click();

This script will always forward you to Google's "I Feel Lucky" choice provided you navigate to www.google.com/?lucky=searchterm_goes_here.

I'm using it in FireFox by having a keyword to a bookmark going to www.google.com/?lucky=%s.


When you have Javascript disabled, it seems that Google uses both a cookie and the HTTP Referrer header being set to https://www.google.com to track if you actually came from the Google home page and clicked the "I'm Feeling Lucky" button. I don't think you'll be able to convince Google to hand you the lucky result with just a URL.


The best solution I've come up with is: Chrome > Preferences > Manage Search Engines... add:

  • Search Engine: I'm Feeling Lucky
  • Keyword: \ (replace with your preferred shortcut)
  • URL: {google:baseURL}search?q=%s&btnI

Then as per this thread, add the following Greasemonkey / Tampermonkey script to reload the page with Google as the referrer.

// ==UserScript==
// @name         I'm feeling lucky fix
// @version      0.0
// @description  Makes Google I'm feeling lucky work reliably from the address bar
// @author       Will Rice
// @match        http://*.google.co.uk/search?q=*&btnI
// @match        https://*.google.co.uk/search?q=*&btnI
// @match        http://*.google.com/search?q=*&btnI
// @match        https://*.google.com/search?q=*&btnI
// ==/UserScript==

document.getElementsByTagName("body")[0].style.display = "none";
window.location.href = location;

Setting the script to "run at body" and adding any additional Google TLDs as you see fit (I couldn't get regex working in Tampermonkey).