-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
57 lines (44 loc) Β· 1.58 KB
/
script.js
File metadata and controls
57 lines (44 loc) Β· 1.58 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
async function roastUser() {
const username = document.getElementById("username").value;
if (!username) return alert("Enter username!");
const res = await fetch(`https://api.github.com/users/${username}`);
const user = await res.json();
if (user.message === "Not Found") {
alert("User not found!");
return;
}
document.getElementById("avatar").src = user.avatar_url;
document.getElementById("name").innerText = user.login;
document.getElementById("stats").innerText =
`Repos: ${user.public_repos} | Followers: ${user.followers}`;
// SCORE
let score = user.public_repos * 2 + user.followers * 2;
score = Math.min(score, 100);
document.getElementById("score").innerText = score + "/100";
document.getElementById("progress").style.width = score + "%";
// ROAST
let roast = "";
if (user.public_repos < 5)
roast += "π Very few repos\n";
if (user.followers < 10)
roast += "π No followers\n";
if (!user.bio)
roast += "π€ No bio\n";
if (roast === "") roast = "π Pretty solid profile";
document.getElementById("roast").innerText = roast;
// SUGGESTIONS
let suggestions = [];
if (user.public_repos < 5)
suggestions.push("Create more projects");
if (!user.bio)
suggestions.push("Add a bio");
if (user.followers < 10)
suggestions.push("Be active");
const list = document.getElementById("suggestions");
list.innerHTML = "";
suggestions.forEach(s => {
const li = document.createElement("li");
li.innerText = "π " + s;
list.appendChild(li);
});
}