-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEcosystemPuller.html
More file actions
325 lines (283 loc) · 11.9 KB
/
EcosystemPuller.html
File metadata and controls
325 lines (283 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Secret Network Ecosystem Puller</title>
</head>
<body>
<div class="input-container">
<textarea id="htmlInput" placeholder="Paste HTML content here..."></textarea>
<button onclick="processHTML()">Process HTML</button>
<div class="function-bar">
<select id="categoryFilter" onchange="filterByCategory(this.value)">
<option value="all">All Categories</option>
</select>
<button onclick="downloadCSV()">Download CSV</button>
</div>
</div>
<div id="results"></div>
<script>
let allDapps = []; // Store all dApps for filtering
function processHTML() {
const htmlContent = document.getElementById('htmlInput').value;
if (!htmlContent) {
alert('Please paste some HTML content first');
return;
}
try {
const parser = new DOMParser();
const doc = parser.parseFromString(htmlContent, 'text/html');
const dAppElements = doc.querySelectorAll('a.elementor-element.e-flex.e-con-boxed');
allDapps = []; // Reset the array
const uniqueCategories = new Set(['all']); // For category filter
dAppElements.forEach(dApp => {
const name = dApp.querySelector('.elementor-heading-title')?.textContent.trim();
const description = dApp.querySelector('.elementor-widget-theme-post-content p')?.textContent.trim();
const imgElement = dApp.querySelector('img');
let imageUrl = imgElement?.getAttribute('src');
if (imageUrl?.startsWith('data:image')) {
imageUrl = imgElement.getAttribute('data-src') ||
imgElement.getAttribute('srcset')?.split(' ')[0] ||
imgElement.getAttribute('data-srcset')?.split(' ')[0];
}
const link = dApp.getAttribute('href');
const categories = [];
const categorySpans = dApp.querySelectorAll('.elementor-post-info__terms-list-item');
categorySpans.forEach(span => {
const category = span.textContent.trim();
categories.push(category);
uniqueCategories.add(category);
});
if (name) {
allDapps.push({
name,
description,
categories,
imageUrl,
link
});
}
});
// Update category filter options
updateCategoryFilter(Array.from(uniqueCategories));
// Display results
displayResults(allDapps);
console.log(JSON.stringify(allDapps, null, 2));
} catch (error) {
console.error('Error processing HTML:', error);
document.getElementById('results').innerHTML = `<p>Error processing HTML: ${error.message}</p>`;
}
}
function updateCategoryFilter(categories) {
const select = document.getElementById('categoryFilter');
select.innerHTML = categories.map(cat =>
`<option value="${cat}">${cat === 'all' ? 'All Categories' : cat}</option>`
).join('');
}
function filterByCategory(category) {
const filteredDapps = category === 'all'
? allDapps
: allDapps.filter(dApp => dApp.categories.includes(category));
displayResults(filteredDapps);
}
function displayResults(dApps) {
const resultsDiv = document.getElementById('results');
let html = '<div class="dapps-grid">';
dApps.forEach(dApp => {
html += `
<div class="dapp-card">
<div class="dapp-image">
${dApp.imageUrl ? `<img src="${dApp.imageUrl}" alt="${dApp.name}">` : ''}
</div>
<div class="dapp-tags">
${dApp.categories.map(cat => `<span class="tag">${cat}</span>`).join('')}
</div>
<div class="dapp-content">
<h3>${dApp.name}</h3>
<p>${dApp.description || 'No description available'}</p>
</div>
<a href="${dApp.link}" target="_blank" class="dapp-link"></a>
</div>
`;
});
html += '</div>';
resultsDiv.innerHTML = html;
}
function downloadCSV() {
if (allDapps.length === 0) {
alert('Please process some data first');
return;
}
// Create CSV headers exactly matching Framer's fields
let csv = 'Name,Category,Description,Logo,Link,Slug\n';
// Add data rows
allDapps.forEach(dApp => {
// Create slug (lowercase and hyphenated)
const slug = dApp.name.toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^a-z0-9-]/g, '');
// Join categories with semicolon separator instead of pipe
const categoriesString = dApp.categories
.map(cat => cat.toLowerCase())
.join(',');
// Escape fields that might contain commas and clean up any potential issues
const escapedName = `"${dApp.name.replace(/"/g, '""').trim()}"`;
const escapedCategories = `"${categoriesString.replace(/"/g, '""').trim()}"`;
const escapedDescription = `"${(dApp.description || '').replace(/"/g, '""').trim()}"`;
const escapedImageUrl = `"${(dApp.imageUrl || '').trim()}"`;
const escapedLink = `"${dApp.link.trim()}"`;
const escapedSlug = `"${slug}"`;
csv += `${escapedName},${escapedCategories},${escapedDescription},${escapedImageUrl},${escapedLink},${escapedSlug}\n`;
});
// Create and trigger download
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.setAttribute('href', url);
link.setAttribute('download', 'secret_network.csv');
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
const styles = `
<style>
@import url('https://fonts.cdnfonts.com/css/sf-pro-display');
body {
margin: 0;
padding: 20px;
background: #0a0a0a;
font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}
.input-container {
margin-bottom: 20px;
display: flex;
flex-direction: column;
gap: 10px;
padding-right: 20px;
padding-top: 20px;
}
textarea {
width: 100%;
height: 200px;
padding: 10px;
border: 1px solid #333;
border-radius: 5px;
font-family: monospace;
background: #1c1c1c;
color: white;
box-sizing: border-box;
}
button, select {
padding: 10px 20px;
background: #007aff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
white-space: nowrap;
}
select {
background: #1c1c1c;
width: 200px;
border: 1px solid #333;
}
button:hover {
background: #0056b3;
}
.function-bar {
display: flex;
gap: 10px;
padding: 10px 0;
align-items: center;
}
.dapps-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 15px;
}
.dapp-card {
background: #000000;
border-radius: 12px;
overflow: hidden;
position: relative;
color: white;
transition: transform 0.2s;
height: 280px;
border: 1px solid #333;
}
.dapp-card:hover {
transform: translateY(-3px);
border-color: #444;
}
.dapp-image {
width: 100%;
height: 100px;
overflow: hidden;
background: #1c1c1c;
}
.dapp-image img {
width: 100%;
height: 100%;
object-fit: cover;
}
.dapp-tags {
position: absolute;
top: 6px;
left: 6px;
display: flex;
gap: 3px;
flex-wrap: wrap;
max-width: calc(100% - 12px);
}
.tag {
background: rgba(0, 0, 0, 0.8);
color: #ffffff;
padding: 3px 6px;
border-radius: 4px;
font-size: 10px;
font-weight: 500;
letter-spacing: -0.2px;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.dapp-content {
padding: 12px;
height: calc(100% - 100px);
overflow: hidden;
}
.dapp-content h3 {
margin: 0 0 6px 0;
font-size: 16px;
font-weight: 600;
letter-spacing: -0.5px;
}
.dapp-content p {
margin: 0;
opacity: 0.7;
font-size: 12px;
line-height: 1.3;
font-weight: 400;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
letter-spacing: -0.2px;
}
.dapp-link {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
`;
document.head.insertAdjacentHTML('beforeend', styles);
</script>
</body>
</html>