/
bookmarks.js
530 lines (494 loc) · 19.3 KB
/
bookmarks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
// (MỚI) CẬP NHẬT CÁCH LẤY TOKEN MỚI - DÙNG WEB HỖ TRỢ
// https://ffb.vn/get-token
// LƯU Ý: ĐÂY LÀ WEB BÊN THỨ 3, SỬ DỤNG COOKIES ĐỂ LẤY TOKEN, MÌNH KHÔNG ĐẢM BẢO COOKIES CỦA BẠN ĐƯỢC AN TOÀN :)
// (CŨ) CẬP NHẬT CÁCH LẤY TOKEN FULL QUYỀN (01/03/2022):
// (20/8/2022) TOKEN NÀY KHÔNG CÒN FULL QUYỀN
javascript: (function () {
if (window.location.host !== "business.facebook.com") {
alert(
"Bookmark này chỉ hoạt động trên trang https://business.facebook.com/content_management/\nBạn hãy vào trang web trên và ấn lại bookmark để lấy token an toàn nhé."
);
window.open("https://business.facebook.com/content_management/");
return;
}
try {
const accessToken =
"EAAG" + /(?<=EAAG)(.*?)(?=\")/.exec(document.body.textContent)[0];
window.prompt("Access Token của bạn:", accessToken);
} catch (e) {
alert("LỖI: " + e.message);
}
})();
// (CŨ) QUAN TRỌNG: LẤY ACCESS TOKEN FULL QUYỀN, CÁC BẠN LÀM THEO HƯỚNG DẪN TRONG LINK SAU:
// https://alotoi.com/get-token-full-quyen/#Cach_1_Get_token_qua_ung_dung_Instagram
// 2 CÁI LẤY TOKEN PHÍA DƯỚI HIỆN ĐANG LỖI NÊN MỌI NGƯỜI ĐỪNG XÀI NHÉ.
// (CŨ) Lấy access token (không thời hạn, full quyền, user token) - Chỉ gọi được hàm này trong trang m.facebook.com
// - HIỆN ĐANG LỖI, FB KHÔNG CÒN CÔNG KHAI ACCESSTOKEN NỮA, NÊN HÀM NÀY SẼ KO LẤY ĐC ACCESSTOKEN
javascript: (function () {
if (window.location.host !== "m.facebook.com") {
alert(
"Bookmark này chỉ hoạt động trên trang m.facebook.com\nBạn hãy vào trang m.facebook.com và ấn lại bookmark để lấy token an toàn nhé."
);
window.open("https://m.facebook.com");
return;
}
console.log("Đang lấy token ...");
fetch("https://m.facebook.com/composer/ocelot/async_loader/?publisher=feed")
.then((response) => response.text())
.then((text) => {
if ("<" == text[0]) {
alert("Chưa đăng nhập. Bạn cần đăng nhập fb thì mới lấy được token.");
} else {
const data = {
token: /(?<=accessToken\\":\\")(.*?)(?=\\")/.exec(text)[0],
fb_dtsg: /(?<=fb_dtsg\\" value=\\")(.*?)(?=\\")/.exec(text)[0],
id: /(?<=USER_ID\\":\\").*?(?=\\",\\")/gm.exec(text)[0],
};
console.log(data);
window.prompt("Access Token của bạn:", data.token);
}
});
})();
// (CŨ) Lấy access token (có thời hạn. app token) Dùng cho www.facebook.com
// - HIỆN ĐANG LỖI: BOOKMARK này không toàn quyền, theo vài bạn test thử thì chức năng tải hình/video trên tường đối tượng không chạy được
// (20/8/2022) TOKEN NÀY CÓ THỂ SỬ DỤNG ĐƯỢC MỘT VÀI CHỨC NĂNG
javascript: (function () {
if (window.location.host !== "www.facebook.com") {
alert(
"Bookmark này chỉ dùng được trong trang www.facebook.com.\nBạn hãy vào trang www.facebook.com và ấn lại bookmark để lấy token nhé."
);
window.open("https://www.facebook.com");
return;
}
var uid = /(?<=c_user=)(\d+)/.exec(document.cookie)[0],
dtsg =
require("DTSGInitialData").token ||
document.querySelector('[name="fb_dtsg"]').value,
http = new XMLHttpRequest(),
url = "//www.facebook.com/v1.0/dialog/oauth/confirm",
params =
"fb_dtsg=" +
dtsg +
"&app_id=124024574287414&redirect_uri=fbconnect%3A%2F%2Fsuccess&display=page&access_token=&from_post=1&return_format=access_token&domain=&sso_device=ios&_CONFIRM=1&_user=" +
uid;
http.open("POST", url, !0),
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"),
(http.onreadystatechange = function () {
if (4 == http.readyState && 200 == http.status) {
var a = http.responseText.match(/(?<=access_token=)(.*?)(?=\&)/);
console.log(http.responseText);
if (a && a[0]) {
prompt("Token", a[0]);
} else {
alert("Failed to Get Access Token.");
}
}
}),
http.send(params);
})();
// Lấy timeline album id của page - khi đang trong trang của page fb. Ví dụ: https://www.facebook.com/profile.php?id=100057998562930
javascript: (function () {
const page_name = document.title;
const list_a = document.querySelectorAll("a");
for (let a of Array.from(list_a)) {
const posts_screen = /(?<=set\=a\.)(.\d+?)(?=\&__cft__)/.exec(a.href);
if (posts_screen && posts_screen[0]) {
window.prompt(`Timeline Album ID của ${page_name}:`, posts_screen[0]) &&
window.open("https://www.facebook.com/" + posts_screen[0]);
return;
}
}
window.prompt(
"Không tìm thấy TIMELINE ALBUM trong trang web!\nBạn có đang ở đúng trang web của 1 Page fb chưa?\nThử kéo xuống tới bài post nào có kèm hình ảnh rồi ấn lại bookmark nhé\nTrang web Ví dụ: ",
"https://www.facebook.com/profile.php?id=100057998562930"
);
})();
// 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
javascript: (function () {
const user_name = document.title;
const found = (check) => {
if (check && check[0]) {
window.prompt(`USER ID của ${user_name}:`, check[0]);
return true;
}
return false;
};
if (found(/(?<=\/profile\.php\?id=)(.\d+?)($|(?=&))/.exec(location.href)))
return;
const list_a = document.querySelectorAll("a");
for (let a of Array.from(list_a)) {
if (found(/(?<=set\=(pb|picfp|ecnf|pob)\.)(.\d+?)($|(?=\.))/.exec(a.href)))
return;
}
if (
found(
/(?<=\"user\"\:\{\"id\"\:\")(.\d+?)(?=\")/.exec(document.body.innerHTML)
)
)
return;
window.prompt(
"Không tìm thấy USER ID nào trong trang web!\nBạn có đang ở đúng trang profile chưa?\nTrang web Ví dụ: ",
"https://www.facebook.com/callchoulnhe"
);
})();
// Lấy UID từ url của user fb. Ví dụ: https://www.facebook.com/99.hoangtran
javascript: (function () {
const getUid = async (url) => {
var response = await fetch(url);
if (response.status == 200) {
var text = await response.text();
let uid = /(?<=\"userID\"\:\")(.\d+?)(?=\")/.exec(text);
if (uid?.length) {
return uid[0];
}
}
return null;
};
const url = window.prompt("Nhập url của user fb:", "");
if (url)
getUid(url)
.then((uid) => {
if (uid) window.prompt(`UID của user ${url}:`, uid);
else alert("Không tìm thấy uid của user!");
})
.catch((err) => alert("Lỗi: " + err.message));
})();
// Lấy group id - trường hợp url của group hiển thị tên chứ ko hiển thị id. Ví dụ: https://www.facebook.com/groups/j2team.community.girls
javascript: (function () {
const group_name = document.title;
const found = (check) => {
if (check && check[0]) {
window.prompt(`GROUP ID của ${group_name}:`, check[0]);
return true;
}
return false;
};
if (found(/(?<=\/groups\/)(.\d+?)($|(?=\/)|(?=&))/.exec(location.href)))
return;
const list_a = document.querySelectorAll("a");
for (let a of Array.from(list_a)) {
if (found(/(?<=\/groups\/)(.\d+?)(?=\/user\/)/.exec(a.href))) return;
}
window.prompt(
"Không tìm thấy GROUP ID nào trong trang web!\nBạn có đang ở đúng trang group chưa?\nTrang web Ví dụ:",
"https://www.facebook.com/groups/j2team.community.girls"
);
})();
// Lấy album id - khi đang xem 1 album, ví dụ https://www.facebook.com/media/set/?vanity=ColourfulSpace&set=a.945632905514659
javascript: (function () {
const list_a = document.querySelectorAll("a");
for (let a of [location, ...Array.from(list_a)]) {
const page_album_id = /(?<=\/photos\/a\.)(.\d+?)(?=\/)/.exec(a.href);
if (page_album_id && page_album_id[0]) {
window.prompt("PAGE ALBUM ID:", page_album_id[0]);
return;
}
const group_album_id = /(?<=set\=oa\.)(.\d+?)($|(?=&))/.exec(a.href);
if (group_album_id && group_album_id[0]) {
window.prompt("GROUP ALBUM ID:", group_album_id[0]);
return;
}
const user_album_id = /(?<=set\=a\.)(.\d+?)($|(?=&))/.exec(a.href);
if (user_album_id && user_album_id[0]) {
window.prompt("USER ALBUM ID:", user_album_id[0]);
return;
}
}
window.prompt(
"Không tìm thấy ALBUM ID nào trong trang web!\nBạn có đang ở đúng trang album chưa?\nTrang web Ví dụ:",
"https://www.facebook.com/media/set/?vanity=ColourfulSpace&set=a.945632905514659"
);
})();
// Lấy tất cả album id có trong trang web - Khi đang xem 1 danh sách album của user/group/page
javascript: (function () {
const list_a = document.querySelectorAll("a");
const list_id = [];
for (let a of [location, ...Array.from(list_a)]) {
const page_album_id = /(?<=\/photos\/a\.)(.\d+?)(?=\/)/.exec(a.href);
if (page_album_id && page_album_id[0]) {
list_id.push(page_album_id[0]);
}
const group_album_id = /(?<=set\=oa\.)(.\d+?)($|(?=&))/.exec(a.href);
if (group_album_id && group_album_id[0]) {
list_id.push(group_album_id[0]);
}
const user_album_id = /(?<=set\=a\.)(.\d+?)($|(?=&))/.exec(a.href);
if (user_album_id && user_album_id[0]) {
list_id.push(user_album_id[0]);
}
}
if (list_id.length)
window.prompt(
`Tìm thấy ${list_id.length} album id trong trang web và trên url.`,
list_id.join(", ")
);
else
window.prompt(
"Không tìm thấy ALBUM ID nào trong trang web!\nBạn có đang ở đúng trang album chưa?\nTrang web Ví dụ:",
"https://www.facebook.com/media/set/?vanity=ColourfulSpace&set=a.945632905514659"
);
})();
// Lấy page id - khi đang trong trang của page fb. Ví dụ: https://www.facebook.com/ColourfulSpace
javascript: (function () {
const page_name = document.title;
const found = (check) => {
if (check && check[0]) {
window.prompt(`PAGE ID của ${page_name}:`, check[0]);
return true;
}
return false;
};
if (found(/(?<=\"pageID\"\:\")(.*?)(?=\")/.exec(document.body.innerHTML)))
return;
if (found(/(?<=facebook\.com\/)(.*?)($|(?=\/)|(?=&))/.exec(location.href)))
return;
window.prompt(
"Không tìm thấy PAGE ID nào trong url!\nBạn có đang ở đúng trang page fb chưa?\nTrang web Ví dụ:",
"https://www.facebook.com/ColourfulSpace"
);
})();
// Lấy tất cả uid từ trang facebook search bạn bè
// Ví dụ: https://www.facebook.com/search/people/?q=*a&epa=FILTERS&filters=eyJmcmllbmRzIjoie1wibmFtZVwiOlwidXNlcnNfZnJpZW5kc19vZl9wZW9wbGVcIixcImFyZ3NcIjpcIjEwMDA2NDI2NzYzMjI0MlwifSJ9
// Link trên được tạo từ web: https://sowsearch.info/
javascript: (() => {
const getUid = async (url) => {
var response = await fetch(url);
if (response.status == 200) {
var text = await response.text();
let uid = /(?<=\"userID\"\:\")(.\d+?)(?=\")/.exec(text);
if (uid?.length) {
return uid[0];
}
}
return null;
};
const main = async () => {
alert("Đang lấy thông tin uid, mở console để xem tiến trình...");
let list_a = Array.from(
document.querySelectorAll(".sjgh65i0 a[role='presentation']")
);
let uids = [];
for (let a of list_a) {
let l = a.href;
let uid = l.split("profile.php?id=")[1];
if (uid) {
uids.push(uid);
console.log(uid);
continue;
}
let name = l.split("facebook.com/")[1];
uid = await getUid(l);
uids.push(uid);
console.log(name, uid);
}
console.log(uids);
window.prompt("Tất cả UID: ", uids.join("\n"));
};
main();
})();
// Scroll trang web xuống cuối cùng và chờ cho load thêm, tiếp tục scroll, cho tới khi ko còn dữ liệu mới
javascript: (() => {
let height = () => document.body.scrollHeight;
let down = () =>
window.scrollTo({ left: 0, top: height(), behavior: "smooth" });
let sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
(async () => {
let lastScroll = {
time: Date.now(),
top: 0,
};
while (true) {
down();
let currentHeight = height();
if (currentHeight != lastScroll.top) {
lastScroll.top = currentHeight;
lastScroll.time = Date.now();
} else if (Date.now() - lastScroll.time > 5000) {
break;
}
await sleep(100);
}
console.log("end");
})();
})();
// =====================================================================
// =============================== BONUS ===============================
// =====================================================================
// Đăng nhập fb bằng access token: https://tienich.xyz/code-dang-nhap-facebook-bang-access-token-2018/
// Lấy tất cả video id có trong trang
javascript: (function () {
const list_a = document.querySelectorAll("a");
const list_id = [];
for (let a of Array.from(list_a)) {
const check = /(?<=\/videos\/)(.\d+?)($|(?=\/))/.exec(a.href);
if (check && check[0]) {
list_id.push(check[0]);
}
}
if (list_id.length)
window.prompt(`Tìm thấy ${list_id.length} video id: `, list_id.join(", "));
else
window.prompt(
"Không tìm thấy video id nào trong trang web!\nBạn có ở đúng trang video chưa?\nTrang web ví dụ:",
"https://www.facebook.com/watch/?ref=tab"
);
})();
// Tải video bằng video id
javascript: (function () {
const video_url = window.prompt("Nhập video id:");
if (video_url) {
window.open("https://mbasic.facebook.com/watch/?v=" + video_url);
}
})();
// Tải video đang xem - khi đang trong trang web video, dạng: https://www.facebook.com/watch?v=254222479732213
// Nếu bạn muốn tải HD thì dùng snapsave: https://snapsave.app/vn
javascript: (function () {
const found = (check) => {
if (check && check[0]) {
const url = window.location.href.replace(
"www.facebook.com",
"mbasic.facebook.com"
);
window.open(url);
return true;
}
return false;
};
if (found(/(?<=\/watch\?v\=)(.\d+?)($|(?=\/))/.exec(location.href))) return;
if (found(/(?<=videos\/)(.\d+?)($|(?=\/))/.exec(location.href))) return;
window.prompt(
"Không tìm thấy id của video trên url!\nBạn có ở đúng trang xem video chưa?\nTrang web ví dụ:",
"https://www.facebook.com/watch?v=254222479732213"
);
})();
// Chia sẻ trang web đang xem lên facebook
javascript: !(function () {
var title = document.title;
window.open(
"https://www.facebook.com/sharer/sharer.php?u=" +
document.URL +
"&t=" +
title,
title,
"menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600"
);
})();
// Lấy tất cả id của member trong group
// source: https://gist.github.com/thinhbuzz/d8ba04c66f69dc78265b9a9ce5a118c0?fbclid=IwAR37QPDL1zlGWIv_pPq4UydYbFcQKlw7Dio-dP-jtztSJODGPD1RoIGFzZU#file-group-uuid-js-L1
javascript: (function () {
(async () => {
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function getId() {
try {
const props = require("CometRouteStore").getRoute(location.pathname)
?.rootView.props;
const result = require("GroupsCometMembersPageNewMembersSectionRefetchQuery.graphql");
if (!props || !result) {
throw new Error("Không phải profile");
}
return {
groupID: props.groupID,
docId: result.params.id,
method: "ProfileCometAppCollectionPhotosRendererPaginationQuery",
};
} catch (e) {
console.error(e);
}
return { groupID: null, docId: null, method: null };
}
function prepareData({ dtsg: fb_dtsg, groupID, docId: doc_id, method }) {
const variables = `{"count":10,"cursor":__CURSOR__,"groupID":"${groupID}","recruitingGroupFilterNonCompliant":false,"scale":1,"id":"${groupID}"}`;
const data = {
doc_id,
fb_dtsg,
variables,
fb_api_caller_class: "RelayModern",
fb_api_req_friendly_name: method,
};
const formBody = [];
for (const property in data) {
const encodedKey = encodeURIComponent(property);
const encodedValue = encodeURIComponent(data[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
return formBody.join("&");
}
async function getLinks(method, formBody) {
return fetch("https://www.facebook.com/api/graphql/", {
headers: {
"content-type": "application/x-www-form-urlencoded",
"user-agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
"x-fb-friendly-name": method,
},
body: formBody,
method: "POST",
})
.then((response) => response.json())
.then(({ data }) => {
console.log(data);
return {
users: data.node.new_members.edges.map((item) => {
return {
id: item.node.id,
name: item.node.name,
url: item.node.url,
};
}),
page: data.node.new_members.page_info,
};
});
}
window.scrollTo(0, document.body.scrollHeight);
await sleep(1000);
let cursor = null;
const limit = +prompt("Số UUID tối đa sẽ lấy", "999999") || 999999;
if (!limit) return;
const { groupID, docId, method } = getId();
const dtsg = require("DTSG").getCachedToken
? require("DTSG").getCachedToken()
: require("DTSG").getToken();
window.allItems = [];
if (!groupID || !docId) {
throw new Error("Không tìm thấy token");
}
alert(
"Quá trình lấy uuid sẽ diễn ra trong console.\nNhấn F12 để mở console"
);
console.log("%cBắt đầu lấy link", "color: green;");
const formBody = prepareData({ dtsg, groupID, docId, method });
while (true) {
let { users, page } = await getLinks(
method,
formBody.replace("__CURSOR__", cursor ? `"${cursor}"` : "null")
);
window.allItems.push(...users);
console.log(
"%cĐã lấy được %d uuid",
"color: green;",
window.allItems.length
);
if (!page.has_next_page) {
break;
}
cursor = page.end_cursor;
if (window.allItems.length >= limit) {
break;
}
}
console.log(window.allItems);
const styles = ["color: green", "font-size: 20px", "padding: 10px"].join(
";"
);
console.log(
"%cĐã lấy thành công %d uuid, gõ copy(window.allItems.map(({ id }) => id).join('\\n')) để sao chép uuid vào clipboard",
styles,
window.allItems.length
);
})().catch((error) => {
console.log(error);
alert("Vui lòng tải lại trang và thử lại.");
});
})();