cdnhost 1.5.0 → 1.5.2

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