Skip to content

Instantly share code, notes, and snippets.

@azu
Created December 2, 2015 15:05
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save azu/36ba5a80feb857c77a3a to your computer and use it in GitHub Desktop.
Save azu/36ba5a80feb857c77a3a to your computer and use it in GitHub Desktop.
Medium: remove location hash
// ==UserScript==
// @name Medium: remove location hash
// @namespace http://efcl.info/
// @description Remove location hash from medium
// @include https://medium.com/*#*
// @version 1
// @grant none
// ==/UserScript==
function removeLocationHash(){
var noHashURL = window.location.href.replace(/#.*$/, '');
window.history.replaceState('', document.title, noHashURL)
}
window.addEventListener("popstate", function(event){
removeLocationHash();
});
window.addEventListener("hashchange", function(event){
event.preventDefault();
removeLocationHash();
});
window.addEventListener("load", function(){
removeLocationHash();
});
@nexispl
Copy link

nexispl commented May 3, 2019

nice!

@PinalVaghasiya
Copy link

PinalVaghasiya commented Jun 17, 2019

Great!

@besstilahun
Copy link

awesome!

@diego1campos
Copy link

Gorgeously great!!

@nikitekirsha
Copy link

thank you a lot

@marcelleblass
Copy link

Just great, exactly what I needed!

@manoelvitorsilvasantos
Copy link

boa

@manoelvitorsilvasantos
Copy link

Me ajudou muito a resolver o problema que eu estava tendo com o modal.

Help me much....one fixed the problem that was had with modal. Thanks Very much.

@caub
Copy link

caub commented May 2, 2021

history.replaceState('', document.title, location.pathname+location.search);

@tomdapchai
Copy link

omg thanks a lottt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment