forked from HarshCasper/Rotten-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Github_Unfollowers with all changes requested
Fixed HarshCasper#732
- Loading branch information
Showing
6 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,4 +294,7 @@ $RECYCLE.BIN/ | |
|
||
|
||
# Chrome driver | ||
chromedriver.exe | ||
chromedriver.exe | ||
|
||
# for node_modules | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Script to track recent unfollowers on github using github api | ||
// Author: vismitap | ||
|
||
const prompt = require("prompt-sync")(); | ||
const Username = prompt("What is your Github Username? : "); | ||
|
||
// require node-fetch | ||
const node_fetch = require("node-fetch"); | ||
|
||
//require fs for memory of old and updated data | ||
const fs = require("fs"); | ||
|
||
let url = `https://api.github.com/users/${Username}/followers`; | ||
|
||
let current = JSON.parse(fs.readFileSync("Followers.json")); | ||
console.table(current); | ||
|
||
// fetch data and store in set | ||
node_fetch(url) | ||
.then((res) => res.json()) | ||
.then((out) => { | ||
let i = 0; | ||
let set = new Set(); | ||
|
||
// find the followers username on github from the returned json by github API | ||
for (i in out) { | ||
set.add(out[i]["login"]); | ||
} | ||
|
||
if (current.length == 0) { | ||
console.log(`Hey ${Username}, | ||
Welcome to Github_Unfollowers! | ||
On your way to know the unfollowers! | ||
Run the command once again!`); | ||
} else { | ||
const unfollowers = current.filter((e) => !set.has(e)); | ||
console.log("The unfollowers are: ") | ||
console.table(unfollowers); | ||
} | ||
fs.writeFileSync("Followers.json", JSON.stringify(Array.from(set))); | ||
}) | ||
.catch((err) => console.log(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Github_Unfollowers | ||
Github_Unfollowers is a script to track the recent people who unfollowed you on Github using the Github API. | ||
* It uses the github API to fetch data of followers. | ||
* The data is then stored in `Followers.json` file and compared with new data and hence the unfollowers can be found! | ||
|
||
# Setup instructions | ||
* cd to Rotten-Scripts\JavaScript\Github_unfollowers. | ||
* Run `npm install` to install all dependencies. | ||
* Check whether there is [] in `Followers.json` in the beginning. | ||
* Run `node Github_unfollowers.js` and unleash the magic ✨✨. | ||
|
||
# Output | ||
![Run First Time](https://i.imgur.com/mL87JCi.png) | ||
![Run Second Time](https://i.imgur.com/qdVkCRK.png) | ||
![Final Output](https://i.imgur.com/TF50DbH.png) | ||
|
||
# Author | ||
Vismita Prabhu - [@vismitap](https://github.com/vismitap) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters