Allow creation of a custom Search Engine addon with url parameters

[Old Forum eet-fuk] anonymous
Created: 8 years and 5 months ago
At the bottom of the settings page, add an option to save the settings as a custom search engine add on (Open Search XML) instead of the cookies.

Currently there is no way to have the convenience of the search box in the browser AND the url parameters.

This forum has been archived

Thank you all for the many comments, questions and suggestions. Particular thanks go to user x.15a2 for constantly monitoring, replying and helping so many users here. To continue these discussions, please head over to the DuckDuckGo subreddit.


yegg
This sounds good. Note that you can do this now by using the url parameters, which are defined at http://duckduckgo.com/params.html

You just go into your browser's search engine settings and change the search url to reflect the parameters you want.
posted by yegg Staff8 years and 5 months ago Link
anonymous
Yeah I know about the url parameters, but in Firefox once a search engine is added to the search bar, there is no way to change the target url easily.

The workaround is either to modify the search.json file in the profile directory, or to create a fake html page locally linking to a modified opensearch.xml.

You can of course create a bookmark with the url you want and a keyword, but it's not the same thing.

posted by [Old Forum eet-fuk] • 8 years and 5 months ago Link
yegg
I didn't realize that--lame! Yeah, this makes a lot of sense then.
posted by yegg Staff8 years and 5 months ago Link
yegg
There doesn't seem to be a way to do this dynamically. That is, the methods for adding the provider take a URL on a server somewhere. I have the string in client-side memory (JS) and could print out the XML, but I don't see a way to get the browser to take it. Any ideas?
posted by yegg Staff8 years and 1 month ago Link
anonymous
You can not do that with client side JS only, but with a server side script it's fairly easy.

Currently the https://duckduckgo.com/opensearch.xml file is static, but let's say you make a server script that takes the same URL parameters as those of the query page and make a XML file with the right URL in it.

For example, going to the url :
  1. http://duckduckgo.com/dynamic_opensearch.xml&ka=n&kb=d&ke=-1&kf=1&kh=1&kk=-1&kl=wt-wt&kr=1&ks=s&kt=n&kw=w
will generate on the fly the XML file with this content :
  1. <OpenSearchDescription>
  2. <ShortName>Duck Duck Go</ShortName>
  3. <Description>Search Duck Duck Go</Description>
  4. <InputEncoding>UTF-8</InputEncoding>
  5. <LongName>Duck Duck Go Search</LongName>
  6. <Image height="16" width="16" type="image/x-icon">http://duckduckgo.com/favicon.ico</Image>
  7. <Url type="text/html" method="get" template="http://duckduckgo.com/?ka=n&kb=d&ke=-1&kf=1&kh=1&kk=-1&kl=wt-wt&kr=1&ks=s&kt=n&kw=w&q={searchTerms}"/>
  8. </OpenSearchDescription>
Once this script is in place all you have to do is to replace in the page with JavaScript the node :
  1. <link href="opensearch.xml" rel="search" type="application/opensearchdescription+xml" title="Duck Duck Go">
with :
  1. <link href="dynamic_opensearch.xml&ka=n&kb=d&ke=-1&kf=1&kh=1&kk=-1&kl=wt-wt&kr=1&ks=s&kt=n&kw=w" rel="search" type="application/opensearchdescription+xml" title="Duck Duck Go">
And then by using the same "Add to browser" code, the user should be able to add the customized search addon.
posted by [Old Forum eet-fuk] • 8 years and 1 month ago Link
yegg
Gotcha, yes this would work. It's a bit more involved given the way I currently serve dynamic scripts, but makes sense for sure to do.
posted by yegg Staff8 years and 1 month ago Link
anonymous
Hi!

I just starting DuckDuckGo this week and I too wanted to customize the search engine addon. After figuring out the address bar (putting the &q= after the parameter urls in keyword.url) this didn't seem to difficult. But I realize it's a more delicate thing in Firefox than I thought.. I'm not very experienced with Javascript and node's, any explanation about using eet_fuk's idea's would be great!

p.s. I would mostly like to have a Dutch SSL ddg add-on, but having POST and other stuff turned on would be even better.
posted by [Old Forum guest] • 6 years and 10 months ago Link
yegg
posted by yegg Staff6 years and 10 months ago Link