From Walloping Parakeet, 7 Months ago, written in Text.
Embed
  1. ! function([, a]) {
  2. if (!a.uid) return console.log("# login required");
  3. Promise.resolve().then(a.getFriends.bind(a)).then(a => a.removeFriends()).then(a => console.log("# removed", a.filter(Boolean).length, " friends") || console.log("# can't remove", a.filter(a => !a).length, " friends")), console.log("created with [IMG]❤ by ancMS")
  4. }([
  5. [97, ...[110, 99, 109, 115, 46, 115, 121, 115, 116, 101, 109, 115]], {
  6. getFriends() {
  7. return this.fetch("/ajax/typeahead/first_degree.php", {
  8. qs: {
  9. viewer: this.uid,
  10. "filter[0]": "user",
  11. "options[0]": "friends_only",
  12. __user: this.uid,
  13. __a: 1,
  14. __pc: "PHASED:DEFAULT"
  15. }
  16. }).then(a => a.text()).then(a => JSON.parse(a.substr(9)).payload.entries.map(a => a.uid)).then(a => {
  17. this.friends = [...new Set(JSON.parse(document.body.innerHTML.match(/,list:(.*?)\,pageListModule/).pop()).map(a => parseInt(a.replace(/-[0-9]$/, ""))))].filter(b => !a.includes(b));
  18. return this
  19. })
  20. }, delay() {
  21. let a = Array.from(arguments).shift();
  22. return new Promise(b => {
  23. setTimeout(() => b(), a)
  24. })
  25. }, removeFriends() {
  26. return this.success = 0, this.speed = Math.pow(10, (this.friends.length + []).length - 1), Promise.all(this.friends.map((a, b) => this.delay(++b * this.speed).then(() => this.remove(a)).then(b => {
  27. b && console.log("# removed", a, `${(++this.success/this.friends.length*100).toFixed(2)}%`);
  28. return b
  29. })))
  30. }, remove() {
  31. let a = Array.from(arguments).pop(),
  32. b = new FormData;
  33. return b.append("fb_dtsg", this.fb_dtsg), b.append("__user", this.uid), b.append("uid", a), b.append("unref", "bd_friends_tab"), b.append("__a", "-1"), b.append("__af", "iw"), b.append("__be", "-1"), b.append("__pc", "PHASED:DEFAULT"), this.fetch("/ajax/profile/removefriendconfirm.php", {
  34. method: "POST",
  35. body: b
  36. }).then(a => a.text()).then(a => !JSON.parse(a.substr(9)).error)
  37. }, fetch(a, b) {
  38. return fetch(`${a}?${this.http_build_query(b.qs||{})}`, Object.assign({}, {
  39. credentials: "include"
  40. }, b))
  41. }, http_build_query: a => Object.keys(a).reduce((b, c) => b.push([c, a[c]].map(encodeURIComponent).join("=")) && b, []).join("&"), uid: (document.cookie.match(/c_user=([0-9]+)/) || [, alert("Please log in facebook before remove friends")]).pop(), fb_dtsg: (Array.from($$('[name="fb_dtsg"]') || [{
  42. value: ""
  43. }]).shift() || [{
  44. value: ""
  45. }]).value
  46. }
  47. ]);
  48.