Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the Default Search Provider on Chrome via a script

I am attempting to set various Google Chrome preferences via a script (on both OS X and Windows). I can successfully set a number of preferences, and add bookmarks, by editing the Preferences and Bookmarks json files in the user's Application Data folder. However, when i attempt to set a new default search provider, the browser automatically reverts to Google search.

The default search provider node in the Preferences file looks like this:

"default_search_provider": {
    "enabled": true,
    "encodings": "UTF-8",
    "icon_url": "http://www.google.com/favicon.ico",
    "id": "2",
    "instant_url": "{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&ie={inputEncoding}&ion=1{searchTerms}&nord=1",
    "keyword": "google.com",
    "name": "Google",
    "prepopulate_id": "1",
    "search_url": "{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}sourceid=chrome&ie={inputEncoding}&q={searchTerms}",
    "suggest_url": "{google:baseSuggestURL}search?client=chrome&hl={language}&q={searchTerms}"
}

In order to add my desired search provider, I've simply added it manually (via the wrench menu), viewed the effect of this action on the json file, and then written a script to mimic these changes. However, when I change it via a script, the default search provider is used for the first search, but then resets the next time chrome is started. What am i missing here?

like image 897
evan Avatar asked Jul 11 '11 22:07

evan


2 Answers

as mentioned, you should edit the 'Web Data' file, which is an sqlite database.

To add a search engine, add an entry to the 'keywords' table.
To change the default search engine, edit the 'Default Search Provider ID' value inside the 'meta' table.

like image 88
Yuval Avatar answered Sep 28 '22 15:09

Yuval


If you want to change the default search provider in Google Chrome you have to modify 'Web Data' file wich is an SQLite file.

On my computer the location where you can find the file is C:\Users\daniel\AppData\Local\Google\Chrome\User Data\Default(Windows7).

See the content of file with SQLite Database Browser; you can find one here.

like image 31
noname Avatar answered Sep 28 '22 15:09

noname