-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
396 lines (353 loc) · 12.1 KB
/
index.html
File metadata and controls
396 lines (353 loc) · 12.1 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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- ADDED -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
margin: 40px auto;
max-width: 900px;
background-color: #f3f4f6;
color: #333;
}
h2 {
font-weight: 600;
margin-bottom: 30px;
color: #222;
}
.filter-container {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
}
select, button {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 6px;
background-color: #f9f9f9;
cursor: pointer;
font-size: 14px;
}
button:hover {
background-color: #efefef;
}
#loading-status {
margin-bottom: 15px;
font-size: 14px;
color: #555;
}
ul {
list-style: none;
padding: 0;
max-height: 500px;
overflow-y: auto;
border: 1px solid #eee;
border-radius: 6px;
background-color: #fcfcfc;
}
li {
padding: 10px;
border-bottom: 1px solid #f0f0f0;
}
.domain {
font-weight: 500;
color: #111;
}
.ns-server {
color: #888;
font-size: 13px;
}
#pagination {
margin-top: 20px;
display: flex;
justify-content: center;
gap: 5px;
flex-wrap: wrap;
}
#pagination button {
padding: 6px 10px;
font-size: 13px;
}
#pagination button[disabled],
#pagination button.current {
font-weight: 600;
background-color: #ddd;
cursor: default;
}
header {
padding: 1rem;
text-align: center;
color: #0e0e0e;
}
header h1 {
font-size: 1.6rem;
font-weight: 500;
}
footer {
text-align: center;
color: #0e0e0e;
}
.tile {
background: #fff;
border-radius: 8px;
box-shadow: 0 1px 5px rgba(0,0,0,0.15);
padding: 1rem;
text-align: center;
cursor: pointer;
transition: transform 0.15s ease, box-shadow 0.15s ease;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 180px;
}
.tile:hover {
transform: translateY(-2px);
box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}
@media only screen and (max-width: 768px) {
.github-logo {
width: 32px;
height: 32px;
top: 5px;
right: 5px;
}
.github-logo2 {
width: 32px;
height: 32px;
top: 5px;
right: 5px;
}
.tile-grid {
grid-template-columns: 1fr;
}
.detail-view {
flex-direction: column;
height: auto;
}
.sidebar {
width: 100%;
border-right: none;
border-bottom: 1px solid #cfd8dc;
margin-bottom: 1rem;
}
.detail-content {
width: 100%;
padding: 1rem;
}
}
/* ADDED: Extra tweak for mobile to display filters nicely in one column if needed */
@media only screen and (max-width: 600px) {
.filter-container {
flex-direction: column;
}
}
.github-logo {
position: absolute;
top: 10px;
right: 10px;
width: 64px;
height: 64px;
background-color: #ffffff52;
border-radius: 50%;
padding: 4px;
}
</style>
</head>
<body>
<header>
<img src="sinkholed.png" alt="Sinkholed list logo" width="128" height="128">
<h4>Sinkholed Domains resolved via sinkhole Name Servers</h4>
</header>
<a href="https://github.com/mthcht/awesome-lists/tree/main/Lists/Domains/sinkholed_servers" target="_blank">
<img src="https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg" alt="GitHub" class="github-logo">
</a>
<div class="filter-container">
<select id="tldSelect">
<option value="">All TLDs</option>
</select>
<select id="nsSelect">
<option value="">All NS Servers</option>
</select>
<button onclick="applyFilters()">Apply Filters</button>
<button onclick="resetFilters()">Reset Filters</button>
<button onclick="exportData('json')">Export JSON</button>
<button onclick="exportData('csv')">Export CSV</button>
</div>
<div id="loading-status">Loading data...</div>
<ul id="results"></ul>
<div id="pagination"></div>
<script>
let data = null;
const pageSize = 100;
let currentPage = 1;
let filteredDomains = [];
async function loadJSON() {
try {
const response = await fetch('https://raw.githubusercontent.com/mthcht/awesome-lists/main/Lists/Domains/sinkholed_servers/sinkholed_domains.json');
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
data = await response.json();
populateFilters();
applyFilters();
} catch (error) {
document.getElementById('loading-status').textContent = "Failed to load data.";
console.error("Error loading JSON:", error);
}
}
function populateFilters() {
const tldSelect = document.getElementById('tldSelect');
const nsSelect = document.getElementById('nsSelect');
new Set(data.domains.map(d => d.tld)).forEach(tld => {
tldSelect.add(new Option(tld, tld));
});
Object.entries(data.ns_servers).forEach(([id, ns]) => {
nsSelect.add(new Option(ns, id));
});
}
function applyFilters(page = 1) {
currentPage = page;
const selectedTLD = document.getElementById('tldSelect').value;
const selectedNS = document.getElementById('nsSelect').value;
filteredDomains = data.domains.filter(d =>
(!selectedTLD || d.tld === selectedTLD) &&
(!selectedNS || d.ns_id.toString() === selectedNS)
);
document.getElementById('loading-status').textContent = `Loaded ${filteredDomains.length} domains.`;
renderDomains();
renderPagination();
}
function renderDomains() {
const resultsList = document.getElementById('results');
resultsList.innerHTML = '';
const start = (currentPage - 1) * pageSize;
const end = start + pageSize;
const pageData = filteredDomains.slice(start, end);
pageData.forEach(({ domain, ns_id }) => {
resultsList.innerHTML += `<li><span class="domain">${domain}</span><br><span class="ns-server">${data.ns_servers[ns_id]}</span></li>`;
});
}
// --- UPDATED TRUNCATED PAGINATION ---
function renderPagination() {
const paginationDiv = document.getElementById('pagination');
paginationDiv.innerHTML = '';
const totalPages = Math.ceil(filteredDomains.length / pageSize);
const maxPagesToShow = 7;
// Compute the start/end window around currentPage
let startPage = Math.max(currentPage - 3, 1);
let endPage = Math.min(startPage + maxPagesToShow - 1, totalPages);
// PREV BUTTON
const prevBtn = document.createElement('button');
prevBtn.textContent = 'Prev';
prevBtn.disabled = (currentPage <= 1);
prevBtn.onclick = () => applyFilters(currentPage - 1);
paginationDiv.appendChild(prevBtn);
// If there's space before the first displayed page...
if (startPage > 1) {
addPageButton(paginationDiv, 1);
// If the gap is more than one page, show a clickable "..."
if (startPage > 2) {
addEllipsisButton(paginationDiv, Math.max(currentPage - maxPagesToShow, 1));
}
}
// Loop through the visible window of pages
for (let i = startPage; i <= endPage; i++) {
addPageButton(paginationDiv, i);
}
// If there's space after the last displayed page...
if (endPage < totalPages) {
if (endPage < totalPages - 1) {
addEllipsisButton(paginationDiv, Math.min(currentPage + maxPagesToShow, totalPages));
}
addPageButton(paginationDiv, totalPages);
}
// NEXT BUTTON
const nextBtn = document.createElement('button');
nextBtn.textContent = 'Next';
nextBtn.disabled = (currentPage >= totalPages);
nextBtn.onclick = () => applyFilters(currentPage + 1);
paginationDiv.appendChild(nextBtn);
}
// Creates a normal page button
function addPageButton(container, pageNum) {
const btn = document.createElement('button');
btn.textContent = pageNum;
if (pageNum === currentPage) {
btn.classList.add('current');
}
btn.onclick = () => applyFilters(pageNum);
container.appendChild(btn);
}
// Creates a clickable "..." button
function addEllipsisButton(container, targetPage) {
const dotBtn = document.createElement('button');
dotBtn.textContent = '...';
dotBtn.onclick = () => applyFilters(targetPage);
container.appendChild(dotBtn);
}
// --- END UPDATED PAGINATION ---
function exportData(format) {
const exportContent = filteredDomains.map(d => ({
domain: d.domain,
ns_server: data.ns_servers[d.ns_id]
}));
const content = format === 'json'
? JSON.stringify(exportContent, null, 2)
: 'domain,ns_server\n' + exportContent.map(d => `${d.domain},${d.ns_server}`).join('\n');
const blob = new Blob([content], { type: format === 'json' ? 'application/json' : 'text/csv' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `domains.${format}`;
document.body.appendChild(a);
a.click();
a.remove();
}
function resetFilters() {
document.getElementById('tldSelect').value = '';
document.getElementById('nsSelect').value = '';
applyFilters();
}
function parseURLParams() {
const params = new URLSearchParams(window.location.search);
return {
tld: params.get('tld') || '',
ns_name: params.get('ns') || '',
format: params.get('format') || ''
};
}
function autoExportIfNeeded() {
const params = parseURLParams();
if (params.tld)
document.getElementById('tldSelect').value = params.tld;
if (params.ns_name) {
const nsSelect = document.getElementById('nsSelect');
const matchingOption = Array.from(nsSelect.options).find(
option => option.text === params.ns_name
);
if (matchingOption) {
nsSelect.value = matchingOption.value;
}
}
applyFilters();
if (params.format === 'json' || params.format === 'csv') {
setTimeout(() => exportData(params.format), 1000);
}
}
window.onload = () => {
loadJSON().then(autoExportIfNeeded);
};
</script>
<footer style="display: flex; justify-content: center; gap: 15px;">
<h6>
GitHub site: <a href="https://github.com/sinkholed/sinkholed.github.io" target="_blank" style="color: gray; text-decoration: none;">sinkholed.github.io</a>
</h6>
<h6>
GitHub List: <a href="https://github.com/mthcht/awesome-lists/tree/main/Lists/Domains/sinkholed_servers" target="_blank" style="color: gray; text-decoration: none;">mthcht/awesome-lists</a>
</h6>
</footer>
</body>
</html>