/**
* Script Đã Hoàn Chỉnh (Version 6 - Thêm chữ ký MuaVia.Vn)
* - Sử dụng prompt() để nhập ID BM cần check.
* - Sử dụng lại hàm require() cho DTSG và USER_ID.
* - Sử dụng đường dẫn trích xuất sâu: data.payload.businessAdmins.__imm.value
* - Thêm dòng chữ "Mua Clone tại MuaVia.Vn" vào khung kết quả.
*/
// 1. LẤY ID BM CẦN CHECK TỪ NGƯỜI DÙNG
var ID_BUSINESS = prompt("Vui lòng nhập ID Business Manager (BM) bạn muốn kiểm tra:");
if (!ID_BUSINESS) {
alert("Không có ID BM được nhập. Hủy bỏ quá trình.");
throw new Error("ID Business Manager không được cung cấp.");
}
// 2. LẤY TOKEN VÀ USER ID CỦA NGƯỜI DÙNG HIỆN TẠI (DỄ GẶP LỖI HƠN)
try {
var TOKEN_DTSG = require("DTSGInitialData").token;
var ID_USER = require("CurrentUserInitialData").USER_ID;
} catch (e) {
console.error("Lỗi khi lấy TOKEN_DTSG hoặc ID_USER. Vui lòng thử lại hoặc sử dụng phiên bản code hardcode.", e);
alert("Lỗi: Không thể lấy token bảo mật. Kiểm tra Console.");
throw new Error("Không thể lấy token bảo mật.");
}
console.log(`Đang thực hiện yêu cầu Fetch cho BM ID: ${ID_BUSINESS}...`);
fetch(`https://business.facebook.com/confirm_business/assets/?business_id=${ID_BUSINESS}&session_id=2e588b28-ebe5-43ce-b6fb-444a47b24bfc&see_all_assets=false`, {
"headers": {
"accept": "*/*",
"accept-language": "en-US,en;q=0.9,vi;q=0.8",
"content-type": "application/x-www-form-urlencoded",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-asbd-id": "129477",
"x-fb-lsd": "koedxGXJ0_horyP7jAiqhN"
},
"referrer": `https://business.facebook.com/confirm_business/?business_id=${ID_BUSINESS}`,
"referrerPolicy": "origin-when-cross-origin",
// SỬ DỤNG CÁC GIÁ TRỊ TỰ ĐỘNG LẤY TRONG BODY
"body": `__aaid=0&__bid=${ID_BUSINESS}&__user=${ID_USER}&__a=1&__req=1&__hs=20013.BP%3ADEFAULT.2.0..0.0&dpr=1&__ccg=EXCELLENT&__rev=1017428696&__s=09a35x%3A6mvexo%3A8qigz8&__hsi=7426736898798639095&__dyn=7xeUmwkHg7ebwKBAg5S1Dxu13wqovzEdEc8uw9-dwJw5ux60Vo1upE4W0OE2WxO0FE662y0um4o5-0ha2l0Fwqo5W0_Ugw9K0OU3mwkE5G0zE5W0HUvw6ixy0gq0Lo6-1Fw63w7zwtU5K0UE&__csr=&fb_dtsg=${TOKEN_DTSG}&jazoest=25201&lsd=koedxGXJ0_horyP7jAiqhN&__spin_r=1017428696&__spin_b=trunk&__spin_t=1729171932&__jssesw=1`,
"method": "POST",
"mode": "cors",
"credentials": "include"
})
.then(e => e.text())
.then(text => {
// 1. Xử lý tiền tố bảo mật "for (;;);"
let jsonString = text.replace(/^for\s*\(;;\);\s*/, '');
if (!jsonString.startsWith('{') && !jsonString.startsWith('[')) {
throw new Error("Phản hồi không chứa JSON hợp lệ sau khi làm sạch.");
}
// 2. Phân tích JSON
const data = JSON.parse(jsonString);
// 🌟 LOGIC TRÍCH XUẤT ĐƯỜNG DẪN SÂU: data.payload.businessAdmins.__imm.value 🌟
let usersData = [];
try {
if (data.payload && data.payload.businessAdmins &&
data.payload.businessAdmins.__imm &&
Array.isArray(data.payload.businessAdmins.__imm.value)) {
usersData = data.payload.businessAdmins.__imm.value;
}
} catch (e) {
console.error("Lỗi khi truy cập đường dẫn JSON:", e);
}
// -----------------------------------------------------
if (usersData.length > 0) {
// Kiểm tra nếu box đã tồn tại thì xóa trước
const existingBox = document.getElementById('facebook-result-box');
if (existingBox) existingBox.remove();
// 3. Tạo phần tử CONTAINER (Hộp thoại)
const resultBox = document.createElement('div');
resultBox.id = 'facebook-result-box';
resultBox.style.cssText = `
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #ffffff;
border: 2px solid #4267B2;
padding: 20px;
z-index: 99999;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
max-height: 80vh;
overflow-y: auto;
color: black;
font-family: Arial, sans-serif;
border-radius: 10px;
min-width: 300px;
`;
// 4. Tạo nội dung HTML chi tiết
let htmlContent = '<h2 style="margin-top:0; color:#4267B2;">Kết Quả Trích Xuất Quản Trị Viên BM</h2><hr style="border-color:#ccc;">';
usersData.forEach((user, index) => {
htmlContent += `
<div style="margin-bottom: 10px; border-bottom: 1px dashed #eee; padding-bottom: 5px;">
<strong>${index + 1}. Tên:</strong> ${user.name} <br>
<strong> ID:</strong> ${user.id}
</div>
`;
});
// 🌟🌟 THÊM DÒNG CHỮ THEO YÊU CẦU 🌟🌟
htmlContent += `<p style="text-align: center; margin-top: 15px; font-weight: bold; color: #f44336; border-top: 1px solid #ccc; padding-top: 10px;">
Mua Clone tại MuaVia.Vn
</p>`;
// 5. Thêm nút đóng
htmlContent += `<button onclick="this.closest('#facebook-result-box').remove()"
style="display: block; width: 100%; padding: 10px; background: #f44336; color: white; font-weight: bold; border: none; cursor: pointer; border-radius: 4px; margin-top: 15px;">
Đóng (Close)
</button>`;
resultBox.innerHTML = htmlContent;
// 6. Chèn vào trang
document.body.appendChild(resultBox);
console.log(`✅ Thành công: Đã hiển thị ${usersData.length} Quản trị viên BM ra hộp thoại.`);
} else {
// Nếu usersData rỗng
console.log("Phản hồi Data (để debug):", data);
alert(`Thành công nhưng không tìm thấy dữ liệu Quản trị viên cho BM ID: ${ID_BUSINESS}. Vui lòng kiểm tra Console.`);
}
})
.catch(error => {
console.error("❌ Lỗi trong quá trình xử lý:", error);
alert("Đã xảy ra lỗi khi lấy hoặc phân tích dữ liệu. Vui lòng kiểm tra Console (F12) để xem chi tiết.");
});
Nhận xét
Đăng nhận xét