Change Safari's default search engine

Feb 14, '12 07:30:00AM

Contributed by: Anonymous

This hint describes a way to change one of Safari's built-in search engines (Google/Yahoo/Bing) into a custom one, without the use of any plugins/add-ons/extensions. It involves carefully editing one of Safari's binary (much like the previous hint.)

Go to /System/Library/PrivateFrameworks/Safari.framework/Versions/A/ and save the file named 'Safari' somewhere safe. If something goes wrong while editing, it's just a matter of copying that back (tested myself).

Do the same for this file /Users/USER/Library/Safari/Configurations.plist.signed.

Open 'Configurations.plist.signed' with any text editor and erase everything in it, making it blank. Save it, and then right-click to 'Get Info,' and tick the 'Locked' box.

Now for the binary I recommend a hex editor, I used the free HexFiend.).

Open the /System/Library/PrivateFrameworks/Safari.framework/Versions/A/Safari with your tool of choice. If you search google/yahoo/bing you'll find several strings, I decided to edit the Bing one because It was the one with the least amount of strings to edit, and as my new search engine I choose DuckDuckgo.

Search for:

http://www.bing.com/search?q={searchTerms}&form=APMCS1

And replace with:

https://duckduckgo.com/?q={searchTerms}

Note that you have to replace the old string with one of the same length, otherwise Safari will crash, and since the new one is shorter, add blank spaces to the end. It's a bit easier if using a hex editor.

Search for:

68 74 74 70 3A 2F 2F 77 77 77 2E 62 69 6E 67 2E 63 6F 6D 2F 73 65 61 72 63 68 3F 71 3D 7B 73 65 61 72 63 68 54 65 72 6D 73 7D 26 66 6F 72 6D 3D 41 50 4D 43 53 31
And replace with:
68 74 74 70 73 3A 2F 2F 64 75 63 6B 64 75 63 6B 67 6F 2E 63 6F 6D 2F 3F 71 3D 7B 73 65 61 72 63 68 54 65 72 6D 73 7D 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
I also tried editing the suggestions string to DDG's but It didn't work, Safari wouldn't display the suggestions with the new string, and since I didn't want suggestions from Bing I just blanked out the http://api.bing.com/asjson.aspx?query={searchTerms}&form=APMCS2 string.

Search for:
68 74 74 70 3A 2F 2F 61 70 69 2E 62 69 6E 67 2E 63 6F 6D 2F 61 73 6A 73 6F 6E 2E 61 73 70 78 3F 71 75 65 72 79 3D 7B 73 65 61 72 63 68 54 65 72 6D 73 7D 26 66 6F 72 6D 3D 41 50 4D 43 53 32
And replace with:
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Save It, open Safari.app and select Bing (I wasn't able to change the search bar label, if someone finds a way, please post!), but now instead of Bing, your searches will go to DDG.

[crarko adds: I haven't tested this one. Be certain you have known good backups of any of these files that you edit, and also be aware that the next time the System or Safari is updated, there may be issues.]

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20120213221354176