From 5fc920f42153a018dbcbee162bba59fe690d7ab9 Mon Sep 17 00:00:00 2001 From: junglesub Date: Sat, 2 Nov 2024 02:56:09 +0900 Subject: [PATCH 1/2] feat(client): inapp browser bypass --- src/main/front/index.html | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/main/front/index.html b/src/main/front/index.html index cc7c88d..48abb57 100644 --- a/src/main/front/index.html +++ b/src/main/front/index.html @@ -24,6 +24,50 @@ ); } }, 3000); + + // In-app 브라우저 Bypass + var inappdeny_exec_vanillajs = (callback) => { + if (document.readyState !== "loading") { + callback(); + } else { + document.addEventListener("DOMContentLoaded", callback); + } + }; + inappdeny_exec_vanillajs(() => { + /* Do things after DOM has fully loaded */ + function copytoclipboard(val) { + var t = document.createElement("textarea"); + document.body.appendChild(t); + t.value = val; + t.select(); + document.execCommand("copy"); + document.body.removeChild(t); + } + function inappbrowserout() { + copytoclipboard(window.location.href); + alert( + 'URL주소가 복사되었습니다.\n\nSafari가 열리면 주소창을 길게 터치한 뒤, "붙여놓기 및 이동"를 누르면 정상적으로 이용하실 수 있습니다.' + ); + location.href = "x-web-search://?"; + } + + var useragt = navigator.userAgent.toLowerCase(); + var target_url = location.href; + + if (useragt.match(/kakaotalk/i)) { + //카카오톡 외부브라우저로 호출 + location.href = + "kakaotalk://web/openExternal?url=" + + encodeURIComponent(target_url); + } else if (useragt.match(/line/i)) { + //라인 외부브라우저로 호출 + if (target_url.indexOf("?") !== -1) { + location.href = target_url + "&openExternalBrowser=1"; + } else { + location.href = target_url + "?openExternalBrowser=1"; + } + } + }); From bdcc0acaabb6318eaed0ab20c05cb64b1d6c53c4 Mon Sep 17 00:00:00 2001 From: junglesub Date: Sat, 2 Nov 2024 03:15:30 +0900 Subject: [PATCH 2/2] feat(client): limit text share --- .../front/src/components/modals/ShareModal.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/front/src/components/modals/ShareModal.jsx b/src/main/front/src/components/modals/ShareModal.jsx index 48dfe46..00cf26d 100644 --- a/src/main/front/src/components/modals/ShareModal.jsx +++ b/src/main/front/src/components/modals/ShareModal.jsx @@ -44,9 +44,8 @@ const ShareModal = ({ openState, item }) => { if (navigator.share) { navigator .share({ - title: "한동피드 공유하기", + title: "한동피드", text: shareText, - url: shareLink, }) .then(() => { setSnackbarMessage("공유 성공!"); @@ -69,10 +68,17 @@ const ShareModal = ({ openState, item }) => { handleClose(); }; - if (!shareHash) return <>; + if (!shareHash || !item?.content) return <>; const shareLink = `${window.location.origin}/k/${shareHash.shortHash}`; - const shareText = `${item?.content}`; + const prefix = `[한동피드]\n`; + const suffix = `\n\n[한동피드] ${shareLink}`; + const prefixSuffixLen = prefix.length + suffix.length; + const shareText = `${ + item.content.length + prefixSuffixLen > 430 + ? item.content.substr(0, 430) + "(...한동피드에서 더보기)" + : item.content + }${suffix}`; return ( <> @@ -106,7 +112,7 @@ const ShareModal = ({ openState, item }) => {