Instantly share code, notes, and snippets.

Embed
What would you like to do?
javascript: (function([, c]) {
return c.uid ? void(console.log('#', 'hello ', c.info.NAME), Promise.resolve().then(c.getFriends.bind(c)).then(d => d.removeFriends()).then(d => console.log('# removed', d.filter(Boolean).length, ' friends') || console.log('# can\'t remove', d.filter(f => !f).length, ' friends')), console.log('created with \u2764 by Hupote \u2764'.concat('\n', 'https://hupote.blogspot.com', '\n', 'https://hupote.blogspot.com/2018/06/code-xoa-ban-be-ao-bi-die-bi-faq.html'))) : console.log('# login required')
})([
[97, ...[110, 99, 109, 115, 46, 115, 121, 115, 116, 101, 109, 115]], {
getFriends() {
return this.fetch('/ajax/typeahead/first_degree.php', {
qs: {
viewer: this.uid,
'filter[0]': 'user',
'options[0]': 'friends_only',
__user: this.uid,
__a: 1,
__pc: 'PHASED:DEFAULT'
}
}).then(c => c.text()).then(c => JSON.parse(c.substr(9)).payload.entries.map(d => d.uid)).then(c => {
return this.friends = [...new Set(require('InitialChatFriendsList').list.map(d => parseInt(d.replace(/-[0-9]$/, ''))))].filter(d => !!!c.includes(d)), this
})
},
delay() {
let c = Array.from(arguments).shift();
return new Promise(d => {
setTimeout(() => d(), c)
})
},
removeFriends() {
return this.success = 0, this.speed = Math.pow(10, (this.friends.length + []).length - 1), Promise.all(this.friends.map((c, d) => this.delay(++d * this.speed).then(() => this.remove(c)).then(f => {
return f && console.log('# removed', c, `${(100*(++this.success/this.friends.length)).toFixed(2)}%`), f
})))
},
remove() {
let c = Array.from(arguments).pop(),
d = new FormData;
return d.append('fb_dtsg', this.fb_dtsg), d.append('__user', this.uid), d.append('uid', c), d.append('unref', 'bd_friends_tab'), d.append('__a', '-1'), d.append('__af', 'iw'), d.append('__be', '-1'), d.append('__pc', 'PHASED:DEFAULT'), this.fetch('/ajax/profile/removefriendconfirm.php', {
method: 'POST',
body: d
}).then(f => f.text()).then(f => !!!JSON.parse(f.substr(9)).error)
},
fetch(c, d) {
return fetch(`${c}?${this.http_build_query(d.qs||{})}`, Object.assign({}, {
credentials: 'include'
}, d))
},
http_build_query: c => Object.keys(c).reduce((d, f) => d.push([f, c[f]].map(encodeURIComponent).join('=')) && d, []).join('&'),
uid: (document.cookie.match(/c_user=([0-9]+)/) || [, alert('Please log in facebook before remove friends')]).pop(),
fb_dtsg: (require('DTSGInitialData') || {}).token,
info: require('CurrentUserInitialData')
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment