Skip to content

Commit 325baf8

Browse files
committed
Added Github_Unfollowers with all changes requested
Fixed #732
1 parent 696b8db commit 325baf8

File tree

6 files changed

+104
-2
lines changed

6 files changed

+104
-2
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,7 @@ $RECYCLE.BIN/
294294

295295

296296
# Chrome driver
297-
chromedriver.exe
297+
chromedriver.exe
298+
299+
# for node_modules
300+
node_modules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Script to track recent unfollowers on github using github api
2+
// Author: vismitap
3+
4+
const prompt = require("prompt-sync")();
5+
const Username = prompt("What is your Github Username? : ");
6+
7+
// require node-fetch
8+
const node_fetch = require("node-fetch");
9+
10+
//require fs for memory of old and updated data
11+
const fs = require("fs");
12+
13+
let url = `https://api.github.com/users/${Username}/followers`;
14+
15+
let current = JSON.parse(fs.readFileSync("Followers.json"));
16+
console.table(current);
17+
18+
// fetch data and store in set
19+
node_fetch(url)
20+
.then((res) => res.json())
21+
.then((out) => {
22+
let i = 0;
23+
let set = new Set();
24+
25+
// find the followers username on github from the returned json by github API
26+
for (i in out) {
27+
set.add(out[i]["login"]);
28+
}
29+
30+
if (current.length == 0) {
31+
console.log(`Hey ${Username},
32+
Welcome to Github_Unfollowers!
33+
On your way to know the unfollowers!
34+
Run the command once again!`);
35+
} else {
36+
const unfollowers = current.filter((e) => !set.has(e));
37+
console.log("The unfollowers are: ")
38+
console.table(unfollowers);
39+
}
40+
fs.writeFileSync("Followers.json", JSON.stringify(Array.from(set)));
41+
})
42+
.catch((err) => console.log(err));
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Github_Unfollowers
2+
Github_Unfollowers is a script to track the recent people who unfollowed you on Github using the Github API.
3+
* It uses the github API to fetch data of followers.
4+
* The data is then stored in `Followers.json` file and compared with new data and hence the unfollowers can be found!
5+
6+
# Setup instructions
7+
* cd to Rotten-Scripts\JavaScript\Github_unfollowers.
8+
* Run `npm install` to install all dependencies.
9+
* Check whether there is [] in `Followers.json` in the beginning.
10+
* Run `node Github_unfollowers.js` and unleash the magic ✨✨.
11+
12+
# Output
13+
![Run First Time](https://i.imgur.com/mL87JCi.png)
14+
![Run Second Time](https://i.imgur.com/qdVkCRK.png)
15+
![Final Output](https://i.imgur.com/TF50DbH.png)
16+
17+
# Author
18+
Vismita Prabhu - [@vismitap](https://github.com/vismitap)

JavaScript/Github_Unfollowers/package-lock.json

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JavaScript/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ It enables interactive web pages and thus is an essential part of web applicatio
2929
| 16 | ROT13 | [Click Here](ROT13) | [tej5169](https://github.com/tej5169) |
3030
| 17 | RSA Key Pair Generator | [Click Here](RSA_Key_Pair_Generator) | [Mohit Bhat](https://github.com/mbcse) |
3131
| 18 | Send emails | [Click Here](Send_Emails) | [Namya LG](https://github.com/Namyalg) |
32-
| 19 | Who don't follow you | [Click Here](Who_Don't_Follow_You) | [Harsh Barshan Mishra](https://github.com/HarshCasper) |
32+
| 19 | Who don't follow you | [Click Here](Who_Don't_Follow_You) | [Harsh Barshan Mishra](https://github.com/HarshCasper) |
33+
| 20 | Github_Unfollowers | [Click Here](Github_Unfollowers) | [Vismita Prabhu](https://github.com/vismitap) |

0 commit comments

Comments
 (0)