this post was submitted on 04 Jul 2024
14 points (85.0% liked)

Firefox

4032 readers
12 users here now

A community for discussion about Mozilla Firefox.

founded 1 year ago
MODERATORS
 

I want URLs of a page to stay the same no matter where I scroll, including on Discourse where stopping at a certain comment changes the url to that comment's number. Scroll this page to see: https://meta.discourse.org/t/should-url-change-as-you-scroll/55302

top 4 comments
sorted by: hot top controversial new old
[–] pivot_root@lemmy.world 6 points 3 months ago* (last edited 3 months ago) (1 children)
window.history.pushState = () => {}
window.history.replaceState = () => {}

It'll break PWAs unless you stub it out properly, but you can throw that in a userscript for a quick and dirty way to disable the API that websites use to update the URL without reloading the page.

[–] Lemminary@lemmy.world 5 points 3 months ago (1 children)

And SPAs, probably. I can't imagine anything that relies on React Router to work after this change.

[–] pivot_root@lemmy.world 2 points 3 months ago

Definitely not.

If I wasn't on mobile, I would write up a more comprehensive fix. Probably something along the lines of:

  • Store the original functions.
  • Attach a scroll listener to window.
  • Stub the functions when the window is scrolled.
  • Set/reset a timeout for 100ms, and put them back after it fires.
[–] open343@lemmy.zip 1 points 3 months ago

To avoid this problem on Android, I hold down the back button and click on the previous tab.