-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex2.js
29 lines (24 loc) · 1.08 KB
/
index2.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
const codeforcesHandle = "nilan12";
const githubUsername = "nilan425";
const codeforcesHandleDiv = document.getElementById("cf-handle");
const codeforcesRatingDiv = document.getElementById("cf-rating");
const githubUsernameDiv = document.getElementById("gh-username");
const githubRepositoriesDiv = document.getElementById("gh-repositories");
async function updateCodeforcesTooltip() {
codeforcesHandleDiv.innerHTML = `Handle: ${codeforcesHandle}`;
const res = await fetch(`https://codeforces.com/api/user.info?handles=${codeforcesHandle}`);
const data = await res.json();
if (data.status === "OK") {
const { rating } = data.result[0];
codeforcesRatingDiv.innerHTML = `Rating: ${rating}`;
}
}
async function updateGithubTooltip() {
githubUsernameDiv.innerHTML = `Username: ${githubUsername}`;
const res = await fetch(`https://api.github.com/users/${githubUsername}`);
const data = await res.json();
const { public_repos } = data;
githubRepositoriesDiv.innerHTML = `Repositories: ${public_repos}`;
}
updateCodeforcesTooltip();
updateGithubTooltip();