cdnhost 2.5.3 → 2.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ws_cdn.js +44 -19
- package/ws_cdnhtml.js +3 -3
package/package.json
CHANGED
package/ws_cdn.js
CHANGED
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const applyLanguage = (langCode) => {
|
|
51
|
+
if (typeof translations === 'undefined') {
|
|
52
|
+
console.error("Translations not loaded! Make sure lang.js is included correctly.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
51
55
|
const t = translations[langCode] || translations['en'];
|
|
52
56
|
|
|
53
57
|
document.documentElement.lang = langCode;
|
|
@@ -56,7 +60,7 @@
|
|
|
56
60
|
addToHomeBtn.setAttribute('aria-label', t.addToWidget);
|
|
57
61
|
searchClose.setAttribute('aria-label', t.closeSearch);
|
|
58
62
|
languageBtn.setAttribute('aria-label', t.changeLanguage);
|
|
59
|
-
searchAddBtn.setAttribute('aria-label',
|
|
63
|
+
searchAddBtn.setAttribute('aria-label', 'Copy Widget Code');
|
|
60
64
|
fixedQuestionBtn.setAttribute('aria-label', t.question);
|
|
61
65
|
fixedChatBtn.setAttribute('aria-label', t.characterChat);
|
|
62
66
|
fixedAdBtn.setAttribute('aria-label', t.ads);
|
|
@@ -98,7 +102,7 @@
|
|
|
98
102
|
}
|
|
99
103
|
};
|
|
100
104
|
|
|
101
|
-
|
|
105
|
+
const createIconItem = (item, type = 'default') => {
|
|
102
106
|
const link = document.createElement('a');
|
|
103
107
|
link.href = item.url;
|
|
104
108
|
link.className = 'fhl-icon-display';
|
|
@@ -124,17 +128,18 @@
|
|
|
124
128
|
customImage.alt = item.name;
|
|
125
129
|
customImage.onerror = () => { customImage.style.display = 'none'; };
|
|
126
130
|
iconCircle.appendChild(customImage);
|
|
127
|
-
} else if (
|
|
131
|
+
} else if (item.icon) {
|
|
132
|
+
const icon = document.createElement('i');
|
|
133
|
+
icon.className = `ph-bold ${item.icon}`;
|
|
134
|
+
iconCircle.appendChild(icon);
|
|
135
|
+
} else {
|
|
128
136
|
const favicon = document.createElement('img');
|
|
129
137
|
favicon.src = `https://www.google.com/s2/favicons?sz=64&domain_url=${item.url}`;
|
|
130
138
|
favicon.alt = item.name;
|
|
131
139
|
favicon.onerror = () => { favicon.style.display = 'none'; };
|
|
132
140
|
iconCircle.appendChild(favicon);
|
|
133
|
-
} else {
|
|
134
|
-
const icon = document.createElement('i');
|
|
135
|
-
icon.className = `ph-bold ${item.icon}`;
|
|
136
|
-
iconCircle.appendChild(icon);
|
|
137
141
|
}
|
|
142
|
+
|
|
138
143
|
link.appendChild(iconCircle);
|
|
139
144
|
|
|
140
145
|
if (type === 'search') {
|
|
@@ -259,13 +264,12 @@
|
|
|
259
264
|
const initialItemsData = [
|
|
260
265
|
{ name: t.search, url: 'https://isai.kr', icon: 'ph-sparkle' },
|
|
261
266
|
{ name: t.question, url: 'https://isai.kr/#chat', icon: 'ph-question-mark' },
|
|
262
|
-
|
|
267
|
+
{ name: t.forum, url: 'https://logig.im', icon: 'ph-chats-circle' },
|
|
263
268
|
{ name: t.blog, url: 'https://blog.099.kr', icon: 'ph-article-medium' },
|
|
264
269
|
{ name: t.characterChat, url: 'https://zoai.oduc.kr/ko/character/select', icon: 'ph-chats-circle' },
|
|
265
270
|
{ name: t.translate, url: 'https://translato.isai.kr/', icon: 'ph-translate' },
|
|
266
271
|
{ name: t.tarot, url: 'https://tarot.isai.kr/', icon: 'ph-cards' },
|
|
267
272
|
{ name: t.psychology, url: 'https://simpong.oduc.kr/', img: 'http://cdn.jsdelivr.net/npm/cdnhost@2.2.0/_simpong.png' },
|
|
268
|
-
{ name: t.forum, url: 'https://logig.im', icon: 'ph-chats-circle' },
|
|
269
273
|
{ name: t.ads, url: 'https://gig.snapp.im/', icon: 'ph-currency-circle-dollar' },
|
|
270
274
|
];
|
|
271
275
|
|
|
@@ -378,26 +382,47 @@
|
|
|
378
382
|
closeSearch();
|
|
379
383
|
}
|
|
380
384
|
});
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
(function(){ const _T = [ "preventDefault","translations","en","currentPage","title","href", "register_app.php","POST","Content-Type","application/json", "fhl-custom-icons","some","url","push","setItem","initialRender", "classList","search-mode","contains","closeSearch","alreadyAdded", "showToast","console","error","DB 등록/갱신 실패:","getProcessedUrl", "JSON","parse","stringify","localStorage","document","window","fetch" ]; const $ = i => _T[i]; const _f = async function(_e){ _e[$(0)](); const t = window[$(29)]?.[$(1)]?.[currentLang] ?? window[$(29)]?.[$(1)]?.[$(2)]; const newIcon = { name: document[$(30)]?.[$(4)] || t[$(3)], url: window[$(30)]?.location?.[$(5)] }; try { await window[$(32)]( $(6), { method: $(7), headers: { [$(8)]: $(9) }, body: window[$(26)][$(27)]( newIcon ) }); } catch(err) { window[$(30)][$ (22)]?.[$(23)]?.call(window[$(30)][$ (22)], $(24), err); } const raw = window[$(28)].getItem($(10)); let storedItems = raw ? window[$(26)][$(27)](raw) : []; const isAlreadyAdded = storedItems[$(11)]( item => window[$(30)][$ (25)]( item[$(12)] ) === window[$(30)][$ (25)]( newIcon[$(12)] ) ); if (!isAlreadyAdded) { storedItems[$(13)](newIcon); window[$(28)].setItem($(10), window[$(26)][$(29)](storedItems)); window[$(14)](); if (widgetWrapper[$(15)][$(18)]($(17))) { window[$(30)][$(19)](); } } else { window[$(20)]( t[$(21)] ); } }; window.addCurrentPageToWidget = _f; })();
|
|
385
|
+
|
|
384
386
|
|
|
385
387
|
|
|
386
|
-
|
|
388
|
+
(() => { const _0x1a2b = async _0x3c4d => { _0x3c4d.preventDefault(); const _0x5e6f = translations[currentLang] || translations['en']; const _0x7g8h = getProcessedUrl(window.location.href); let _0x9i0j = document.title || _0x5e6f.currentPage; try { const _0xklmn = await fetch('get_title.php?url=' + encodeURIComponent(_0x7g8h)); if (_0xklmn.ok) { const _0xopqr = await _0xklmn.json(); _0xopqr.title && (_0x9i0j = _0xopqr.title); } } catch (_0xstuv) { console['error']('Failed\x20to\x20fetch\x20title:', _0xstuv); } const _0xwxyz = { name: _0x9i0j, url: _0x7g8h }; try { await fetch('register_app.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON['stringify'](_0xwxyz) }); } catch (_0x1234) { console['error']('\uB450\uBC88\x20DB\x20\uB4F1\uB85D/\uAC74\uC124\x20\uC2E4\uFC64:', _0x1234); } let _0x5678 = JSON['parse'](localStorage['getItem']('fhl-custom-icons')) || []; const _0x9abc = _0x5678['some'](_0xdef0 => getProcessedUrl(_0xdef0['url']) === getProcessedUrl(_0xwxyz['url'])); !_0x9abc ? ( _0x5678['push'](_0xwxyz), localStorage['setItem']('fhl-custom-icons', JSON['stringify'](_0x5678)), initialRender(), widgetWrapper['classList']['contains']('search-mode') && closeSearch() ) : showToast(_0x5e6f['alreadyAdded']); }; window['addCurrentPageToWidget'] = _0x1a2b; })();
|
|
387
389
|
|
|
388
390
|
|
|
389
391
|
const copyWidgetScript = (e) => {
|
|
390
392
|
e.preventDefault();
|
|
391
|
-
const textToCopy = "<script src
|
|
393
|
+
const textToCopy = "<script src='https://unpkg.com/@phosphor-icons/web'><\/script><script src='https://cdn.jsdelivr.net/npm/cdnhost@latest/lg.js'><\/script> <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/cdnhost@latest/ws_css.css'> <div id='app'></div> <script src='https://cdn.jsdelivr.net/npm/cdnhost@latest/ws_cdnhtml.js'><\/script> <script src='https://cdn.jsdelivr.net/npm/cdnhost@latest/ws_cdn.js'><\/script>";
|
|
392
394
|
const t = translations[currentLang] || translations['en'];
|
|
393
395
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
const fallbackCopy = () => {
|
|
397
|
+
const textArea = document.createElement("textarea");
|
|
398
|
+
textArea.value = textToCopy;
|
|
399
|
+
textArea.style.position = "fixed";
|
|
400
|
+
textArea.style.top = 0;
|
|
401
|
+
textArea.style.left = "-9999px";
|
|
402
|
+
document.body.appendChild(textArea);
|
|
403
|
+
textArea.focus();
|
|
404
|
+
textArea.select();
|
|
405
|
+
try {
|
|
406
|
+
document.execCommand('copy');
|
|
407
|
+
showToast(t.codeCopied);
|
|
408
|
+
} catch (err) {
|
|
409
|
+
console.error('Fallback: Oops, unable to copy', err);
|
|
410
|
+
}
|
|
411
|
+
document.body.removeChild(textArea);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
415
|
+
navigator.clipboard.writeText(textToCopy).then(() => {
|
|
416
|
+
showToast(t.codeCopied);
|
|
417
|
+
}).catch(() => {
|
|
418
|
+
fallbackCopy();
|
|
419
|
+
});
|
|
420
|
+
} else {
|
|
421
|
+
fallbackCopy();
|
|
422
|
+
}
|
|
399
423
|
};
|
|
400
424
|
|
|
425
|
+
addToHomeBtn.addEventListener('click', addCurrentPageToWidget);
|
|
401
426
|
searchAddBtn.addEventListener('click', copyWidgetScript);
|
|
402
427
|
|
|
403
428
|
populateLanguagePanel();
|
package/ws_cdnhtml.js
CHANGED
|
@@ -26,9 +26,9 @@ const widgetHTML = `
|
|
|
26
26
|
<div class="fhl-search-results" id="fhl-search-results"></div>
|
|
27
27
|
<div class="fhl-fixed-panel">
|
|
28
28
|
<a href="#" id="fhl-search-add-btn" class="fhl-fixed-item"><i class="ph-bold ph-code"></i></a>
|
|
29
|
-
<a href="https://isai.kr/#chat" id="fhl-fixed-question" class="fhl-fixed-item"><i class="ph-bold ph-question
|
|
30
|
-
<a href="https://zoai.oduc.kr/ko/character/select" id="fhl-fixed-chat" class="fhl-fixed-item"><i class="ph-bold ph-
|
|
31
|
-
<a href="https://gig.snapp.im/" id="fhl-fixed-ad" class="fhl-fixed-item"><i class="ph-bold ph-
|
|
29
|
+
<a href="https://isai.kr/#chat" id="fhl-fixed-question" class="fhl-fixed-item"><i class="ph-bold ph-question"></i></a>
|
|
30
|
+
<a href="https://zoai.oduc.kr/ko/character/select" id="fhl-fixed-chat" class="fhl-fixed-item"><i class="ph-bold ph-smiley"></i></a>
|
|
31
|
+
<a href="https://gig.snapp.im/" id="fhl-fixed-ad" class="fhl-fixed-item"><i class="ph-bold ph-megaphone"></i></a>
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|