ClearURLs / Addon

ClearURLs is an add-on based on the new WebExtensions technology and will automatically remove tracking elements from URLs to help protect your privacy.
http://docs.clearurls.xyz
GNU Lesser General Public License v3.0
4.06k stars 111 forks source link

History cleaner: consider replacing the state with `null` instead of `{ state: "cleaned_history" }` for better compatibility #196

Closed julienw closed 1 year ago

julienw commented 2 years ago

Hey,

I noticed that the clear urls addons was doing replaceState to replace the history. The problem is that by using some hardcoded state this is breaking websites. Most recently this applied to the Firefox Profiler. Here is a typical example:

  1. Open some profile link, such as https://profiler.firefox.com/public/def4zbt1tyg8w0x7nkdtq8g7s6h3ad0ndz7jbzg/calltree/
  2. Change the panel at the bottom (for example click on "Flame Graph")
  3. Then press the back button;

=> The application crashes.

Indeed when changing the panel (and other actions too), the application does a pushState with the new state, and also changes the URL by serializing part of the state. If you're curious, here is the code responsible for this.

The problem is the application thinks that a proper state is present, and use it, and crashes. By using null instead, the application would use the information contained and serialized in the URL. If you're curious, here is the code responsible for this.

I believe this wasn't happening before, but happens now, because the new "recursive cleaning" will make the URL look different while before they were possibly looking the same.

Now I can find 2 solutions (not exhaustive, both could be used):

  1. as I suggest in the title, I'm not sure why we use this hardcoded state information, and I think that using null would provide the same functionality and less breakage.
  2. do not clean history if the hostname stays the same -- we could probably accept that inside one hostname it's acceptable that websites use the history information.

Thanks

ghost commented 2 years ago

do not clean history if the hostname stays the same -- we could probably accept that inside one hostname it's acceptable that websites use the history information.

That is maybe a solution. I'm having issues as well when History cleaner is enabled at PIPED instances, i.e. https://piped.kavin.rocks/ with the search feature :

Required History API is obviously damaged. Neither of the above mentioned occurs when Prevent tracking injection over history API is unchecked.

evertheylen commented 2 years ago

I am building an app and was getting this issue too. I agree that both solution 1 and 2 are better than the current behaviour. Of course, for my app to work as intended, I'd prefer solution 2.

KevinRoebert commented 1 year ago

Fixed by https://github.com/ClearURLs/Addon/commit/14a0832973e137f0cbbbb1e9110c1286bc88e319