@@ -12,92 +12,12 @@ export default {
12
12
} ,
13
13
14
14
onClickExtension : async ( ) => {
15
- async function searchGroupForOther ( other_uid , cursor , uid , dtsg ) {
16
- let variables = JSON . stringify ( {
17
- count : 8 ,
18
- cursor : cursor ?? null ,
19
- id : btoa ( `app_collection:${ other_uid } :2361831622:66` ) ,
20
- } ) ;
21
-
22
- let f = new URLSearchParams ( ) ;
23
- f . append ( "__user" , uid ) ;
24
- f . append ( "__a" , 1 ) ;
25
- f . append ( "dpr" , 1 ) ;
26
- f . append ( "fb_dtsg" , dtsg ) ;
27
- f . append ( "fb_api_caller_class" , "RelayModern" ) ;
28
- f . append (
29
- "fb_api_req_friendly_name" ,
30
- "ProfileCometAppCollectionGridRendererPaginationQuery"
31
- ) ;
32
- f . append ( "variables" , variables ) ;
33
- f . append ( "doc_id" , 5244211935648733 ) ;
34
-
35
- try {
36
- let res = await fetch ( "https://www.facebook.com/api/graphql/" , {
37
- method : "POST" ,
38
- body : f ,
39
- } ) ;
40
-
41
- let json = await res . json ( ) ;
42
- let { pageItems } = json . data . node ;
43
- return {
44
- nextCursor : pageItems . page_info . end_cursor ,
45
- groups : pageItems . edges . map ( ( e ) => ( {
46
- id : e . node . node ?. id || btoa ( e . node . id ) . split ( ":" ) . at ( - 1 ) ,
47
- title : e . node . title . text ,
48
- subTitle : e . node . subtitle_text . text ,
49
- url : e . node . url ,
50
- visibility : e . node . node . visibility ,
51
- image : e . node . image . uri ,
52
- membersCount : Number (
53
- (
54
- e . node . node . forum_member_profiles . formatted_count_text ||
55
- e . node . node . group_member_profiles . formatted_count_text
56
- ) . match ( / \d + / ) ?. [ 0 ] ?? 1
57
- ) ,
58
- cursor : e . cursor ,
59
- } ) ) ,
60
- } ;
61
- } catch ( e ) {
62
- console . log ( "ERROR fetch page" , e ) ;
63
- return {
64
- nextCursor : null ,
65
- groups : [ ] ,
66
- } ;
67
- }
68
- }
69
-
70
- async function searchAllGroupForOther (
71
- other_uid ,
72
- uid ,
73
- dtsg ,
74
- pageFetchedCallback
75
- ) {
76
- let cursor = "" ;
77
- let allGroups = [ ] ;
78
- while ( true ) {
79
- let { nextCursor, groups } = await searchGroupForOther (
80
- other_uid ,
81
- cursor ,
82
- uid ,
83
- dtsg
84
- ) ;
85
- if ( ! nextCursor ) {
86
- break ;
87
- }
88
- cursor = nextCursor ;
89
- allGroups = allGroups . concat ( groups ) ;
90
- await pageFetchedCallback ?. ( groups , allGroups ) ;
91
- }
92
- return allGroups ;
93
- }
94
-
95
15
let url = prompt ( "Nhập link facebook bạn bè: " ) ;
96
16
if ( url == null ) return ;
97
17
98
18
let { setLoadingText, closeLoading } = showLoading ( "Đang chuẩn bị..." ) ;
99
19
try {
100
- let { getUidFromUrl, getYourUserId, getFbdtsg } =
20
+ let { getUidFromUrl, getYourUserId, getFbdtsg, searchAllGroupForOther } =
101
21
UsefulScriptGlobalPageContext . Facebook ;
102
22
103
23
setLoadingText ( "Đang lấy uid, token..." ) ;
0 commit comments