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

Function initCache

scripts/ufs_statistic.js:475–498  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

473};
474
475async function initCache() {
476 if (!CACHED.fbProfile) {
477 CACHED.fbProfile = new Map();
478 try {
479 const c = localStorage.getItem("fbProfile");
480 if (c) {
481 const arr = JSON.parse(c);
482 console.log(arr);
483 arr.forEach((info) => CACHED.fbProfile.set(info.uid, info));
484 }
485 } catch (e) {
486 console.error(e);
487 }
488 }
489
490 if (!CACHED.fb_dtsg) {
491 let res = await UfsGlobal.Extension.runInBackground("fetch", [
492 "https://www.facebook.com/policies_center/",
493 ]);
494 CACHED.fb_dtsg = res?.body?.match?.(
495 /DTSGInitData",\[\],\{"token":"(.*?)"/
496 )?.[1];
497 }
498}
499
500async function getFbProfile(uid, force = false) {
501 const cached = CACHED.fbProfile.get(uid);

Callers 1

onDocumentEndFunction · 0.70

Calls 2

parseMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected