Basic Safari extension

This commit is contained in:
Arkadiusz Fal
2021-10-24 14:31:10 +02:00
parent 60c7027429
commit ca8298a9e9
32 changed files with 740 additions and 168 deletions

26
Open in Yattee/content.js Normal file
View File

@@ -0,0 +1,26 @@
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()
}