From 3f0754ab6a7ae0810db3f0f0201a99c194cc5d06 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Tue, 6 Dec 2022 20:36:42 -0500 Subject: fix share button Signed-off-by: Xe Iaso --- src/frontend/mastodon_share_button.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/frontend/mastodon_share_button.tsx b/src/frontend/mastodon_share_button.tsx index d689abd..f2129e7 100644 --- a/src/frontend/mastodon_share_button.tsx +++ b/src/frontend/mastodon_share_button.tsx @@ -5,6 +5,10 @@ r(() => { let defaultURL = localStorage["mastodon_instance"]; + if (defaultURL == undefined) { + defaultURL = ""; + } + const title = document.querySelectorAll('meta[property="og:title"]')[0] .getAttribute("content"); let series = g("mastodon_share_series").innerText; @@ -26,12 +30,17 @@ ${series}${tags.innerText} @cadey@pony.social`; const tootBox = ; const doShare = () => { - const instanceURL = instanceBox.value; + let instanceURL = instanceBox.value; + + if (!instanceURL.startsWith("https://")) { + instanceURL = `https://${instanceURL}`; + } + localStorage["mastodon_instance"] = instanceURL; const text = tootBox.value; - const mastodon_url = u(instanceURL + "/share", { text }); - console.log({ text, mastodon_url }); - window.open(mastodon_url, "_blank"); + const mastodonURL = u(instanceURL + "/share", { text, visibility: "public" }); + console.log({ text, mastodonURL }); + window.open(mastodonURL, "_blank"); }; const shareButton = ; -- cgit v1.2.3