mirror of
https://github.com/yattee/yattee.git
synced 2025-10-15 11:58:14 +00:00
Basic Safari extension
This commit is contained in:
26
Open in Yattee/content.js
Normal file
26
Open in Yattee/content.js
Normal 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()
|
||||
}
|
Reference in New Issue
Block a user