apiraino / link_cleaner

A Firefox extension to clean urls from tracking and advertisement parameters
82 stars 10 forks source link

Clean Google search result links, such that search results link directly to their targets #26

Closed openjck closed 3 years ago

openjck commented 4 years ago

Steps to reproduce

  1. Visit google.com
  2. Enter the search term example
  3. Click the first result

Expected result

Firefox navigates directly to the domain of the first result, which is currently merriam-webster.com

Actual result

Firefox navigates to google.com/url, which redirects the user to meriam-webster.com after presumably tracking the click

openjck commented 4 years ago

I'm currently using an add-on called Google search link fix to do this, but it'd be nice if Link Cleaner+ took care of it, so that I'd have one less add-on.

ghost commented 4 years ago

We do account for Google URLs already https://github.com/apiraino/link_cleaner/blob/bbdab6eead1616e645e0bcaac85231c073ac8f01/background.js#L233-L241 . If you could provide the specific URL you think is not being link-cleaned that would be very helpful.

ghost commented 4 years ago

Oh, if you're copying links then you should be using the "Copy clean link" button when you right click, not "copy link location". Firefox does not allow us to override the default "copy link location" button, for better or for worse.

openjck commented 4 years ago

Oh, if you're copying links then you should be using the "Copy clean link" button when you right click, not "copy link location". Firefox does not allow us to override the default "copy link location" button, for better or for worse.

Oh, thanks! I hadn't noticed that menu item before. For whatever it's worth, the Google Search link fix add-on does add the clean version of the link to the clipboard when the Copy Link Location menu item is used. They must be doing something different. Perhaps they're manipulating the DOM.

In any case, I should have been more clear. The issue isn't with the Copy Link Location menu item itself, but rather that Google links don't seem to be cleaned at all. (Please correct me if I'm wrong.) Take a look at the screencast below, which seems to show that after clicking a result, I navigate to google.com/url, rather than to the target directly.

https://imgur.com/a/ONSHONU

apiraino commented 4 years ago

Hi @openjck, like @Riamse points out the extension should work as expected (in this case nothing to do as the link you click does not need to be cleaned).

The additional queries you see in your network traffic are a different story. These are asynchronous requests that the google javascript triggers. The fact that you see them after you click the link is purely coincidental: if you wait a bit more before clicking or if you go back to google.com you should see these requests being triggered anyway. I've searched a bit around but couldn't figure out the purpose of these requests, I usually keep js disabled on google domains (unless necessary).

Feel fee to close this issue if this answer your doubts.

openjck commented 3 years ago

I don't mean to be a bother, but I'm not sure that's correct. I know that Google does some async requests after a search is performed, but if I wait for those to finish, clear the network log, wait several seconds, and then click the link, the first request is a GET to google.com/url. I'll try to put together another screencast for you.

openjck commented 3 years ago

Here's a screencast demonstrating the point of my last comment. You can see that after the async requests complete, I wait for about 10-15 seconds. (During this time, I highlight some text just to make it clear that the video is not frozen.) During those 10-15 seconds, no new async requests are made. After the 10-15 seconds, I click the link, and the first network request is a GET to google.com/url. Firefox is not navigating directly to the meriam-webster.com domain as I would expect.

(When the Google Search link fix add-on is enabled, Firefox does navigate directly to meriam-webster.com.)

apiraino commented 3 years ago

No worries!

So, at a closer look I observe an interesting behaviour, see the following (sorry for the poor quality, i'm pasting here so it won't be lost on third-party image hosting).

Test 1:

Test 2:

recording

Tested on Linux on FF 81.0b9 (64-Bit). On Chromium this trick doesn't work.

I'll investigate what's going on :thinking:

vidschofelix commented 3 years ago

Google replaces the href on mousedown...

grafik

The rwt() rewrites the link.

For testing do a left klick on a link, it changes to the tracking-link.

apiraino commented 3 years ago

thanks @vidschofelix for the hint.

In order to implement this, this extension would need to do what the other extension does: adding listeners to JavaScript events.

As end user, I'd like "Link Cleaner+" to manage these cases, as maintainer I feel it is a bit "out of scope". There are many extensions doing a good job at controlling scripts in the browser, would it make sense to partially duplicate their efforts? :thinking:

I'm sure there are many websites that trick and deceive users this way. However handling this single case would open the gates to supporting them, too.

I think I'll close this issue for the moment, but I'm happy to receive other opinions.