feat: add script to extract and log unique Facebook group names and IDs from DOM elements

This commit is contained in:
Victor Phan
2026-07-23 12:25:01 +07:00
parent 2bd6cfef55
commit 1f2248351d
+6 -5
View File
@@ -3,13 +3,14 @@ let links = document.querySelectorAll('a[href*="/groups/"]');
links.forEach(a => { links.forEach(a => {
let url = a.href.split('?')[0]; let url = a.href.split('?')[0];
let name = a.innerText.trim(); let name = a.innerText.trim();
// Lọc ra các nhóm hợp lệ (có tên và đúng định dạng)
if(name && !name.includes("Joined") && url.includes("facebook.com/groups/")) { let match = url.match(/\/groups\/([^\/]+)\/?$/);
let groupId = url.split('/groups/')[1].replace('/', ''); if(name && !name.includes("Joined") && match) {
let groupId = match[1];
groups.push(name + "\t" + groupId); groups.push(name + "\t" + groupId);
} }
}); });
// Lọc trùng lặp và in ra màn hình
let uniqueGroups = [...new Set(groups)]; let uniqueGroups = [...new Set(groups)];
console.log("TÊN NHÓM \t GROUP ID/LINK"); console.log("TÊN NHÓM \t GROUP ID (Hoặc Tên Tùy Chỉnh)");
console.log(uniqueGroups.join('\n')); console.log(uniqueGroups.join('\n'));