Last active
April 7, 2023 07:18
-
-
Save dvygolov/eaf57fd387df03cce9c04544fa28f220 to your computer and use it in GitHub Desktop.
Export Blocked Users from your FanPage: first switch your profile to your FanPage, then run the script on https://www.facebook.com/settings?tab=blocking
This file contains 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
async function privateApiRequest2(body = null, headers = null, url = null) { | |
let graphUrl = ""; | |
if (url != null) graphUrl = url; | |
else { | |
let subDomain = getSubDomain(); | |
graphUrl = `https://${subDomain}.facebook.com/api/graphql/`; | |
} | |
if (body == null) { | |
let uid = require("CurrentUserInitialData").USER_ID; | |
let dtsg = require("DTSGInitialData").token; | |
let lsd = require("LSD").token; | |
body = `__user=${uid}&__a=1&fb_dtsg=${dtsg}&lsd=${lsd}`; | |
} | |
headers = headers ?? { | |
accept: "*/*", | |
"accept-language": "ca-ES,ca;q=0.9,en-US;q=0.8,en;q=0.7", | |
"content-type": "application/x-www-form-urlencoded", | |
"sec-ch-ua": | |
'"Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"', | |
"sec-ch-ua-mobile": "?0", | |
"sec-ch-ua-platform": '"Windows"', | |
"sec-fetch-dest": "empty", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-site": "same-origin", | |
"x-fb-lsd": require("LSD").token, | |
}; | |
let f = await fetch(graphUrl, { | |
headers: headers, | |
body: body, | |
method: "POST", | |
mode: "cors", | |
credentials: "include", | |
}); | |
let t = await f.text(); | |
if (t.startsWith("for (;;);")) t = t.substring(9); | |
return JSON.parse(t); | |
} | |
async function privateApiRequest(variables, docId, url = null) { | |
let graphUrl = ""; | |
if (url != null) graphUrl = url; | |
else { | |
let subDomain = getSubDomain(); | |
graphUrl = `https://${subDomain}.facebook.com/api/graphql/`; | |
} | |
let lsd = require("LSD").token; | |
let dtsg = require("DTSGInitialData").token; | |
let uid = require("CurrentUserInitialData").USER_ID; | |
let body = { | |
av: uid, | |
__user: uid, | |
__a: 1, | |
fb_dtsg: dtsg, | |
lsd: lsd, | |
variables: JSON.stringify(variables), | |
server_timestamps: true, | |
doc_id: docId, | |
}; | |
let headers = { | |
accept: "*/*", | |
"accept-language": "ca-ES,ca;q=0.9,en-US;q=0.8,en;q=0.7", | |
"content-type": "application/x-www-form-urlencoded", | |
"sec-ch-ua": | |
'"Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"', | |
"sec-ch-ua-mobile": "?0", | |
"sec-ch-ua-platform": '"Windows"', | |
"sec-fetch-dest": "empty", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-site": "same-origin", | |
"x-fb-lsd": lsd, | |
}; | |
return await privateApiRequest2( | |
new URLSearchParams(body).toString(), | |
headers, | |
graphUrl | |
); | |
} | |
function getSubDomain(){ | |
let curUrl = window.location.href; | |
let subDomain = curUrl.includes("/business.") ? "business" : (curUrl.includes("/adsmanager.") ?"adsmanager" : "www"); | |
return subDomain; | |
} | |
let js = await privateApiRequest({"settingType":"USER","profile_picture_size":36},5380804175301552); | |
let setting = js.data.viewer.privacy_block_settings.setting; | |
let users = []; | |
for (const edge of setting.blockees.edges){ | |
users.push(`https://facebook.com/${edge.node.id}`); | |
} | |
while (setting.blockees.page_info.has_next_page){ | |
js = await privateApiRequest({"count":10,"cursor":setting.blockees.page_info.end_cursor,"profile_picture_size":36,"id":setting.id},5186554984768632); | |
setting = js.data.node; | |
for (const edge of setting.blockees.edges){ | |
users.push(`https://facebook.com/${edge.node.id}`); | |
} | |
} | |
console.log(users.join("\n")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment