Multiple parameter keyword searches: Difference between revisions
m (Typos) |
m (red hat is now rht and sco is delisted! ;)) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Searches (Firefox)]] | |||
: ''For basics of keyword searches, refer to [[Using keyword searches]].'' | |||
==Creating a keyword search with multiple parameters== | |||
Copy/Paste the following string in your bookmark's Location field. Don't forget to replace ''###INSERT YOUR KEYWORD SEARCH URL HERE###'' with your search URL, which can now include multiple '''%s''' occurences. | |||
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,' | <pre>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>');</pre> | ||
(The script was was copied from an attachment in [https://bugzilla.mozilla.org/show_bug.cgi?id=124237 bug 124237] in [[Bugzilla]].) | |||
Examples | ==Usage== | ||
If we would want to compare the performance of two stocks using an | Just type this in Location Bar: | ||
search_keyword param1 param2 ... | |||
If one parameter contains spaces put it inside quotes. | |||
==Examples== | |||
===finance.yahoo.com=== | |||
If we would want to compare the performance of two stocks using an URL similar to this: | |||
http://finance.yahoo.com/q/bc?t=6m&s=%s&c=%s | http://finance.yahoo.com/q/bc?t=6m&s=%s&c=%s | ||
The | The bookmark URL would be | ||
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>'); | <pre>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>');</pre> | ||
If you chose the keyword compare you could compare Redhat's performance with | If you chose the keyword '''compare''' you could compare Redhat's performance with Microsoft by writing | ||
compare | compare rht msft | ||
===Googlefight=== | |||
Another example given the url for a googlefight: | Another example given the url for a googlefight: | ||
http://www.googlefight.com/cgi-bin/compare.pl?q1=%s&q2=%s&B1=Make+a+fight%21&compare=1&langue=us | http://www.googlefight.com/cgi-bin/compare.pl?q1=%s&q2=%s&B1=Make+a+fight%21&compare=1&langue=us | ||
And the bookmark would be | And the bookmark would be | ||
javascript:var%C2%A0s='%s';url='http://www.googlefight.com/cgi-bin/compare.pl?q1=%s&q2=%s&B1=Make+a+fight%21&compare=1&langue=us';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>'); | <pre>javascript:var%C2%A0s='%s'; url='http://www.googlefight.com/cgi-bin/compare.pl?q1=%s&q2=%s&B1=Make+a+fight%21&compare=1&langue=us'; 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> ');</pre> | ||
With the keyword fight you could do a search like | With the keyword '''fight''' you could do a search like | ||
fight "United States" Finland | fight "United States" Finland |
Latest revision as of 16:39, 29 May 2008
- For basics of keyword searches, refer to Using keyword searches.
Creating a keyword search with multiple parameters
Copy/Paste the following string in your bookmark's Location field. Don't forget to replace ###INSERT YOUR KEYWORD SEARCH URL HERE### with your search URL, which can now include multiple %s occurences.
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>');
(The script was was copied from an attachment in bug 124237 in Bugzilla.)
Usage
Just type this in Location Bar:
search_keyword param1 param2 ...
If one parameter contains spaces put it inside quotes.
Examples
finance.yahoo.com
If we would want to compare the performance of two stocks using an URL similar to this: http://finance.yahoo.com/q/bc?t=6m&s=%s&c=%s
The bookmark URL would be
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>');
If you chose the keyword compare you could compare Redhat's performance with Microsoft by writing
compare rht msft
Googlefight
Another example given the url for a googlefight: http://www.googlefight.com/cgi-bin/compare.pl?q1=%s&q2=%s&B1=Make+a+fight%21&compare=1&langue=us
And the bookmark would be
javascript:var%C2%A0s='%s'; url='http://www.googlefight.com/cgi-bin/compare.pl?q1=%s&q2=%s&B1=Make+a+fight%21&compare=1&langue=us'; 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> ');
With the keyword fight you could do a search like
fight "United States" Finland