GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — github-following-tracker/index.js at main · youngkwon02/github-following-tracker

Expand file tree

/

index.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
98 lines (80 loc) · 2.74 KB
/

index.js

Copy path

File metadata and controls

98 lines (80 loc) · 2.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
const { fetchGET } = require("./util/fetchGET");
const { getRequestUrl } = require("./util/getRequestUrl");
const { githubHost } = require("./util/githubHost");
const { pageType } = require("./util/pageType");
const { stringToHtml } = require("./util/stringToHtml");
const prompt = require("prompt-sync")({ sigint: true });
const getFollowers = async (gitHost) => {
let followers = [];
for (let page = 1; ; page++) {
const requestUrl = getRequestUrl(gitHost, "", {
page,
tab: pageType.FOLLOWERS,
});
let res = await fetchGET(requestUrl);
const jsDomRes = stringToHtml(res.data);
const tagElements = jsDomRes.window.document.querySelectorAll(
".d-table-cell .Link--secondary"
);
if (!tagElements.length) {
break;
}
tagElements.forEach((n) => followers.push(n.textContent));
}
return followers;
};
const getFollowing = async (gitHost) => {
let followings = [];
for (let page = 1; ; page++) {
const requestUrl = getRequestUrl(gitHost, "", {
page,
tab: pageType.FOLLOWING,
});
let res = await fetchGET(requestUrl);
const jsDomRes = stringToHtml(res.data);
const tagElements = jsDomRes.window.document.querySelectorAll(
".d-table-cell .Link--secondary"
);
if (!tagElements.length) {
break;
}
tagElements.forEach((n) => followings.push(n.textContent));
}
return followings;
};
const printResult = (followers, followings) => {
const only = {
followingOnly: [],
followerOnly: [],
};
followings.forEach((f) => {
!followers.includes(f) ? only.followingOnly.push(f) : false;
});
followers.forEach((f) => {
!followings.includes(f) ? only.followerOnly.push(f) : false;
});
console.log("--------------------------------------------------------");
console.log(`Total Followers : ${followers.length}`);
console.log(`Total Followings : ${followings.length}`);
console.log("--------------------------------------------------------");
console.log(`Only you follow : ${only.followingOnly.length}`);
only.followingOnly.forEach((f) => console.log(f));
console.log("--------------------------------------------------------");
console.log(`Only someone follows : ${only.followerOnly.length}`);
only.followerOnly.forEach((f) => console.log(f));
console.log("--------------------------------------------------------");
};
const crawlAll = async () => {
const name = prompt("What is your GitHub name? ");
const host = githubHost(name);
try {
const followers = await getFollowers(host);
const followings = await getFollowing(host);
printResult(followers, followings);
} catch (e) {
console.log(
"존재하지 않는 GitHub name이거나 Tracking 불가능한 계정입니다."
);
}
};
crawlAll();
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.