Rob--W / dont-track-me-google

Firefox and Chrome extensions to prevent Google from making links ugly.
MIT License
459 stars 26 forks source link

Intercept window.open calls, e.g. at maps.google.com #41

Closed Rob--W closed 3 years ago

Rob--W commented 3 years ago

STR:

  1. Open a point of interest on Google Maps, e.g. Kasteel Heeswijk
  2. Click on the website (e.g. kasteelheeswijk.nl).
  3. Notice that a google.com/url?... link is opened.

The link detection/rewriting logic is not triggered because Google Maps uses a button instead of an <a>. Upon clicking the button, window.open is being called, with the following parameters:

window.open(
  "/url?url=https%3A%2F%2Fwww.kasteelheeswijk.nl%2F&sa=t&rct=j&source=maps&usg=...&ved=...",
  "_blank",
  "",
  undefined
);

This could be addressed by intercepting and rewriting window.open calls. But ideally, Google should not use <button> elements, but plain <a>. The use of buttons instead of links prevents users from right-clicking and opening the URL in a new window, for example. That's not a good user experience...

Rob--W commented 3 years ago

In Google docs, I have observed that window.open is sometimes being used for external links. Clicks on links are intercepted and code equivalent to the following is used instead:

w = window.open("", "", "");
w.opener = null;
doc = w.document;
doc.write('<meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0; url=' + escapeHTML(url) + '">');
doc.close();