-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
47 lines (41 loc) · 1.21 KB
/
app.js
File metadata and controls
47 lines (41 loc) · 1.21 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
const fetch = require('node-fetch');
const chalk = require('chalk');
const fs = require('fs').promises;
const maxConcurrent = 3;
const threeLetters = [];
for (let a = 0; a < 26; a++)
for (let b = 0; b < 26; b++)
for (let c = 0; c < 26; c++)
threeLetters.push(
String.fromCharCode(a + 97) +
String.fromCharCode(b + 97) +
String.fromCharCode(c + 97)
);
async function isSteamLinkTaken(id) {
const res = await fetch(`https://steamcommunity.com/id/${id}`);
if (!res.ok) throw res.status;
const body = await res.text();
return body.includes('playerAvatarAutoSizeInner');
}
(async () => {
let concurrent = [];
let numDone = 0;
for (const id of threeLetters) {
if (concurrent.length >= maxConcurrent) {
await Promise.all(concurrent);
concurrent = [];
}
concurrent.push((async () => {
const isTaken = await isSteamLinkTaken(id);
numDone++;
const percent = Math.floor(numDone / threeLetters.length * 10000) / 100;
if (isTaken) {
console.log(chalk.red(id) + ` (${percent}%)`);
} else {
console.log(chalk.green(id) + ` (${percent}%)`);
await fs.appendFile('available.txt', `${new Date().toLocaleString()} => ${id}\n`);
}
})());
}
await Promise.all(concurrent);
})();