Last active
February 24, 2019 04:49
remove friends no longer exists from facebook
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
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 Duc An'.concat('\n','https://ancms.systems/','\n','https://gist.github.com/ancm-s/5cb15c8f432d2be1c6fdb66ff89df030'))):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
This code no longer works :((