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

Remove also oncontextmenu attribute #17

Closed csagan5 closed 6 years ago

csagan5 commented 6 years ago

Google search results' hyperlinks also contain now the oncontextmenu attribute, calling some internal JS function.

By the way, I have successful integrated your contentscript.js in Bromite and it will be released in next version.

Rob--W commented 6 years ago

When I view the source of https://encrypted.google.com/search?q=test (with view-source / with the devtools), I don't see the contextmenu (in Chrome / Firefox). How can I get the "oncontextmenu" attribute to appear?

csagan5 commented 6 years ago

@Rob--W I see it on mobile, but on an actual Chrome/Chromium/Bromite via adb dev tools remote inspection

csagan5 commented 6 years ago

I ended up using a simplified version of your content script and I am adding AMP search results removal too; I'll publish that part of the patch as soon as it builds successfully and it's tested.

Rob--W commented 6 years ago

Thanks for the patch and instructions.

When I use desktop Chrome browser and emulate the "Nexus 6P" in the device toolbar, with JS enabled, then I see the following when I search for "example.com":

<a
  href="http://www.example.com/"
  ping="/url?...&url=http://www.example.com/&..."
  oncontextmenu="google.ctpacw.cm(this)">

And google.ctpacw.cm is:

function (a) {
  a.ping && (a.href = a.ping, a.removeAttribute("ping"))
}

The oncontextmenu handler indeed attempts to rewrite the href of the link. However your patch does not prevent that from happening because removeAttribute('oncontextmenu') is only called when an onmousedown attribute is present (and this is not the case).

The code (at Google) shows to me that my extension is working as intended, because I intercept the attempt to set the href and assign the actual URL instead:

https://github.com/Rob--W/dont-track-me-google/blob/81aad59b86264491754bf05ebf4b51e0867a0377/contentscript.js#L142-L160