Do everything better
Do everything better

# Firefox Tip: How to set up multi-parameter keyword searches

One of Firefox's most useful features is Quick Searches, the ability to assign a keyword to a link and pass a parameter in when you launch it - like `thes useful` to look up "useful" in a thesaurus.

But what about shortcuts that need more than one parameter, like comparing two stock prices? Turns out that multiple parameter keyword searches in Firefox are possible, with some Javascript magic.

After the jump, find out how to compare 3 stock symbols or pit 4 words against one another with Firefox keyword searches.

Single-parameter quick searches use the %s symbol to pass information into a link. For example, a bookmark with the keyword `map` might be `http://maps.google.com/maps?q=%s`. Type `map San Diego Zoo` into the address bar with that bookmark set up and poof! You'll get a map of the zoo.

If you want directions from one place to another, you need multiple parameters, which you can have - with a little help from our friend Javascript. Use this link template to enable as many %s instances in your bookmark URL as you need (sorry for the horizontal scroll):

` `javascript:var%C2%A0s='%s'; url='###INSERT YOUR KEYWORD SEARCH URL HERE###'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');` `

Replace `###INSERT YOUR KEYWORD SEARCH URL HERE###'` with your bookmark URL that has multiple instances of the %s parameter in it.

Check out some examples of useful multi-parameter keyword bookmarks. (Note: Copy and paste each of these URLs into a new bookmark and assign a keyword to launch them from the Firefox address bar.)

#### Alexaholic site traffic comparison (2 sites)

` `javascript:var%C2%A0s='%s'; url='http://www.alexaholic.com/%s+%s'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i];}}location.replace(nurl,'<BR>');` `

Bookmark this and give it the keyword `comparetraffic`. Then, type `comparetraffic lifehacker.com example.com` to run it.

` `javascript:var%C2%A0s='%s'; url='http://googlefight.com/index.php?lang=en_GB&word1=%s&word2=%s'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');` `

Pit two search terms against one another. Bookmark this one with the keyword `fight` and then try `fight "Getting Things Done" Lifehacker` to try it out. (Remember, multi-word values have to be enclosed in quotes.)

` `javascript:var%C2%A0s='%s'; url='http://www.google.com/trends?q=%s%2C%s&ctab=0&geo=all&date=all'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');` `

Compare the usage patterns of two words using Google Trends data.

` `javascript:var%C2%A0s='%s'; url='http://maps.google.com/maps?saddr=%s&daddr=%s'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='%22')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');` `

Get directions from Google Maps using a `directions` keyword and your starting and ending points, ie, `directions "San Diego, CA" "San Francisco, CA"`

#### Yahoo! Stock price comparison (2 stock symbols)

` `javascript:var%C2%A0s='%s'; url='http://finance.yahoo.com/q/bc?t=6m&s=%s&c=%s'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');` `

For more on quick searches, check out Adam's previously-published article, Firefox and the art of keyword bookmarking.

Multiple parameter keyword searches [MozillaZine]

### DISCUSSION These are very useful, but there's a keyword issue that's driving me crazy:

I already have a keyword for the Google Bookmarks bookmarklet (thanks to LH), but now I'm trying to create a keyword that allows me to enter the labels at the address bar, instead of waiting for the GB window to open and load. Consequently, I would also be able to have separate keywords with preset labels.

For example, I could type "gb SomeLabel" and get the regular Google Bookmarks window, and it would already have the label "SomeLabel" filled in.

I tried putting "&labels:%s" on the bookmarklet address, but it won't work. I don't understand why, because when I put the same thing at the end of the "pure" URL (without the javascript: stuff) it works.

Any ideas?
{"ft_lang_label":"__label__en","ft_lang_prob":0.5356716,"math_prob":0.854225,"size":5525,"snap":"2021-04-2021-17","text_gpt3_token_len":1585,"char_repetition_ratio":0.13294692,"word_repetition_ratio":0.12179487,"special_character_ratio":0.3156561,"punctuation_ratio":0.20163083,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95739913,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-17T15:15:52Z\",\"WARC-Record-ID\":\"<urn:uuid:a174c1c1-aa2a-411f-946c-0277b13f0377>\",\"Content-Length\":\"240854\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4a5398f2-1e43-4374-b120-f29b43b9caad>\",\"WARC-Concurrent-To\":\"<urn:uuid:ec3fe5cb-3479-411f-b7ef-9d96fc28f42e>\",\"WARC-IP-Address\":\"151.101.130.166\",\"WARC-Target-URI\":\"https://lifehacker.com/firefox-tip-how-to-set-up-multi-parameter-keyword-sear-240552\",\"WARC-Payload-Digest\":\"sha1:33WPUM3JMRJ2KFNKKUOFB7OUTW3BREUD\",\"WARC-Block-Digest\":\"sha1:LQ5AWUQWS62OOEGZFWIP5TRVKDQAYNO7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703513062.16_warc_CC-MAIN-20210117143625-20210117173625-00120.warc.gz\"}"}