gregsadetsky / chrome-dont-add-custom-search-engines

Google Chrome extension that stops sites from adding custom search engines
https://chrome.google.com/webstore/detail/dont-add-custom-search-en/dnodlcololidkjgbpeoleabmkocdhacc
Other
118 stars 12 forks source link

Work more thoroughly and less destructively #2

Closed ap closed 6 years ago

ap commented 7 years ago

This PR makes the code

  1. … look for all OpenSearch links, not just the first. The reason for making this change should be obvious.

  2. … merely disarm links by removing their type attribute, instead of removing them altogether. The motivation here is that the selector looks for any element with the right type, not just <link rel="search">, but the type attribute can also be added to e.g. <a> tags in the body of the document. You don’t want to remove those.

    My first thought was to just make the selector more, err, selective by adding link[rel="search"] to it. But who knows if Chrome mightn’t start looking at elements other than <link rel="search"> in the future.

    That’s how I came up with this strategy of looking for the attribute everywhere but only removing the attribute rather than the whole DOM node. That seems most likely to be robust against future changes in both HTML and Chrome.

karlicoss commented 6 years ago

Can confirm that works! Although, github shows 'unknown repository' for @ap 's patch, so had to fork and apply it manually, feel free to use https://github.com/karlicoss/chrome-dont-add-custom-search-engines

cxw42 commented 6 years ago

@karlicoss Unfortunately, your fork didn't work for me here. The site doesn't use type="application/opensearchdescription+xml". The entry wasn't added when I visited, but was added after I did a search.

At #6, I have one that works in my early testing. It includes the code in this PR, plus new code based on here kindly linked by @panozzaj here in #1. Would folks be willing to test and let me know how it goes?

I first tried adding a no-op onsubmit handler to any form that didn't have one. However, that didn't solve the problem. I then tried adding an extra <input type=text> to any form that only has one of those, and that seemed to work in some early tests. Unfortunately, this requires sites to ignore the extra query-string parameter. Hopefully most will!

I also merged the other open branches just to clean up the tree, and in hopes that we can get one PR that will work and that @gregsadetsky can merge with minimal effort. Edit This PR is now #6.

Edit Adding a <textarea> seems to work better, since adding an <input> defeated implicit submission on forms without submit buttons - see this.