Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcelleblass/85bc5d9bfb78fb738c6886ee0578619b to your computer and use it in GitHub Desktop.
Save marcelleblass/85bc5d9bfb78fb738c6886ee0578619b 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();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment