Skip to content

Commit d38433d

Browse files
committed
update
1 parent 68770bf commit d38433d

File tree

10 files changed

+63
-116
lines changed

10 files changed

+63
-116
lines changed

popup/tabs.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ const tabs = [
123123
s.fb_getPageId,
124124
s.fb_getGroupId,
125125
s.fb_getAlbumId,
126-
s.fb_getTimelineAlbumId,
127-
s.fb_getAllVideoId,
128126
s.fb_getAllAlbumId,
129127
s.fb_getUidFromUrl,
130128
s.fb_getAllUidFromFbSearch,

scripts/content-scripts/scripts/ufs_global_webpage_context.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,30 @@ const UsefulScriptGlobalPageContext = {
176176
decodeArrId(arrId) {
177177
return arrId[0] * 4294967296 + arrId[1];
178178
},
179+
getUidFromUrl: async (url) => {
180+
let methods = [
181+
() => require("CometRouteStore").getRoute(url).rootView.props.userID,
182+
async () => {
183+
var response = await fetch(url);
184+
if (response.status == 200) {
185+
var text = await response.text();
186+
let uid = /(?<=\"userID\"\:\")(.\d+?)(?=\")/.exec(text);
187+
if (uid?.length) {
188+
return uid[0];
189+
}
190+
}
191+
return null;
192+
},
193+
];
194+
195+
for (let m of methods) {
196+
try {
197+
let uid = await m();
198+
if (uid) return uid;
199+
} catch (e) {}
200+
}
201+
return null;
202+
},
179203
getStoryBucketIdFromURL(url) {
180204
return url.match(/stories\/(\d+)\//)?.[1];
181205
},
@@ -188,6 +212,7 @@ const UsefulScriptGlobalPageContext = {
188212
getFbdtsg() {
189213
let methods = [
190214
() => require("DTSGInitData").token,
215+
() => require("DTSG").getToken(),
191216
() => {
192217
const regex = /"DTSGInitialData",\[],{"token":"(.+?)"/gm;
193218
const resp = regex.exec(document.documentElement.innerHTML);
@@ -200,9 +225,9 @@ const UsefulScriptGlobalPageContext = {
200225
return m();
201226
} catch (e) {}
202227
}
203-
alert("Cannot get your Fb_dtsg");
228+
return null;
204229
},
205-
getUserId() {
230+
getYourUserId() {
206231
let methods = [
207232
() => require("CurrentUserInitialData").USER_ID,
208233
() => require("RelayAPIConfigDefaults").actorID,
@@ -218,7 +243,7 @@ const UsefulScriptGlobalPageContext = {
218243
return m();
219244
} catch (e) {}
220245
}
221-
alert("Cannot get your UID");
246+
return null;
222247
},
223248

224249
// Source: https://pastebin.com/CNvUxpfc

scripts/fb_getAllUidFromFriendsPage.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,40 @@ export default {
1414
// Ví dụ: https://www.facebook.com/search/people/?q=*a&epa=FILTERS&filters=eyJmcmllbmRzIjoie1wibmFtZVwiOlwidXNlcnNfZnJpZW5kc19vZl9wZW9wbGVcIixcImFyZ3NcIjpcIjEwMDA2NDI2NzYzMjI0MlwifSJ9
1515
// Link trên được tạo từ web: https://sowsearch.info/
1616

17-
const _getUidFromUrl = async (url) => {
18-
var response = await fetch(url);
19-
if (response.status == 200) {
20-
var text = await response.text();
21-
let uid = /(?<=\"userID\"\:\")(.\d+?)(?=\")/.exec(text);
22-
if (uid?.length) {
23-
return uid[0];
24-
}
25-
}
26-
return null;
27-
};
28-
alert("Đang lấy thông tin uid, mở console để xem tiến trình...");
2917
let list_a = Array.from(
3018
document.querySelectorAll(".sjgh65i0 a[role='presentation']")
3119
);
3220

21+
if (!list_a.length) {
22+
return prompt(
23+
"Không tìm thấy thông tin, bạn đã ở đúng trang tìm kiếm bạn bè fb chưa?" +
24+
"\nTrang web ví dụ:",
25+
"https://www.facebook.com/search/people/?q=*a"
26+
);
27+
}
28+
29+
alert("Đang lấy thông tin uid, mở console để xem tiến trình...");
3330
let uids = [];
3431
for (let a of list_a) {
35-
let l = a.href;
32+
try {
33+
let l = a.href;
34+
35+
let uid = l.split("profile.php?id=")[1];
36+
if (uid) {
37+
uids.push(uid);
38+
console.log(uid);
39+
continue;
40+
}
3641

37-
let uid = l.split("profile.php?id=")[1];
38-
if (uid) {
42+
let name = l.split("facebook.com/")[1];
43+
uid = await UsefulScriptGlobalPageContext.Facebook.getUidFromUrl(l);
3944
uids.push(uid);
40-
console.log(uid);
41-
continue;
45+
console.log(name, uid);
46+
} catch (e) {
47+
console.log("Lỗi khi lấy thông tin của " + a, e);
4248
}
43-
44-
let name = l.split("facebook.com/")[1];
45-
uid = await _getUidFromUrl(l);
46-
uids.push(uid);
47-
console.log(name, uid);
4849
}
4950
console.log(uids);
5051
prompt("Tất cả UID: ", uids.join("\n"));
5152
},
5253
};
53-
54-
export async function getAllUidFromFriendsPage() {}

scripts/fb_getAllVideoId.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

scripts/fb_getTimelineAlbumId.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

scripts/fb_getUid.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ export default {
1010
},
1111
whiteList: ["https://www.facebook.com/*"],
1212

13-
onClick: function () {
13+
onClick: async function () {
1414
// Lấy user id (uid) - khi đang trong tường của người dùng muốn lấy user id. Ví dụ: https://www.facebook.com/callchoulnhe
1515

16-
const find = (r) => (r ? r[0] : 0);
16+
let uid = await UsefulScriptGlobalPageContext.Facebook.getUidFromUrl(
17+
location.href
18+
);
19+
if (uid) return prompt(`USER ID của ${document.title}:`, uid);
1720

18-
let uid =
21+
const find = (r) => (r ? r[0] : 0);
22+
uid =
1923
find(
2024
/(?<=\"userID\"\:\")(.\d+?)(?=\")/.exec(
2125
document.querySelector("html").textContent

scripts/fb_getUidFromUrl.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,16 @@ export default {
1010
vi: "Lấy id của facebook user từ URL truyền vào",
1111
},
1212

13-
onClickExtension: function () {
13+
onClick: function () {
1414
// Lấy UID từ url của user fb. Ví dụ: https://www.facebook.com/99.hoangtran
15-
16-
const _getUidFromUrl = async (url) => {
17-
var response = await fetch(url);
18-
if (response.status == 200) {
19-
var text = await response.text();
20-
let uid = /(?<=\"userID\"\:\")(.\d+?)(?=\")/.exec(text);
21-
if (uid?.length) {
22-
return uid[0];
23-
}
24-
}
25-
return null;
26-
};
2715
const url = prompt("Nhập url của user fb:", "");
2816
if (url) {
29-
const { closeLoading } = showLoading("Đang lấy UID của " + url);
30-
_getUidFromUrl(url)
17+
UsefulScriptGlobalPageContext.Facebook.getUidFromUrl(url)
3118
.then((uid) => {
3219
if (uid) prompt(`UID của user ${url}:`, uid);
3320
else alert("Không tìm thấy uid của user!");
3421
})
35-
.catch((err) => alert("Lỗi: " + err.message))
36-
.finally(closeLoading);
22+
.catch((err) => alert("Lỗi: " + err.message));
3723
}
3824
},
3925
};

scripts/fb_moreReactionStory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default {
3838
if (!!document.querySelector(".ufs-more-react-story")) return;
3939

4040
const fb_dtsg = UsefulScriptGlobalPageContext.Facebook.getFbdtsg();
41-
const user_id = UsefulScriptGlobalPageContext.Facebook.getUserId();
41+
const user_id = UsefulScriptGlobalPageContext.Facebook.getYourUserId();
4242

4343
/* HTML template
4444
<div class="ufs-more-react-story">

scripts/fb_whoIsTyping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default {
2424
utf8_str.startsWith("1") &&
2525
utf8_str.includes("updateTypingIndicator")
2626
) {
27-
console.log(utf8_str);
27+
// console.log(utf8_str);
2828
try {
2929
let isStartTyping = utf8_str.includes(",true)");
3030
let isStopTyping = utf8_str.includes(",false)");

scripts/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import fb_getUid from "./fb_getUid.js";
99
import fb_getPageId from "./fb_getPageId.js";
1010
import fb_getGroupId from "./fb_getGroupId.js";
1111
import fb_getAlbumId from "./fb_getAlbumId.js";
12-
import fb_getTimelineAlbumId from "./fb_getTimelineAlbumId.js";
13-
import fb_getAllVideoId from "./fb_getAllVideoId.js";
1412
import fb_getAllAlbumId from "./fb_getAllAlbumId.js";
1513
import fb_getUidFromUrl from "./fb_getUidFromUrl.js";
1614
import fb_getAllUidFromFbSearch from "./fb_getAllUidFromFbSearch.js";
@@ -174,8 +172,6 @@ const allScripts = {
174172
fb_getPageId: addBadge(fb_getPageId, BADGES.hot),
175173
fb_getGroupId: addBadge(fb_getGroupId, BADGES.hot),
176174
fb_getAlbumId: addBadge(fb_getAlbumId, BADGES.hot),
177-
fb_getTimelineAlbumId: addBadge(fb_getTimelineAlbumId, BADGES.hot),
178-
fb_getAllVideoId,
179175
fb_getAllAlbumId,
180176
fb_getUidFromUrl: addBadge(fb_getUidFromUrl, BADGES.hot),
181177
fb_getAllUidFromFbSearch,

0 commit comments

Comments
 (0)