KEMBAR78
BM Create Code New Update | PDF
0% found this document useful (0 votes)
255 views3 pages

BM Create Code New Update

The document is a JavaScript code snippet that creates a user interface for automatically generating five Facebook Business Managers. It includes functions to retrieve necessary tokens, generate random IDs, and handle the creation process through a GraphQL API call. The UI displays the creation status and results for each Business Manager created, along with error handling for potential issues during the process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
255 views3 pages

BM Create Code New Update

The document is a JavaScript code snippet that creates a user interface for automatically generating five Facebook Business Managers. It includes functions to retrieve necessary tokens, generate random IDs, and handle the creation process through a GraphQL API call. The UI displays the creation status and results for each Business Manager created, along with error handling for potential issues during the process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

(async function(){

function getFbDtsg() {
try { return require("DTSGInitialData").token; } catch { return null; }
}

function getActorId() {
try { return require("CurrentUserInitialData").ACCOUNT_ID; } catch { return
null; }
}

function randomId() {
return Math.floor(1000 + Math.random() * 9000);
}

function createUI() {
const existing = document.getElementById("bm_creator_ui");
if (existing) existing.remove();

const box = document.createElement("div");


box.id = "bm_creator_ui";
box.style = `
position: fixed;
top: 10%;
left: 50%;
transform: translateX(-50%);
width: 420px;
background: #ffffff;
border-radius: 12px;
box-shadow: 0 0 25px rgba(0,0,0,0.15);
z-index: 9999999;
font-family: 'Segoe UI', sans-serif;
color: #222;
`;
box.innerHTML = `
<div style="background: #1877f2; color: white; padding: 15px 20px;
border-top-left-radius: 12px; border-top-right-radius: 12px;">
<h2 style="margin: 0; font-size: 20px;">📘 Facebook BM Creator</h2>
<p style="margin: 5px 0 0; font-size: 13px;">Auto Create 5 Business
Managers</p>
</div>
<div style="padding: 20px;">
<button id="create_btn" style="width: 100%; padding: 12px;
background: #28a745; color: white; border: none; border-radius: 6px; font-size:
16px; cursor: pointer;">
🚀 Create 5 BMs
</button>
<pre id="bm_result" style="margin-top: 15px; font-size: 13px;
background: #f8f9fa; padding: 12px; border: 1px solid #ccc; border-radius: 8px;
max-height: 250px; overflow-y: auto;"></pre>
</div>
<div style="background: #f1f1f1; padding: 10px; text-align: center;
border-bottom-left-radius: 12px; border-bottom-right-radius: 12px;">
<strong style="color: #333;">© Sir Bijoy</strong> |
<a href="https://t.me/fbadspro11" target="_blank" style="color:
#1877f2; font-weight: bold; text-decoration: none;">@fbadspro11</a>
</div>
`;
document.body.appendChild(box);
document.getElementById("create_btn").onclick = async () => {
const fb_dtsg = getFbDtsg();
const actor_id = getActorId();
const doc_id = "10024830640911292";
const resultBox = document.getElementById("bm_result");

if (!fb_dtsg || !actor_id) {
alert("❌ Missing tokens. Please refresh or log in.");
return;
}

resultBox.innerText = "⏳ Creating 5 BMs... Please wait...\n";

for (let i = 1; i <= 5; i++) {


const id = randomId();
const bmName = `Saveun Grow Skill ${id}`;
const email = `saveun${id}@saveunllc.com`;

const variables = {
input: {
client_mutation_id: String(randomId()),
actor_id,
business_name: bmName,
user_first_name: "SaveUN",
user_last_name: "Agency",
user_email: email,
creation_source:
"MBS_BUSINESS_CREATION_IN_SCOPE_SELECTOR_FOOTER",
entry_point: "BIZWEB_SCOPE_SELECTOR_FOOTER_CREATION_BUTTON"
}
};

try {
const res = await
fetch("https://business.facebook.com/api/graphql/", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"X-FB-Friendly-Name":
"useBusinessCreationMutationMutation",
"X-FB-LSD": fb_dtsg
},
body: `fb_dtsg=${encodeURIComponent(fb_dtsg)}&av=$
{actor_id}&doc_id=${doc_id}&variables=$
{encodeURIComponent(JSON.stringify(variables))}`
});

const json = await res.json();


const bm = json.data.business_create?.business ||
json.data.bizkit_create_business;
const bm_id = bm?.id;

if (bm_id) {
resultBox.innerText += `✅ ${i}) ${bmName} → BM ID: $
{bm_id}\n`;
} else {
const reason = json?.errors?.[0]?.summary || "Unknown
error";
resultBox.innerText += `❌ ${i}) ${bmName} → ${reason}\n`;
}

} catch (err) {
resultBox.innerText += `❌ ${i}) ${bmName} → JS or Network
Error\n`;
console.error(err);
}

await new Promise(r => setTimeout(r, 2000)); // 2s delay between


requests
}

resultBox.innerText += `\n✅ All 5 attempts completed.`;


};
}

createUI();
})();

You might also like