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

Function initCache

scripts/ufs_statistic_old.js:675–696  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

673};
674
675async function initCache() {
676 if (!CACHED.fbProfile) {
677 CACHED.fbProfile = new Map();
678 try {
679 const c = localStorage.getItem("fbProfile");
680 if (c) {
681 const arr = JSON.parse(c);
682 console.log(arr);
683 arr.forEach((info) => CACHED.fbProfile.set(info.uid, info));
684 }
685 } catch (e) {
686 console.error(e);
687 }
688 }
689
690 if (!CACHED.fb_dtsg) {
691 let res = await UfsGlobal.Extension.runInBackground("fetch", [
692 "https://mbasic.facebook.com/photos/upload/",
693 ]);
694 CACHED.fb_dtsg = RegExp(/name="fb_dtsg" value="(.*?)"/).exec(res.body)?.[1];
695 }
696}
697
698async function getFbProfile(uid, force = false) {
699 if (CACHED.fbProfile.has(uid) && !force) return CACHED.fbProfile.get(uid);

Callers 1

onDocumentEndFunction · 0.70

Calls 3

parseMethod · 0.80
errorMethod · 0.80
execMethod · 0.45

Tested by

no test coverage detected