1(() => { 2 const DEFAULT_KEY = "79eac4c85eb2ae41bb9d370a6aba2533"; 3 const SDK_SRC = "https://t1.kakaocdn.net/kakao_js_sdk/2.7.5/kakao.min.js"; 4 let sdkPromise = null; 5 6 function absoluteUrl(value, fallback) { 7 try { 8 return new URL(value || fallback || location.href, location.origin).href; 9 } catch { 10 return fallback || location.href; 11 } 12 } 13 14 function kakaoKey() { 15 return window.BOGEUM_KAKAO_JS_KEY || DEFAULT_KEY; 16 } 17 18 function loadSdk() { 19 if (window.Kakao) return Promise.resolve(window.Kakao); 20 if (sdkPromise) return sdkPromise; 21 sdkPromise = new Promise((resolve, reject) => { 22 const existing = document.querySelector(`script[src^="${SDK_SRC}"]`); 23 if (existing) existing.remove(); 24 25 const script = document.createElement("script"); 26 const timeout = window.setTimeout(() => { 27 reject(new Error("Kakao SDK load timeout")); 28 }, 8000); 29 30 script.src = SDK_SRC; 31 script.crossOrigin = "anonymous"; 32 script.onload = () => { 33 window.clearTimeout(timeout); 34 resolve(window.Kakao); 35 }; 36 script.onerror = (error) => { 37 window.clearTimeout(timeout); 38 reject(error); 39 }; 40 document.head.appendChild(script); 41 }); 42 return sdkPromise; 43 } 44 45 async function initKakao() { 46 const Kakao = await loadSdk(); 47 if (!Kakao) throw new Error("Kakao SDK is not ready"); 48 if (!Kakao.isInitialized?.()) Kakao.init(kakaoKey()); 49 return Kakao; 50 } 51 52 async function shareWithKakao(payload) { 53 const Kakao = await initKakao(); 54 if (!Kakao.Share?.sendDefault) throw new Error("Kakao Share is not ready"); 55 const link = { 56 mobileWebUrl: payload.url, 57 webUrl: payload.url 58 }; 59 Kakao.Share.sendDefault({ 60 objectType: "feed", 61 content: { 62 title: payload.title, 63 description: payload.text, 64 imageUrl: payload.imageUrl, 65 link 66 }, 67 buttons: [ 68 { 69 title: payload.buttonTitle, 70 link 71 } 72 ], 73 installTalk: true 74 }); 75 return true; 76 } 77 78 async function fallbackShare(payload) { 79 if (navigator.share) { 80 try { 81 await navigator.share({ 82 title: payload.title, 83 text: payload.text, 84 url: payload.url 85 }); 86 return "native"; 87 } catch (error) { 88 if (error?.name === "AbortError") return "cancelled"; 89 } 90 } 91 92 try { 93 await navigator.clipboard.writeText(payload.url); 94 alert("ì¹´ì¹´ì¤í¡ ê³µì ì°½ì ì´ ì ìì´ ê³µì 주ì를 ë³µì¬íìµëë¤."); 95 return "copied"; 96 } catch { 97 window.prompt("ìë ê³µì 주ì를 ë³µì¬í´ 주ì¸ì.", payload.url); 98 return "prompt"; 99 } 100 } 101 102 window.bogeumKakaoShare = async function bogeumKakaoShare(options = {}) { 103 const url = absoluteUrl(options.url, location.href); 104 const payload = { 105 url, 106 title: options.title || document.title || "ë³µìê´ì¥", 107 text: options.text || "", 108 imageUrl: absoluteUrl(options.imageUrl, `${location.origin}/img/og_img.jpg`), 109 buttonTitle: options.buttonTitle || "ë°ë¡ 보기" 110 }; 111 112 try { 113 await shareWithKakao(payload); 114 return true; 115 } catch (error) { 116 console.warn("Kakao share failed; using fallback share.", error); 117 const result = await fallbackShare(payload); 118 return result !== "cancelled"; 119 } 120 }; 121})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.