Skip to content

Instantly share code, notes, and snippets.

@dvygolov
Last active November 30, 2022 08:51
Embed
What would you like to do?
Import users to the Blocked list of a Facebooks Fan Page
let api = 'https://graph.facebook.com/v14.0';
let headers = {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-language": "en-US,en;q=0.9",
"cache-control": "max-age=0",
"sec-ch-ua": "\"Google Chrome\";v=\"107\", \"Chromium\";v=\"107\", \"Not=A?Brand\";v=\"24\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1"
};
let f = await fetch(`${api}/me/accounts?access_token=${__accessToken}`, {
"headers": headers,
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
let js = await f.json();
let data = js['data'];
let msg = '';
for (let i = 0; i < data.length; i ++) {
msg += `${i+1}. ${data[i]['name']}\n`;
}
let fpIndex = prompt(`Choose your FanPage (for example, 1):\n${msg}`);
let fp = data[fpIndex-1];
let fpId = fp['id'];
let usersText=prompt(`${fp['name']} selected!\nEnter user ids to block (divided by Enter):`);
let users = usersText.split('\n');
var userIds=[];
let r = /\d+/;
for (var i=0;i<users.length;i++){
userIds.push(r.exec(users[i])[0]);
}
console.log(`Total users found:${users.length}`);
let result = await blockUsers(fpId,fp['access_token'],userIds);
alert(JSON.stringify(result));
async function blockUsers(fpId,fpToken,users){
let f = await fetch(`${api}/${fpId}/blocked?access_token=${fpToken}&method=post&user=${JSON.stringify(users)}`, {
"headers": headers,
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
let js = await f.json();
console.log(js);
return js;
}
@veinsis
Copy link

veinsis commented Nov 21, 2022

Sad it doesn't work anymore with new FanPage type

@dvygolov
Copy link
Author

Sad it doesn't work anymore with new FanPage type

Updated the script, now it does work with New Page Experience.

@veinsis
Copy link

veinsis commented Nov 21, 2022

Sad it doesn't work anymore with new FanPage type

Updated the script, now it does work with New Page Experience.

Wow awesome I tested it it really works! You made my life easier bro

@dvygolov
Copy link
Author

dvygolov commented Nov 21, 2022

Wow awesome I tested it it really works! You made my life easier bro

You are welcome, man!

@veinsis
Copy link

veinsis commented Nov 30, 2022

Hello bro I struggled in step when I need to export new blocked users from FP new type. How can I do that?

@dvygolov
Copy link
Author

dvygolov commented Nov 30, 2022

Hello bro I struggled in step when I need to export new blocked users from FP new type. How can I do that?

Yep, no problem. I made this script to export blocked users: https://gist.github.com/dvygolov/eaf57fd387df03cce9c04544fa28f220
Also I updated the article about these scripts: https://yellowweb.top/zaranee-ubiraem-negativno-nastroennuyu-auditoriyu-s-pomoshhyu-skriptov-importa-eksporta-nadoedlivyh-kommentatorov/

You are welcome.

@veinsis
Copy link

veinsis commented Nov 30, 2022

Hello bro I struggled in step when I need to export new blocked users from FP new type. How can I do that?

Yep, no problem. I made this script to export blocked users: https://gist.github.com/dvygolov/eaf57fd387df03cce9c04544fa28f220 Also I updated the article about these scripts: https://yellowweb.top/zaranee-ubiraem-negativno-nastroennuyu-auditoriyu-s-pomoshhyu-skriptov-importa-eksporta-nadoedlivyh-kommentatorov/

You are welcome.

Awesome! Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment