Skip to content

Commit 66b9b0b

Browse files
committed
search group for other
1 parent 628d318 commit 66b9b0b

File tree

5 files changed

+137
-1
lines changed

5 files changed

+137
-1
lines changed

popup/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
viewScriptSource,
2727
} from "./helpers/utils.js";
2828
import { refreshSpecialTabs, getAllTabs } from "./tabs.js";
29-
import _ from "../md/exportScriptsToMd.js";
29+
// import _ from "../md/exportScriptsToMd.js";
3030

3131
const tabDiv = document.querySelector("div.tab");
3232
const contentDiv = document.querySelector("div.content");

popup/tabs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const tabs = [
2828
{
2929
...CATEGORY.search,
3030
scripts: [
31+
s._test,
3132
s.search_userscript,
3233
s.whatFont,
3334
s.similarWeb,

scripts/_test.js

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import { showLoading } from "./helpers/utils.js";
2+
3+
export default {
4+
icon: "",
5+
name: {
6+
en: "Test",
7+
vi: "Test",
8+
},
9+
description: {
10+
en: "",
11+
vi: "",
12+
},
13+
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+
let url = prompt("Nhập link facebook bạn bè: ");
96+
if (url == null) return;
97+
98+
let { setLoadingText, closeLoading } = showLoading("Đang chuẩn bị...");
99+
try {
100+
let { getUidFromUrl, getYourUserId, getFbdtsg } =
101+
UsefulScriptGlobalPageContext.Facebook;
102+
103+
setLoadingText("Đang lấy uid, token...");
104+
let other_uid = await getUidFromUrl(url);
105+
let uid = await getYourUserId();
106+
let dtsg = await getFbdtsg();
107+
108+
setLoadingText("Đang tải thông tin group...");
109+
let allGroups = await searchAllGroupForOther(
110+
other_uid,
111+
uid,
112+
dtsg,
113+
(groups, all) => {
114+
setLoadingText(
115+
"Đang tải thông tin group...\nTải được " + all.length + " group."
116+
);
117+
}
118+
);
119+
console.log(allGroups);
120+
} catch (e) {
121+
alert("ERROR: " + e);
122+
} finally {
123+
closeLoading();
124+
}
125+
},
126+
};

scripts/fb_whoIsTyping.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
overflow: auto;
77
background-color: #fff;
88
border-radius: 3px;
9+
z-index: 99999;
910
}
1011

1112
#ufs-who-is-typing.collapsed .ufs-noti-item {
1213
display: none;
1314
}
1415

16+
#ufs-who-is-typing .ufs-header {
17+
position: sticky;
18+
top: 0;
19+
z-index: 2;
20+
}
21+
1522
#ufs-who-is-typing .ufs-header button {
1623
float: right;
1724
display: inline-block;

scripts/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { addBadge, BADGES } from "./helpers/badge.js";
22

3+
import _test from "./_test.js";
34
import fb_toggleLight from "./fb_toggleLight.js";
45
import fb_getTokenBusinessStudio from "./fb_getTokenBusinessStudio.js";
56
import fb_getTokenFacebook from "./fb_getTokenFacebook.js";
@@ -165,6 +166,7 @@ import fb_messengerCount from "./fb_messengerCount.js";
165166

166167
// inject badges
167168
const allScripts = {
169+
_test: _test,
168170
fb_toggleLight: fb_toggleLight,
169171
fb_getTokenBusinessStudio: addBadge(fb_getTokenBusinessStudio, BADGES.hot),
170172
fb_getTokenFacebook: addBadge(fb_getTokenFacebook, BADGES.hot),

0 commit comments

Comments
 (0)