11import { BADGES } from "./helpers/badge.js" ;
2- import { getFbdtsg , getYourUserId } from "./fb_GLOBAL .js" ;
2+ import { runFunc } from "./helpers/utils .js" ;
33
44const CACHED = {
55 uid : null ,
66 fb_dtsg : null ,
77} ;
88
9+ const GLOBAL = {
10+ fetch : ( url , options ) => fetch ( url , options || { } ) . then ( ( res ) => res . text ( ) ) ,
11+ } ;
12+
913export default {
1014 icon : '<i class="fa-brands fa-square-facebook fa-2xl"></i>' ,
1115 name : {
@@ -29,42 +33,11 @@ export default {
2933 backgroundScript : {
3034 runtime : {
3135 onMessageExternal : async ( { request, sender, sendResponse } , context ) => {
32- if ( request . action === "fb_allInOne_init" ) {
33- init ( ) . then ( sendResponse ) ;
34- return true ;
35- }
36-
37- if ( request . action === "request_graphql" && request . query ) {
38- ( async ( ) => {
39- if ( ! CACHED . fb_dtsg ) await init ( ) ;
40-
41- fetch ( request . url || "https://www.facebook.com/api/graphql/" , {
42- body : request . query + "&fb_dtsg=" + CACHED . fb_dtsg ,
43- method : "POST" ,
44- headers : { "Content-Type" : "application/x-www-form-urlencoded" } ,
45- credentials : "include" ,
46- } )
47- . then ( ( res ) => res . text ( ) )
48- . then ( sendResponse )
49- . catch ( ( e ) => sendResponse ( { error : e . message } ) ) ;
50- } ) ( ) ;
51- return true ;
52- }
53-
54- if ( request . action === "fetch" ) {
55- fetch ( request . url , request . options || { } )
56- . then ( ( res ) => res . text ( ) )
57- . then ( sendResponse )
58- . catch ( ( e ) => sendResponse ( { error : e . message } ) ) ;
36+ if ( request . action === "fb_allInOne_runFunc" ) {
37+ runFunc ( request . fnPath , request . params , GLOBAL ) . then ( sendResponse ) ;
5938 return true ;
6039 }
6140 } ,
6241 } ,
6342 } ,
6443} ;
65-
66- async function init ( ) {
67- CACHED . uid = await getYourUserId ( ) ;
68- CACHED . fb_dtsg = await getFbdtsg ( ) ;
69- return CACHED ;
70- }
0 commit comments