Search code examples
javascriptcross-browsersearch-enginensis

SCRIPT to change default search engine (with or without having to install browser addon)


Goal : Change FF, IE, Chrome, Safari, Default search engine, Homepage and url searchbar

Tools & Scripts : I would like to have a link on the page, that would suggest to make the changes described above. The user has to optin (i don't want aggressive silent install). Ideally without installing a browser addon (but not sure its possible without)

Limitations :

  • I'm aware it's different methods for each browser, but even if you
    have the solution for one, it would be great.

  • I'm also aware that the easiest way is to go through the registry
    using a broswer extension, yet i didn't find the solution for each
    browser, links would be much appreciated.

  • I was suggested also to make these changes through a NSIS installer and i successfully did it, but i would like to know how to do it simply within the broswer extension or ideally from within the page (with a JS or something else).

Thanks a lot in advance, i'm no expert so don't hesitate to go into details as i'm willing to explore all solutions.

PS : i've looked extensively around and there was a lot of topics about manually make these changes, or with an extension for a specific browser, but none about a direct link making these changes.

UPDATE1:

I'm also looking for a complete article about how to change default search engine and homepage WITH an extension for FF, Chrome, IE and Safari. Thanks a lot


Solution

  • For IE:

    You just need to edit the registry

    HKEY_CURRENT_USER "Software\Microsoft\Internet Explorer\Main" "Start Page" 
    HKEY_CURRENT_USER "Software\Microsoft\Internet Explorer\Main" "Default_Search_URL"
    HKEY_CURRENT_USER "Software\Microsoft\Internet Explorer\Main" "Default_Page_URL" "http://abc.com/"
    HKEY_CURRENT_USER "Software\Microsoft\Internet Explorer\SearchScopes\YourSearchEngineName" "DisplayName" "YourSearchEngineName"
    HKEY_CURRENT_USER "Software\Microsoft\Internet Explorer\SearchScopes\YourSearchEngineName" "URL" "YourSearchEngineUrl"
    HKEY_CURRENT_USER "Software\Microsoft\Internet Explorer\SearchScopes" "DefaultScope" "YourSearchEngineName" 
    

    For chrome:

    Find this file:

    "$LOCALAPPDATA\Google\Chrome\User Data\Default\Preferences"
    

    Use nsJson plugin to edit its "homepage" attribute.

    For changing the url search bar (default search) , you need to find some way to edit the sqlite database:

    "$LOCALAPPDATA\Google\Chrome\User Data\Default\Web Data
    

    In this there is a keywords table where you have to add your search engine. And then update it in the meta table of same databse.

    For Firefox:

    Find this file:

     $APPDATA\Mozilla\Profiles\default_profile\prefs.js
    

    Its a javascript file, you can edit its attributes to change the home page and default search.