MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / getFbProfile

Function getFbProfile

scripts/ufs_statistic_old.js:698–745  ·  view source on GitHub ↗
(uid, force = false)

Source from the content-addressed store, hash-verified

696}
697
698async function getFbProfile(uid, force = false) {
699 if (CACHED.fbProfile.has(uid) && !force) return CACHED.fbProfile.get(uid);
700
701 let res = await UfsGlobal.Extension.runInBackground("fetch", [
702 "https://www.facebook.com/api/graphql/",
703 {
704 method: "POST",
705 headers: { "content-type": "application/x-www-form-urlencoded" },
706 body: new URLSearchParams({
707 fb_api_req_friendly_name: "ProfileCometHeaderQuery",
708 fb_dtsg: CACHED.fb_dtsg,
709 variables: JSON.stringify({
710 userID: uid,
711 shouldDeferProfilePic: false,
712 useVNextHeader: false,
713 scale: 1.5,
714 }),
715 doc_id: "4159355184147969",
716 }).toString(),
717 },
718 ]);
719
720 let text = await res.body;
721 const info = {
722 uid: uid,
723 name: UfsGlobal.DEBUG.decodeEscapedUnicodeString(
724 /"name":"(.*?)"/.exec(text)?.[1]
725 ),
726 avatar: UfsGlobal.DEBUG.decodeEscapedUnicodeString(
727 /"profilePicLarge":{"uri":"(.*?)"/.exec(text)?.[1] ||
728 /"profilePicMedium":{"uri":"(.*?)"/.exec(text)?.[1] ||
729 /"profilePicSmall":{"uri":"(.*?)"/.exec(text)?.[1] ||
730 /"profilePic160":{"uri":"(.*?)"/.exec(text)?.[1]
731 ),
732 gender: /"gender":"(.*?)"/.exec(text)?.[1],
733 alternateName: UfsGlobal.DEBUG.decodeEscapedUnicodeString(
734 /"alternate_name":"(.*?)"/.exec(text)?.[1]
735 ),
736 };
737 CACHED.newFbUsers.set(uid, info);
738 CACHED.fbProfile.set(uid, info);
739 localStorage.setItem(
740 "fbProfile",
741 JSON.stringify(Array.from(CACHED.fbProfile.values()))
742 );
743 console.log(info);
744 return info;
745}
746
747export const TargetType = {
748 User: "user",

Callers 1

onDocumentEndFunction · 0.70

Calls 2

getMethod · 0.80
execMethod · 0.45

Tested by

no test coverage detected