Google Chrome automatically adding websites to my list of search engines?
This was making me absolutely insane, so I found a hackish, but effective solution to the issue.
Chrome stores it's search engines in a simple sqlite3 database. I found that you can create a trigger when chrome goes to add the search engine that causes the database insert statement to be ignored.
Note that the search engines are still kept in memory, so they will still show up in the list until the browser is restarted. However you wont have to clear them out all the time, and so if you want to add your own search engines, you won't have to worry about accidentally deleting them (yes, manually adding search engines will still work).
First you must locate the Web data
file.
Mac OS X:
~/Library/Application Support/Google/Chrome/Default/Web Data
XP:
C:\Documents and Settings\<username>\Local Settings\Application Data\Google\Chrome\User Data\Default\Web Data
Vista/7:
C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default\Web Data
Linux:
~/.config/google-chrome/Default/Web Data
or~/.config/chromium/Default/Web Data
Then open it with an sqlite3 editor.
Chrome must be shut down at this point.
The official sqlite web site has a download page with a pre-compiled command line utility for the various operating systems. Though any editor capable of working with sqlite3 databases will work.
For the command line utility, use a command such as the following (don't forget to escape or quote the space in the file name):
sqlite3 /path/to/Web\ Data
Add the trigger.
CREATE TRIGGER no_auto_keywords BEFORE INSERT ON keywords WHEN (NEW.originating_url IS NOT NULL AND NEW.originating_url != '') BEGIN SELECT RAISE(IGNORE); END;
You're done. Close the editor and start chrome back up.
The way it works is that when chrome goes to add auto-add a search engine to the keywords
table, chrome sets the originating_url
field to the web site it came from. The trigger basically looks for any inserts with a non-empty originating_url
field, and issues a RAISE(IGNORE)
which causes the statement to be silently skipped.
Manually added search engines don't have an originating_url
, and so the trigger allows them to be added.
Thanks to @10basetom's code and inspired by @shthed, I've released the Don't add custom search engines Chrome extension which does just that.
You'll find the source code here.
Let me know what you think!
There are two ways to do this:
Add this userscript to Tamper Monkey:
var elOpenSearch = document.querySelector('[type="application/opensearchdescription+xml"]'); if (elOpenSearch) elOpenSearch.remove();
If you're not a regular Tamper Monkey user and don't feel like wasting 15-20 MB of RAM just to load the Tamper Monkey extension for this purpose, then you can roll your own super lightweight extension that won't consume any memory. Instructions are provided below.
How to create your own extension to remove the OpenSearch <link>
tag and prevent Chrome from auto-adding search engines:
Create a folder where you will be putting the extension files.
Inside this folder, create two text files named
manifest.json
andcontent.js
containing the code provided below.manifest.json
{ "manifest_version": 2, "name": "Disable OpenSearch", "version": "1.0.0", "description": "Remove the OpenSearch <link> tag to prevent Google Chrome from auto-adding custom search engines.", "content_scripts": [ { "matches": ["<all_urls>"], "js": ["content.js"] } ], "permissions": [ "http://*/*", "https://*/*" ] }
content.js
var elOpenSearch = document.querySelector('[type="application/opensearchdescription+xml"]'); if (elOpenSearch) elOpenSearch.remove();
In Chrome, go to
chrome://extensions/
(enter this into the URL bar).Enable Developer Mode.
Click on 'Load unpacked extension', select the folder you created in step 1, and click 'OK'.
Congratulations! Now Google Chrome should be a little less annoying to use :-).
Limitation: This solution is not 100% reliable. If you go to a URL that contains a search parameter (e.g., https://cdnjs.com/#q=fastclick), then in rare cases a custom search engine will still be added. I suspect this is because Chrome can parse the OpenSearch <link>
tag before the userscript or extension has a chance to remove it from the DOM.