mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 05:53:41 +00:00
27 lines
660 B
JavaScript
27 lines
660 B
JavaScript
|
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() {
|
||
|
document.querySelector('body').innerHTML = yatteeLink();
|
||
|
}
|
||
|
|
||
|
function redirectAndReplaceContentWithLink(){
|
||
|
redirect()
|
||
|
replaceContentWithLink()
|
||
|
}
|