17 lines
No EOL
581 B
JavaScript
17 lines
No EOL
581 B
JavaScript
document.addEventListener('DOMContentLoaded', (event) => {
|
|
if (localStorage['mastodon_share_url']) {
|
|
dgel('share-instance').value = localStorage['mastodon_share_url'];
|
|
}
|
|
});
|
|
|
|
function share_with_mastodon() {
|
|
let url = "https://" + dgel('share-instance').value;
|
|
url = url.replace(/^https:\/\/(https?:\/\/)/, "$1"); // remove duplicated leading 'https://' if present
|
|
url = url.replace(/\/+$/, ''); // remove trailing slashes
|
|
|
|
post_content = window.location.hash.substr(1);
|
|
|
|
localStorage['mastodon_share_url'] = url;
|
|
|
|
window.location = `${url}/share?text=${post_content}`;
|
|
} |