-
Notifications
You must be signed in to change notification settings - Fork 150
/
index.html
340 lines (274 loc) · 12.7 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
<link rel="shortcut icon" href="favicon.ico">
<title>polkadot{.js}/phishing</title>
<style>
:root {
--bg-box: rgba(255, 255, 255, 0.85);
--color: #4e4e4e;
--font-mono: 0.9em Consolas, monaco, "Ubuntu Mono", "Liberation Mono", "Courier New", Courier, monospace;
--font-sans: 1em "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
a { color: #ff8c00 !important; text-decoration: none }
body { color: var(--color); font: var(--font-sans); height: 100vh; overflow-x: hidden; padding: 0 }
h3 { font: var(--font-sans); font-weight: 400; margin: 0; opacity: 0.5; text-transform: lowercase }
p { line-height: 1.5rem; margin: 0.75rem 0 }
input { color: var(--color); display: block; opacity: 0.85; padding: 0.5rem 0.75rem; width: 100% }
input:focus { outline: none }
.box { background: var(--bg-box); border-radius: 0.25rem; flex: 1 1; margin: 0.5rem; min-width: 15rem; max-width: 40rem; padding: 1rem 1.5rem; text-align: center; white-space: nowrap; width: 40rem; z-index: 2 }
.buttons { display: none; margin: 2rem 0 1.5rem }
.buttons a { border: 1px solid #eee; border-radius: 0.25rem; margin: 0 0.25rem; padding: 0.5rem 0.75rem }
.buttons .invert { color: var(--bg-box) !important }
.container { align-items: center; display: flex; flex-direction: column; justify-content: center; margin-top: 4rem; padding-bottom: 2rem }
.desc { font-size: 0.95rem; opacity: 0.85; white-space: normal }
.dot { border-radius: 50%; position: absolute; z-index: 0 }
.header { align-items: center; background: var(--bg-box); display: flex; left: 0; justify-content: space-between; padding: 0.5rem 1rem; position: fixed; right: 0; top: 0; z-index: 2 }
.header div.logo { display: flex; align-items: center }
.header img { height: 1.5rem; margin-right: 0.5rem; width: 1.5rem }
.hidden { display: none }
.row { align-items: center; display: flex; justify-content: center }
p.search { padding: 0 1rem }
input#search { border: 1px solid #888; border-radius: 0.25rem; display: none }
table { margin: 0 }
td:first-child { max-width: 29rem; overflow: hidden; text-overflow: ellipsis }
td:not(.centered) { font: var(--font-mono); padding: 0.25rem 0.5rem; text-align: right }
td.centered { opacity: 0.65; padding: 1rem; text-align: center }
td:nth-child(2) { width: 100% }
tr + tr > td > h3 { margin-top: 0.5rem }
td > span { border-radius: 0.25em; color: white; font-size: 0.75rem; padding: 0.125em 0.375em }
td > span.active { background: darkred }
td > span.inactive { background: darkgrey; display: none }
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="box">
<p class="desc">A community driven curated list of potentially less-than-honest operators.</p>
<p class="desc">Any additions can be made by editing <a href="https://github.com/polkadot-js/phishing/edit/master/all.json">phishing/all.json</a> and adding any new sites in alphabetical order. In the same vein addresses can be added in <a href="https://github.com/polkadot-js/phishing/edit/master/address.json">phishing/address.json</a>. For any discrepancies or requests <a href="https://github.com/polkadot-js/phishing/issues">log an issue</a>.</p>
<p class="desc">The following extensions and wallets have blocking functionality based on these lists: <a href="https://github.com/polkadot-js/extension">polkadot{.js} extension</a>, <a href="https://polkadot.js.org/apps">polkadot{.js} apps</a>, <a href="https://talisman.xyz/">Talisman</a>, <a href="https://polkagate.xyz/">PolkaGate extension</a>, <a href="https://novawallet.io/">Nova Wallet</a>, <a href="https://fearlesswallet.io/">Fearless Wallet</a> and <a href="https://subwallet.app/">SubWallet</a>.</p>
<p id="buttons" class="buttons"><a href="#" id="btn-sites" onclick="fillTable('sites')">Sites</a><a href="#" id="btn-addresses" onclick="fillTable('addresses')">Addresses</a></p>
<p class="search"><input id="search" placeholder="search & filter entries" type="search"></p>
<table>
<tbody id="table">
<tr>
<td></td>
<td class="centered">.. loading url & address metadata ...</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="header">
<div class="logo">
<img src="https://polkadot.js.org/logo.svg" />
<div>polkadot{.js}/phishing</div>
</div>
<a href="https://github.com/polkadot-js/phishing">view on github</a>
</div>
<script>
if (window.self !== window.top) {
window.top.location.href = window.location.href;
}
const search = document.getElementById('search');
const style = document.createElement('style');
const table = document.getElementById('table');
document.head.appendChild(style);
let hue = Math.floor(Math.random() * 359);
let counter = 0;
let navTo = '';
let metaJson = [];
let addrJson;
let urlStatus;
let balances = [];
function draw () {
hue = (hue + 1) % 360;
document.body.style.background = `hsl(${hue}, 45%, 85%)`;
style.innerHTML = `a { color: hsl(${hue}, 45%, 45%) !important } .buttons a { border-color: hsl(${hue}, 45%, 45%) !important } .buttons .invert { background: hsl(${hue}, 45%, 45%) !important } input#search:focus { border-color: hsl(${hue}, 45%, 45%) }`;
setTimeout(() => window.requestAnimationFrame(draw), 100);
}
function onSearch (evt) {
const text = evt.target.value;
const trs = document.getElementsByTagName('tr');
for (let i = 0; i < trs.length; i++) {
const tr = trs[i];
const attr = tr.getAttribute('data-value');
if (attr && !attr.includes(text)) {
tr.classList.add('hidden');
} else {
tr.classList.remove('hidden');
}
}
}
function appendRow (date, url = '', status) {
const row = document.createElement('tr');
const a = document.createElement('td');
const b = document.createElement('td');
const c = document.createElement('td');
a.appendChild(document.createTextNode(url));
if (typeof date === 'string') {
b.appendChild(document.createTextNode(date));
} else {
b.appendChild(date);
}
if (typeof status === 'string') {
const s = document.createElement('span');
s.classList.add(status);
s.appendChild(document.createTextNode(status));
c.appendChild(s);
}
row.setAttribute('data-value', url);
row.appendChild(a);
row.appendChild(b);
row.appendChild(c);
table.appendChild(row);
}
function appendHeader (header) {
const row = document.createElement('tr');
const ab = document.createElement('td');
const c = document.createElement('td');
if (typeof header === 'string') {
ab.appendChild(document.createTextNode(header));
} else {
ab.appendChild(header);
}
ab.colSpan = 2;
row.appendChild(ab);
row.appendChild(c);
table.appendChild(row);
}
function fillAddressList (url, addresses) {
if (addresses && addresses.length) {
const c = document.createElement('h3');
c.appendChild(document.createTextNode(url));
appendHeader(c);
addresses.forEach((address) => {
const balance = balances.find(([a]) => a === address) || ['', '']
appendRow(balance[1], address);
});
}
}
function fillAddresses () {
metaJson.forEach(({ url }) => fillAddressList(url, addrJson[url]));
Object.entries(addrJson).forEach(([url, addresses]) => {
if (!metaJson.find((m) => m.url === url)) {
fillAddressList(url, addresses);
}
});
}
function fillSites (items = metaJson) {
if (navTo === 'sites') {
let prevMonth = '';
let countIndex = -1;
const count = items.reduce((count, { date }) => {
const thisMonth = date.split('-').slice(0, 2).join('-');
if (thisMonth !== prevMonth) {
count.push(0);
prevMonth = thisMonth;
}
count[count.length - 1] += 1;
return count;
}, []);
prevMonth = '';
items.forEach(({ date, url }, index) => {
const thisMonth = date.split('-').slice(0, 2).join('-');
if (thisMonth !== prevMonth) {
const c = document.createElement('h3');
countIndex++;
c.appendChild(document.createTextNode(`${thisMonth} (${count[countIndex]})`));
appendHeader(c);
prevMonth = thisMonth;
}
appendRow(date, url, urlStatus[index] ? 'active' : 'inactive');
});
}
document.getElementById('btn-sites').innerText = `Sites (${metaJson.length})`;
}
function fillTable (newNav) {
if (newNav !== navTo) {
if (navTo) {
document.getElementById(`btn-${navTo}`).classList = '';
}
document.getElementById(`btn-${newNav}`).classList = 'invert';
navTo = newNav;
table.innerHTML = '';
if (navTo === 'sites') {
fillSites();
} else {
fillAddresses();
}
search.focus();
}
}
async function fetchTimeout (url, options = {}) {
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), 2500);
const response = await fetch(url, { ...options, signal: controller.signal });
clearTimeout(id);
return response;
}
async function isUp (url) {
// try {
// await fetchTimeout(url, { method: 'HEAD', mode: 'no-cors' });
// const response = await fetchTimeout(`https://proxy.dotapps.workers.dev/?${url}`, { follow: 'error' });
// return response.status === 200;
// } catch (error) {
// return false;
// }
return false;
}
async function getBalance (key) {
try {
const response = await fetchTimeout('https://polkadot.subscan.io/api/scan/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ key, page: 0, row: 1 })
});
const { data } = await response.json();
const [pre, post] = ((data && data.account.balance) || '0').split('.');
return [key, `${pre}.${`${post || ''}0000000000`.substr(0, 10)}`];
} catch (error) {
console.error(error);
return [key, ''];
}
}
async function main () {
draw();
const from = window.location.protocol === 'file:' ? 'https://polkadot.js.org/phishing/' : '';
const [addrBody, metaBody] = await Promise.all(['address', 'meta/index'].map((j) => fetchTimeout(`${from}${j}.json`)));
let metaMonths;
[addrJson, metaMonths] = await Promise.all([addrBody.json(), metaBody.json()]);
const addresses = Object
.values(addrJson)
.reduce((all, addrs) => {
addrs.forEach((a) => !all.includes(a) && all.push(a));
return all;
}, []);
[balances, urlStatus] = await Promise.all([
Promise.all(addresses.map(getBalance)),
Promise.all(metaJson.map(({ url }) => isUp(`https://${url}`)))
]);
search.addEventListener('input', onSearch);
search.style.display = 'block';
document.getElementById('btn-addresses').innerText = `Addresses (${Object.values(addrJson).reduce((count, addrs) => count + addrs.length, 0)})`;
document.getElementById('btn-sites').innerText = `Sites (0)`;
document.getElementById('buttons').style.display = 'block';
fillTable('sites');
for (const month of metaMonths) {
const response = await fetchTimeout(`${from}meta/${month}.json`);
const items = await response.json();
for (const item of items) {
metaJson.push(item);
}
fillSites(items);
}
}
main();
</script>
</body>
</html>