|
|
I frequently "get to" enter
or
it'd be great to have a user script to do at least one on a toggle basis for the big four search engines |
|
|
For Google this would be easy enough by doing this.. searchString = "-2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008 " if (location.search.indexOf(searchString) == -1) location.search += "&q=" + searchString I don't use the other search engines at all but I imagine something similar should work. |
|
|
|
|
|
Thanks that's great!
.. but it doesn't work for searches initiated from CTRL-K (search bar in toolbar) because it's looking for a button?
f.addEventListener('submit', function(e)
http://www.google.com/search?q=blend+kittens&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-ain addition to CTRL+K support would you also have it remove
&aq=t&rls=org.mozilla:en-US:official&client=firefox-a |
|
|
The whole script seems excessive to me. It really would be much simpler to go with what I said... // ==UserScript== // @name Append String to Google search // @include http://www.google.com/search?q=* // ==/UserScript== searchString = "-2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008 " if (location.search.indexOf(searchString) == -1) location.search += "&q=" + searchString |
|
|
warning: contains some stream of consciousness ... at least I'm conscious @znerp How could his q matching be changed to use
// f.elements.namedItem('q').value += filter;
.... aside: wow, thanks, I never realized until I tried it seconds ago that the google search url could contain TWO &q= and google would build one search string into the search field .... the JoeSimmons userscript relies on getElementsByName and button mashing so I'm left wondering how to integrate your &q=filter append into his function f/e or to append the filter to the existing &q as his does -- keep yours but add toggle apparently it's beyond me (currently) my use of your bits has a tiny iterate infinitely problem http://userscripts.org/scripts/show/41010 |
|
|
I'd have to look at Joe's code to work out your first question, which I may do in a while. With respect to your second question though, it's a small oversight on my part. Change the if-condition to this... if (location.search.indexOf(encodeURI(searchString)) == -1) |
|
|
excellent, thank you! =D [1]
I'm crafting my reply to my other thread, http://userscripts.org/topics/20707 , expanding my understanding of this topic. edit: [2]
|
|
|
I updated mine so that if the script is set to 'on' in the userscript commands, it will append the filter to an existing search meaning you can search from your toolbar. I added the 'xdate' thing; it wont add the filter unless xdate is in the query then it removes 'xdate' and adds the filter. |
|
|
Sorry, I seem to have missed this earlier.
If my understanding of what you want is correct, then you can do this.. if (location.search.indexOf("xdate") > -1)
location.search = location.search.replace("xdate", searchString)
I can't see why that would be the case. |
|
|
> I can't see why that would be the case. http://userscripts.org/scripts/review/41010 submit search via CTRL+K
http://img520.imageshack.us/my.php?image=afterf... There were no results in your selected language(s). Showing worldwide web results for apple -2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008 secondsearch -2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008 thirdsearch -2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008 fourthsearch -2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008. it's merely a curiosity |
|
|
Ok, I see. It seems that google sometimes makes the spaces into searchString = "-2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008 "
if (location.search.indexOf(encodeURI(searchString)) == -1 &&
location.search.indexOf(searchString.replace(/\s/g, '+')) == -1)
location.search += "&q=" + searchString
|
|
|
@JoeSimmons in a temporary, fresh firefox profile, searching google with "xdate clowns" resulted in this in the google search field: x -2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008date clowns |
|
|
@ znerp with your modifications have you tried submitting a search to google and on the resulting page mashing submit a second time changing nothing? |
|
|
(you guys are awesome) |
|
|
with your modifications have you tried submitting a search to google and on the resulting page mashing submit a second time changing nothing? You keep saying mashing but I have no idea what you mean by that. I followed the steps you listed above, and the code I just posted worked fine for that..
|
|
|
No... lol you use xdate after the search term... like "clowns xdate" |
|
|
Any url can contains infinite parameters with the same name, this is because at the beginning the submitted forms generated a different parameter for each input, then to spare space they were joint together and separated with a comma.
|
|
|
@Aquilax I didn't know comma separated url arguments was a standard. Thanks for the tip! |
|
|
@ znerp > You keep saying mashing mash, v.
.
@ JoeSimmons Thanks. Any idea why it does not work as expected with a search intiated from CTRL+K? .
userscript not enabled: search initiated from CTRL+K
.
.
|
|
|
Works fine for me, did you update the script? |