Created
March 2, 2019 14:54
-
-
Save monokaijs/6596fed85f2954b41c218c8dde37de8e to your computer and use it in GitHub Desktop.
Unfollow All Facebook Friends.
This file contains hidden or 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
(() => { | |
/* | |
** Author: MonokaiJs | |
** Home: https://monokai.dev | |
*/ | |
const ACCESS_TOKEN = ''; // Get Token Here: https://gist.github.com/monokaijs/ce3abbc37d6bd435f70e39fd59eb3f67 | |
var get_friends = (e, o) => { | |
var a = new XMLHttpRequest; | |
a.onreadystatechange = (() => { | |
4 == a.readyState && 200 == a.status && o(JSON.parse(a.responseText).data) | |
}), a.open("GET", "https://graph.facebook.com/me/friends?limit=5000&fields=id,name&access_token=" + e), a.send() | |
}; | |
var removeFriend = (user, callback) => { | |
var xhr = new XMLHttpRequest; | |
var frm = new FormData(); | |
frm.append('subject_id', user.id); | |
frm.append('forceredirect', 'false'); | |
frm.append('location', '83'); | |
frm.append('m_sess', ''); | |
frm.append('fb_dtsg', require('MRequestConfig')['dtsg']['token']); | |
xhr.open('POST', '/a/subscriptions/remove'); | |
xhr.send(frm); | |
if (xhr.readyState == 4 && xhr.status !== 400 && xhr.status !== 500) callback(user); | |
} | |
get_friends(ACCESS_TOKEN, friend_list => { | |
friend_list.forEach(friend => { | |
removeFriend(friend, unfollowed => { | |
console.log('Unfollowed ' + unfollowed.name); | |
}); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment