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