Page 1 of 2 12 LastLast
Results 1 to 10 of 13

This is a discussion on Multiple critiera using custom search engines? within the Chrome Tips & Tricks section, part of the Google Chrome category: Greetings and salutations. I am a new Chrome user. Almost (not officially, but close) converted from Firefox. I might not ...


  1. #1
    thespecialk is offline Junior Member
    Join Date
    Oct 2009
    Posts
    11

    Default Multiple critiera using custom search engines?

    Greetings and salutations.

    I am a new Chrome user. Almost (not officially, but close) converted from Firefox. I might not completely make the swim across until there is more add-on support, but I'm mighty impressed thus far.

    My first question is regarding the custom engine search. I have listed several search engines that I routinely check. I was wondering if it's possible to search for multiple criteria.

    For instance, I often check baseball statistics. Let me use ESPN for example. If I use their sort feature for player statistics, I would insert "%s" in the portion of the URL that would be customized to the search within the Omnibar. Let's say I want to search for John Doe but in the year 2008. Is it possible to do multiple %s in a criteria so I can search for more than one parameter?

  2. #2
    Michael3185 is offline Senior Member
    Join Date
    Apr 2009
    Location
    Lincoln, UK
    Posts
    377

    Default

    Quote Originally Posted by thespecialk View Post
    I am a new Chrome user. Almost (not officially, but close) converted from Firefox.
    Hi special. That made me smile! When someone 'officially' migrates to Chrome from Firefox, should they get a little badge, I wonder..?

    Let's say I want to search for John Doe but in the year 2008. Is it possible to do multiple %s in a criteria so I can search for more than one parameter?
    I'm not sure if I'm reading this right, and I deleted all search engines except Google as it's the only one I use, but... Do you mean searching for a number of distinct strings at once? If so, your example would be;

    ["john doe" 2008]

    That's standard in most search engines, and other than that I'm not sure how there could be multiple parameters..?
    Veesteronnalaptop, and Chrome extension mods at http://gochrome.letsdoo.org

  3. #3
    thespecialk is offline Junior Member
    Join Date
    Oct 2009
    Posts
    11

    Default

    Quote Originally Posted by Michael3185 View Post
    Hi special. That made me smile! When someone 'officially' migrates to Chrome from Firefox, should they get a little badge, I wonder..?

    I'm not sure if I'm reading this right, and I deleted all search engines except Google as it's the only one I use, but... Do you mean searching for a number of distinct strings at once? If so, your example would be;

    ["john doe" 2008]

    That's standard in most search engines, and other than that I'm not sure how there could be multiple parameters..?
    Basically, as far as I can tell, the search engine support lists just one search, such as "John Doe" or "John Doe 2008". But, for instance, with ESPN's sortable stats, if I wanted to search by player, by year and by name, in the URL, they're actually listed in separate parts of the bar. For instance it might go "player=John Doe," and later, "year=2008" and "team=anyteam"

    So I'm trying to be able to account for the various types of search criteria in a database.

  4. #4
    Luc VN's Avatar
    Luc VN is offline Senior Member
    Join Date
    Sep 2008
    Location
    Belgium - Europe
    Posts
    758

  5. #5
    PAEz's Avatar
    PAEz is offline Moderator
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    655

    Default

    I think what he wants is something along the lines of
    The search bar input looks like this...
    "John Does" 2008 anyteam
    ...and the url would be somthing like....
    http:\\some.dot.com\searchpage?player=%1&year=%2&team=%3
    ...and if thats right, then no sorry theres no way to do that...pity, that would be cool

  6. #6
    thespecialk is offline Junior Member
    Join Date
    Oct 2009
    Posts
    11

    Default

    Quote Originally Posted by PAEz View Post
    I think what he wants is something along the lines of
    The search bar input looks like this...
    "John Does" 2008 anyteam
    ...and the url would be somthing like....
    http:\\some.dot.com\searchpage?player=%1&year=%2&team=%3
    ...and if thats right, then no sorry theres no way to do that...pity, that would be cool
    Yep, this is what I meant. Appreciate all the feedback. I'm sure we're not far off having the ability to do that kind of thing. Seems like something that could be created in the near future without too much hassle.

  7. #7
    sammio5 is offline Junior Member
    Join Date
    Dec 2009
    Posts
    1

    Default (Hacky) solution

    I managed to accomplish this using some (hacky and ugly!) javascript. Use the following as your "url":

    javascript:url='http://searchengine?term1=%0s&term2=%1s';parts='%s'.replace(/(%5C%5C)?\+/g, function($0,$1)%7Breturn($1?'+':'qzq')%7D).split('qzq');for(var i=0; i < parts.length && (url=url.replace(new RegExp('%'+i+'s', 'g'),parts[i]));i++);location=url.replace(/%[0-9]s/g,'')


    but change the "url" variable at the front to be whatever you want. Use '%0s', '%1s' etc to refer to query terms (and you can instantiate them multiple times). Any terms that aren't supplied are replaced with empty strings. When using this you can add '\\' before spaces to escape them

    For example, if the keyword for this search engine is 'sf' use 'sf term\\ one term2' if you want to pass 'term one' and 'term2' as the two terms.

    Final note: this fails if your query happens to contain 'qzq' but that shouldn't be too likely :-)

  8. #8
    thespecialk is offline Junior Member
    Join Date
    Oct 2009
    Posts
    11

    Default

    Quote Originally Posted by sammio5 View Post
    I managed to accomplish this using some (hacky and ugly!) javascript. Use the following as your "url":

    javascript:url='http://searchengine?term1=%0s&term2=%1s';parts='%s'.replace(/(%5C%5C)?\+/g, function($0,$1)%7Breturn($1?'+':'qzq')%7D).split('qzq');for(var i=0; i < parts.length && (url=url.replace(new RegExp('%'+i+'s', 'g'),parts[i]));i++);location=url.replace(/%[0-9]s/g,'')


    but change the "url" variable at the front to be whatever you want. Use '%0s', '%1s' etc to refer to query terms (and you can instantiate them multiple times). Any terms that aren't supplied are replaced with empty strings. When using this you can add '\\' before spaces to escape them

    For example, if the keyword for this search engine is 'sf' use 'sf term\\ one term2' if you want to pass 'term one' and 'term2' as the two terms.

    Final note: this fails if your query happens to contain 'qzq' but that shouldn't be too likely :-)
    Thanks for this. I haven't got a chance to test it. I'll take a look tonight and play around with it and see if I can get this to work.

  9. #9
    PAEz's Avatar
    PAEz is offline Moderator
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    655

    Default

    Thats awesome sammio5. I havent had need to try it yet but what I like is the fact that you can use javascript as the url, I had no idea you could do that. That means some bookmarklets that require input could use this approach which would be great for people that prefer to type than click.
    For instance heres a zoom bookmarklet as a search url....
    Code:
    javascript:(function()%7Bvar objZoom=document.getElementsByTagName('body')[0].style.zoom='%s'; %7D)()
    ...so if you make that the url and make its keyword z then you can type "z 1.5" in the omnibar and the page zooms to 1.5
    Unfortunately it doesnt seem to like alot of bookmarklets as urls and Im not sure why? If you have any idea Id love to hear it. Im a clicker more than a typer but I know alot of people would like this.
    Wouldnt be suprised if google remove this ability if they find out about it as it MAY be a security risk?....dunno
    Last edited by PAEz; 12-11-2009 at 05:17 AM.

  10. #10
    PAEz's Avatar
    PAEz is offline Moderator
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    655

    Default

    Actually looking at that bookmarklet made it obvious...drrrrrr
    The curlys have to be replaced as they make for an unvalid url.
    So replace all { with %7B and all } with %7D and it works!...tried it on a bunch or bookmarklets

Page 1 of 2 12 LastLast

Similar Threads

  1. Windows 7 Custom Jumplist
    By seiichi in forum Chrome Tips & Tricks
    Replies: 3
    Last Post: 02-24-2011, 02:26 PM
  2. Context Search And Search Engine Drop-down Box
    By chrome567 in forum Plugins Development
    Replies: 12
    Last Post: 11-06-2009, 07:59 PM
  3. Custom Search in ToolStrip
    By caveman.savant in forum Plugins Development
    Replies: 1
    Last Post: 09-18-2009, 06:21 PM
  4. Multiple Chrome processes
    By Excalibur in forum Chrome Troubleshooting
    Replies: 3
    Last Post: 05-14-2009, 12:29 AM
  5. Chrome Custom Mouse Gestures
    By Laoguy in forum Chrome Plugins
    Replies: 6
    Last Post: 04-15-2009, 06:52 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •