You can achieve this with a JavaScript bookmarklet. I will post the uncompressed code first (so it's easy to read), and then the code compressed to a single line for Firefox.
Uncompressed: Thanks, @Didjo, for catching the extra %s
case!
javascript: (function(){ var keywords = "%s"; var mainURL = "https://superuser.com/"; var searchURL = "https://superuser.com/search?q=" + keywords; if (keywords == "" || keywords == "%" + "s") { window.location = mainURL; } else { window.location = searchURL; } })();
Compressed:
javascript:(function()else})();
Setup:
Create a new bookmark. Open the Firefox Library.
Select a folder. Right-click and select
New Bookmark...
.Enter the name, location, and keyword fields for the bookmark, pasting the JavaScript bookmarklet as the location.
Close the Library.
Demo:
Now, you can launch a location or perform a search using a single keyword!
With no search keywords:
With search keywords: