cdnhost 1.5.2 → 1.5.4
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.
|
@@ -13,9 +13,14 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
|
13
13
|
div.style.background = '#000';
|
|
14
14
|
div.innerHTML = '';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
fetch('https://ipapi.co/json/')
|
|
17
|
+
.then(res => res.json())
|
|
18
|
+
.then(data => {
|
|
19
|
+
const ip = data.ip;
|
|
20
|
+
const region = data.region || '';
|
|
21
|
+
return fetch(`https://gig.snapp.im/banner_api.php?user=${encodeURIComponent(userId)}&country=ko&ip=${ip}®ion=${encodeURIComponent(region)}`);
|
|
22
|
+
})
|
|
23
|
+
|
|
19
24
|
.then(res => res.json())
|
|
20
25
|
.then(data => {
|
|
21
26
|
const hasImage = data.image && data.image.trim() !== '';
|
|
@@ -44,7 +49,6 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
|
44
49
|
textDiv.style.height = '600px';
|
|
45
50
|
textDiv.style.display = 'flex';
|
|
46
51
|
textDiv.style.flexDirection = 'column';
|
|
47
|
-
textDiv.style.justifyContent = 'center';
|
|
48
52
|
textDiv.style.setProperty('color', '#fff', 'important');
|
|
49
53
|
textDiv.style.setProperty('line-height', '1.4', 'important');
|
|
50
54
|
|
|
@@ -168,5 +172,4 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
|
168
172
|
.catch(err => {
|
|
169
173
|
console.error('배너 로드 실패:', err);
|
|
170
174
|
});
|
|
171
|
-
}
|
|
172
|
-
|
|
175
|
+
}
|
package/cdnbanner.js
CHANGED
package/package.json
CHANGED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
2
|
-
const div = document.getElementById(divId);
|
|
3
|
-
if (!div) {
|
|
4
|
-
console.error(`Element with id="${divId}" not found.`);
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
div.style.height = (typeof height === 'number' ? height + 'px' : height);
|
|
9
|
-
div.style.width = (typeof width === 'number' ? width + 'px' : width);
|
|
10
|
-
div.style.background = '#000';
|
|
11
|
-
div.innerHTML = '';
|
|
12
|
-
|
|
13
|
-
fetch('https://api.ipify.org?format=json')
|
|
14
|
-
.then(res => res.json())
|
|
15
|
-
.then(data => fetch(`https://gig.snapp.im/banner_test.php?user=${encodeURIComponent(userId)}&country=ko&ip=${data.ip}`))
|
|
16
|
-
.then(res => res.json())
|
|
17
|
-
.then(data => {
|
|
18
|
-
const banner = document.createElement('a');
|
|
19
|
-
banner.href = `https://gig.snapp.im/banner2.php?link=${encodeURIComponent(data.link)}&user=${encodeURIComponent(userId)}&country=ko`;
|
|
20
|
-
banner.target = "_blank";
|
|
21
|
-
banner.style.background = '#000';
|
|
22
|
-
banner.style.color = '#fff';
|
|
23
|
-
banner.style.textDecoration = 'none';
|
|
24
|
-
banner.style.display = 'flex';
|
|
25
|
-
banner.style.overflow = 'hidden';
|
|
26
|
-
banner.style.position = 'relative'; // ← 고정 아이콘을 위한 기준
|
|
27
|
-
|
|
28
|
-
const imgWidth = 300;
|
|
29
|
-
const imgHeight = 250;
|
|
30
|
-
|
|
31
|
-
const imageDiv = document.createElement('div');
|
|
32
|
-
imageDiv.style.backgroundImage = `url('${data.image}')`;
|
|
33
|
-
imageDiv.style.backgroundSize = 'cover';
|
|
34
|
-
imageDiv.style.backgroundPosition = 'center';
|
|
35
|
-
imageDiv.style.flexShrink = '0';
|
|
36
|
-
|
|
37
|
-
const textDiv = document.createElement('div');
|
|
38
|
-
textDiv.style.color = '#fff';
|
|
39
|
-
textDiv.style.boxSizing = 'border-box';
|
|
40
|
-
textDiv.style.padding = '10px';
|
|
41
|
-
textDiv.style.overflow = 'hidden';
|
|
42
|
-
|
|
43
|
-
const title = document.createElement('h3');
|
|
44
|
-
title.textContent = data.title;
|
|
45
|
-
title.style.margin = '0 0 10px 0';
|
|
46
|
-
|
|
47
|
-
const desc = document.createElement('p');
|
|
48
|
-
desc.textContent = data.desc;
|
|
49
|
-
desc.style.margin = '0';
|
|
50
|
-
|
|
51
|
-
textDiv.appendChild(title);
|
|
52
|
-
textDiv.appendChild(desc);
|
|
53
|
-
|
|
54
|
-
const widthNum = typeof width === 'number' ? width : null;
|
|
55
|
-
const isFullWidth = width.toString() === '100%';
|
|
56
|
-
|
|
57
|
-
if (widthNum === imgWidth && height === imgHeight) {
|
|
58
|
-
banner.style.width = imgWidth + 'px';
|
|
59
|
-
banner.style.height = imgHeight + 'px';
|
|
60
|
-
banner.style.flexDirection = 'column';
|
|
61
|
-
imageDiv.style.width = imgWidth + 'px';
|
|
62
|
-
imageDiv.style.height = imgHeight + 'px';
|
|
63
|
-
|
|
64
|
-
banner.appendChild(imageDiv);
|
|
65
|
-
|
|
66
|
-
} else if (isFullWidth) {
|
|
67
|
-
banner.style.width = '100%';
|
|
68
|
-
banner.style.height = imgHeight + 'px';
|
|
69
|
-
banner.style.flexDirection = 'row';
|
|
70
|
-
|
|
71
|
-
imageDiv.style.width = imgWidth + 'px';
|
|
72
|
-
imageDiv.style.height = imgHeight + 'px';
|
|
73
|
-
|
|
74
|
-
textDiv.style.flexGrow = '1';
|
|
75
|
-
textDiv.style.height = imgHeight + 'px';
|
|
76
|
-
textDiv.style.display = 'flex';
|
|
77
|
-
textDiv.style.flexDirection = 'column';
|
|
78
|
-
textDiv.style.justifyContent = 'center';
|
|
79
|
-
|
|
80
|
-
banner.appendChild(imageDiv);
|
|
81
|
-
banner.appendChild(textDiv);
|
|
82
|
-
|
|
83
|
-
} else if (widthNum !== null && widthNum > imgWidth) {
|
|
84
|
-
const extraWidth = widthNum - imgWidth;
|
|
85
|
-
banner.style.width = widthNum + 'px';
|
|
86
|
-
banner.style.height = imgHeight + 'px';
|
|
87
|
-
banner.style.flexDirection = 'row';
|
|
88
|
-
|
|
89
|
-
imageDiv.style.width = imgWidth + 'px';
|
|
90
|
-
imageDiv.style.height = imgHeight + 'px';
|
|
91
|
-
|
|
92
|
-
textDiv.style.width = extraWidth + 'px';
|
|
93
|
-
textDiv.style.height = imgHeight + 'px';
|
|
94
|
-
textDiv.style.display = 'flex';
|
|
95
|
-
textDiv.style.flexDirection = 'column';
|
|
96
|
-
textDiv.style.justifyContent = 'center';
|
|
97
|
-
|
|
98
|
-
banner.appendChild(imageDiv);
|
|
99
|
-
banner.appendChild(textDiv);
|
|
100
|
-
|
|
101
|
-
} else if (typeof height === 'number' && height > imgHeight) {
|
|
102
|
-
const extraHeight = height - imgHeight;
|
|
103
|
-
banner.style.width = imgWidth + 'px';
|
|
104
|
-
banner.style.height = height + 'px';
|
|
105
|
-
banner.style.flexDirection = 'column';
|
|
106
|
-
|
|
107
|
-
imageDiv.style.width = imgWidth + 'px';
|
|
108
|
-
imageDiv.style.height = imgHeight + 'px';
|
|
109
|
-
|
|
110
|
-
textDiv.style.width = imgWidth + 'px';
|
|
111
|
-
textDiv.style.height = extraHeight + 'px';
|
|
112
|
-
|
|
113
|
-
banner.appendChild(imageDiv);
|
|
114
|
-
banner.appendChild(textDiv);
|
|
115
|
-
} else {
|
|
116
|
-
banner.style.width = (typeof width === 'number' ? width + 'px' : width);
|
|
117
|
-
banner.style.height = (typeof height === 'number' ? height + 'px' : height);
|
|
118
|
-
banner.style.flexDirection = 'column';
|
|
119
|
-
|
|
120
|
-
imageDiv.style.width = (typeof width === 'number' ? width + 'px' : width);
|
|
121
|
-
imageDiv.style.height = (typeof height === 'number' ? height + 'px' : height);
|
|
122
|
-
|
|
123
|
-
banner.appendChild(imageDiv);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// 추가된 고정 아이콘 (우측 상단)
|
|
127
|
-
const fixedIcon = document.createElement('a');
|
|
128
|
-
fixedIcon.href = 'https://gig.snapp.im/';
|
|
129
|
-
fixedIcon.target = '_blank';
|
|
130
|
-
fixedIcon.style.position = 'absolute';
|
|
131
|
-
fixedIcon.style.top = '5px';
|
|
132
|
-
fixedIcon.style.right = '5px';
|
|
133
|
-
fixedIcon.style.width = '30px';
|
|
134
|
-
fixedIcon.style.zIndex = '10';
|
|
135
|
-
|
|
136
|
-
const fixedImg = document.createElement('img');
|
|
137
|
-
fixedImg.src = 'https://cdn.jsdelivr.net/npm/cdnhost@0.1.4/l2.png';
|
|
138
|
-
fixedImg.alt = 'a';
|
|
139
|
-
fixedImg.style.width = '100%';
|
|
140
|
-
|
|
141
|
-
fixedIcon.appendChild(fixedImg);
|
|
142
|
-
banner.appendChild(fixedIcon);
|
|
143
|
-
|
|
144
|
-
div.appendChild(banner);
|
|
145
|
-
})
|
|
146
|
-
.catch(err => {
|
|
147
|
-
console.error('배너 로드 실패:', err);
|
|
148
|
-
});
|
|
149
|
-
}
|