-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathetherscan_extractor.js
129 lines (119 loc) · 3.24 KB
/
etherscan_extractor.js
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
// ==UserScript==
// @name Ethereum Address Extractor
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Extract Ethereum addresses from etherscan.io
// @author icepy
// @match https://etherscan.io/accounts/label/bridge?subcatid=undefined&size=100&start=0&col=1&order=asc
// @icon https://www.google.com/s2/favicons?sz=64&domain=etherscan.io
// @grant none
// ==/UserScript==
(function () {
"use strict";
alert('Starting Etherscan userscripts for tag "bridge"');
const length = 207;
const pages = 56;
let draw = 1;
const payload = {
labelModel: {
label: "bridge",
},
dataTableModel: {
draw,
length,
start: 0,
search: {
value: "",
regex: false,
},
order: [
{
column: 1,
dir: "asc",
},
],
columns: [
{
data: "address",
name: "",
searchable: true,
orderable: false,
search: { value: "", regex: false },
},
{
data: "nameTag",
name: "",
searchable: true,
orderable: false,
search: { value: "", regex: false },
},
{
data: "balance",
name: "",
searchable: true,
orderable: true,
search: { value: "", regex: false },
},
{
data: "txnCount",
name: "",
searchable: true,
orderable: true,
search: { value: "", regex: false },
},
],
},
};
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function run() {
const values = [];
const hacks = [];
const csv = [["address", "nameTag", "balance", "txnCount"]];
for (let index = 1; index <= pages; index++) {
console.log(`Fetching page ${index} of ${pages}`);
payload.dataTableModel.draw = draw++;
payload.dataTableModel.start = (index - 1) * length;
const response = await fetch(
"https://etherscan.io/accounts.aspx/GetTableEntriesBySubLabel",
{
method: "POST",
headers: [["Content-Type", "application/json; charset=utf-8"]],
body: JSON.stringify(payload),
}
);
const json = await response.json();
const data = json.d.data;
const newData = data.map((v) => {
const anchorMatch = /href\s*=\s*['"]\/address\/([^'"]+)['"]/.exec(v.address);
const fullAddress = anchorMatch ? anchorMatch[1] : '';
return {
address: fullAddress,
balance: v.balance.replace(/<[^<>]+>/g, ""),
nameTag: v.nameTag,
txnCount: v.txnCount,
};
});
values.push(newData);
await sleep(3000);
}
values.forEach((v) => {
v.forEach((k) => {
hacks.push(k);
csv.push([k.address, k.nameTag, k.balance, k.txnCount]);
});
});
const createCSVData = csv
.map((v) => {
return v.join(",");
})
.join("\n");
alert(
'Finished Etherscan userscripts for tag "bridge". Check console for csv'
);
console.log(JSON.stringify(hacks));
console.log(JSON.stringify(createCSVData));
}
run();
})();