Created
January 23, 2021 01:34
-
-
Save faurehu/66e232e3110412b0c5efbc4b74310bb6 to your computer and use it in GitHub Desktop.
Roam Alias Plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onhashchange = function () { | |
var isPage = window.location.hash.split('/')[3] == 'page' | |
if (isPage) { | |
setTimeout(function () { | |
var topBlock = document.getElementsByClassName("roam-block")[0].children[0] | |
var blockValue = topBlock.innerText.split(':') | |
if (blockValue.length == 2 && blockValue[0] == 'forward') { | |
var attrs = topBlock.children[1].attributes[1] | |
if (attrs.name == 'data-link-uid') { | |
var newUrl = window.location.href.slice(0, -9) + attrs.value | |
window.location.assign(newUrl) | |
} | |
} | |
}, 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment