Skip to content

Instantly share code, notes, and snippets.

@hobelinm
Last active March 14, 2018 05:39
Show Gist options
  • Save hobelinm/15a5605444c402a674230c96cfe5e77e to your computer and use it in GitHub Desktop.
Save hobelinm/15a5605444c402a674230c96cfe5e77e to your computer and use it in GitHub Desktop.
0.1 Version
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous">
</script>
<script>
if(localStorage.getItem('IsDebug') === 'true') {
console.log('Debug mode, no redirection');
return;
}
let langs = ['en-US', 'es-MX'];
let aRefs = $('a[href^="https://blog.hugobelin.com/search/label/"]');
let lang = 'en-US';
for(let i = 0; i < aRefs.length; i++) {
let aTag = aRefs[i];
if(langs.include(aTag.innerHTML)) {
lang = aTag.innerHTML;
}
}
console.log(window.location.href);
if(window.self === window.top) {
console.log('Redirecting to:');
let destination = 'https://hugobelin.com/#post:' + lang + ':' + window.location.pathname;
console.log(destination);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment