yattee/Open in Yattee/content.js

27 lines
679 B
JavaScript
Raw Normal View History

2021-10-24 12:31:10 +00:00
if (document.readyState !== 'complete') {
window.addEventListener('load', redirectAndReplaceContentWithLink);
} else {
redirectAndReplaceContentWithLink();
}
function yatteeUrl() {
return window.location.href.replace(/^https?:\/\//, 'yattee://');
}
function yatteeLink() {
return '<a href="'+ yatteeUrl() +'" onclick=\'window.location.href="'+ yatteeUrl() +'"\'>Open in Yattee</a>';
}
function redirect() {
window.location.href = yatteeUrl()
}
function replaceContentWithLink() {
2021-11-07 16:52:42 +00:00
document.querySelector('body').innerHTML = '<h1>' + yatteeLink() + '</h1>';
2021-10-24 12:31:10 +00:00
}
function redirectAndReplaceContentWithLink(){
redirect()
replaceContentWithLink()
}