This completely destroys my browser history. After playing around with this for a bit yesterday, I had to delete literally thousands of browser history entries.
Instead of setting location.href it should use history.replaceState. That way I keep a single history entry that gets updated with the state. Selecting an example could push a new history entry, but all other edit actions shouldn't.