Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

With a bookmark of IMDb http://www.imdb.com/find?q=%s and a keyword imdb, I can type imdb seven then enter, and it will send me at http://www.imdb.com/find?q=seven.

With the same bookmark or another one how can I make imdb then enter go to http://www.imdb.com/, and not http://www.imdb.com/find?q=?

EDIT

Thanks to iglvzx, here's a JavaScript solution (original script by iglvzx, modified to load the main URL if the bookmark is selected in Firefox's menus). m is main URL, s is search. See his answer for more information.

javascript:(function(){var q='%s',m='http://www.google.com/',s='http://www.google.com/search?q='+q;if(keywords==''||keywords=='%'+'s'){window.location=m;}else{window.location=s;}})();
share|improve this question
    
Couldn't you save the second bookmark as imd? Then just type imd, instead of imdb. It's even shorter ;) –  mreq May 8 '12 at 17:58
    
I haven't imdb only… But yes, it'll be the solution if there's no aleternative! ;) –  Joan May 8 '12 at 18:04
    
Than maybe make an unified syntax, say prepend s as in search to the site name. So simdb, swiki, sgoogle etc... –  mreq May 8 '12 at 18:06
    
Yes, good idea. But I can't figure out I'm the first one trying to do this! (Or there's no way in 12 version of Ff !) –  Joan May 8 '12 at 18:08
    
@Didjo Good catch on the %s case! I will include that in my answer, too. –  iglvzx May 8 '12 at 22:34
add comment

3 Answers 3

up vote 6 down vote accepted

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 = "http://superuser.com/";
    var searchURL = "http://superuser.com/search?q=" + keywords;

    if (keywords == "" || keywords == "%" + "s")
    {
        window.location = mainURL;
    }
    else
    {
        window.location = searchURL;
    }

})();

Compressed:

javascript:(function(){var keywords="%s";var mainURL="http://superuser.com/";var searchURL="http://superuser.com/search?q="+keywords;if(keywords==""||keywords=="%"+"s"){window.location=mainURL}else{window.location=searchURL}})();

Setup:

  1. Create a new bookmark. Open the Firefox Library.

    library

  2. Select a folder. Right-click and select New Bookmark....

    new bookmark

  3. Enter the name, location, and keyword fields for the bookmark, pasting the JavaScript bookmarklet as the location.

    add

  4. Close the Library.


Demo:

Now, you can launch a location or perform a search using a single keyword!

  • With no search keywords:

    no keywords

    mainURL

  • With search keywords:

    search keywords

    searchURL

Video Demo: http://www.youtube.com/watch?v=DGNU5FiogXM

share|improve this answer
    
THAT is a very good idea. Thanks. But it's still a very huge lack in Firefox… (And Chrome, BTW.) Thanks again, this idea rocks. (I didn't tried it yet but just thaught: Firefox disabled javascript from address bar, didn't it?) –  Joan May 8 '12 at 21:23
    
I used Firefox 12 with default settings in my example. Yes, you have to call the JavaScript from a bookmark. You can't paste it directly into the address bar. –  iglvzx May 8 '12 at 21:29
    
This method delete bookmark favicon. I tried the Bookmark Favicon Changer plug-in but it doesn't work. Got a JS idea? ;) –  Joan May 9 '12 at 21:08
    
Great answer and great screen shots. +1 –  Peter Feb 1 '13 at 16:51
add comment

Add to Search Bar does exactly what you want. For example, when you type imdb battleship it searchs for the movie battleship, but when you type imdb, it opens imdb.com.

share|improve this answer
add comment

You can try multiple bookmarks with different name (say prepending a letter) as discussed in the comments.

Other than that, you may want to try the instafox plugin. Combined with bookmarks, it could give you the desired result.

share|improve this answer
1  
This plugin looks great! I'm gonna look around it. Thank you! (I let open in case someone has a plugin-free solution!) –  Joan May 8 '12 at 18:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.