๐Ÿ” POPFOI ร— McDonald's โ€” System Map

Full architecture & troubleshooting guide for popfood.vip

๐Ÿ“ File Structure
MCD UTAMA/ โ”‚ โ”œโ”€โ”€ CNAME โ†’ Custom domain: popfood.vip โ”œโ”€โ”€ index.html โ†’ Main webpage (form + receipt) โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ app.js โ†’ Core logic (form, validation, API, receipt) โ”‚ โ”œโ”€โ”€ food-bg.js โ†’ Floating emoji background animation โ”‚ โ””โ”€โ”€ style.css โ†’ All styling (McDonald's theme, animations) โ”‚ โ”œโ”€โ”€ Cloudflare Worker/ โ”‚ โ””โ”€โ”€ index.js โ†’ Backend proxy (validation โ†’ Sheets + Telegram) โ”‚ โ”œโ”€โ”€ Google App Script/ โ”‚ โ””โ”€โ”€ script.gs โ†’ Google Sheets writer (appends row) โ”‚ โ””โ”€โ”€ media/ โ†’ Static assets โ”œโ”€โ”€ banner.jpg โ†’ Hero banner image โ”œโ”€โ”€ mcd.png โ†’ McDonald's logo + favicon โ”œโ”€โ”€ foi.png โ†’ POPFOI logo โ”œโ”€โ”€ bea.png luz.png n1.png โ†’ Platform logos (emoji click game) โ””โ”€โ”€ sur.png zoe.png โ†’ Platform logos (emoji click game)
๐ŸŒ Hosting & Domain
ComponentWhere It Lives
Frontend STATICGitHub Pages (index.html + src/ + media/)
Custom Domainpopfood.vip
Cloudflare Worker APImcd.danilla-vargas1923.workers.dev
Google Apps Script BACKENDWeb App (URL in Worker env GOOGLE_SHEET_URL)
Telegram Bot NOTIFYBot API (token in Worker env TG_BOT_TOKEN)
Google Sheet DBLinked to Apps Script โ€” stores all registrations
๐Ÿ”€ Complete Data Flow
USER (Browser) โ”‚ โ”‚ 1. Opens popfood.vip โ”‚ โ†’ index.html loads โ†’ style.css โ†’ food-bg.js โ†’ app.js โ”‚ โ”‚ 2. Types Game ID (10 digits) โ†’ Tier table reveals โ”‚ 3. Types Email โ†’ Warning box appears โ”‚ โ”‚ 4. Clicks "REGISTRE-SE!" โ”‚ โ†’ app.js validates: โœ“ 10 digits โœ“ valid email โ”‚ โ†’ Button disabled โ†’ "Enviando..." โ”‚ โ†’ Generates Sรฃo Paulo timezone date/time โ”‚ โ–ผ โ”‚ 5. POST โ†’ https://mcd.danilla-vargas1923.workers.dev โ”‚ Body: { platform, game_id, email, registered_date, registered_time } โ”‚ Retry: up to 3 attempts (300ms, 600ms delays) โ”‚ โ–ผ CLOUDFLARE WORKER โ”‚ โ”‚ 6. Validates again: โœ“ 5 fields โœ“ game_id โœ“ email โ”‚ โ”‚ 7. Fires TWO tasks in parallel (Promise.allSettled) โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ–ผ โ–ผ GOOGLE APPS SCRIPT TELEGRAM BOT API โ”‚ โ”‚ โ”‚ 8a. POST JSON (3 retries) โ”‚ 8b. sendMessage (2 retries) โ”‚ 200ms backoff โ”‚ MarkdownV2 format โ”‚ โ”‚ โ”‚ 9a. script.gs: โ”‚ ๐Ÿ” NOVA INSCRIร‡รƒO โ”‚ โ†’ Parse JSON โ”‚ ๐Ÿ“ฑ Platform โ”‚ โ†’ Append row to Sheet โ”‚ ๐ŸŽฎ Game ID โ”‚ โ†’ {success: true} โ”‚ ๐Ÿ“ง Email ๐Ÿ• Date โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ–ผ โ”‚ 10. Worker checks: โ”‚ โ†’ Sheet MUST succeed (or 502 error) โ”‚ โ†’ Telegram fail = silent (non-blocking) โ”‚ โ†’ Returns { success: true } โ”‚ โ–ผ BACK TO BROWSER โ”‚ โ”‚ 11. Success โ†’ Hide form โ†’ Show receipt โ†’ Fill fields โ†’ Scroll top โ”‚ 12. 2s delay โ†’ Auto-download receipt PNG (html2canvas) โ”‚ 13. User can click "๐Ÿ“ฅ Baixar" or "Fazer outra inscriรงรฃo"
๐Ÿ“„ File-by-File Breakdown
index.html โ€” Main Page
SectionID / ClassPurpose
Header.mcd-bannerPOPFOI ร— McDonald's logo bar
Banner Image.banner-wrap > .banner-imgHero banner with breathing animation
Form Page#pageFormRegistration form (visible by default)
How It Works.how-it-works3-step guide (recharge โ†’ receive โ†’ use)
Game ID#gameId10-digit numeric input
Tier Table#tierSectionHidden until typing; shows R$ โ†’ voucher tiers
Email#emailEmail with focus-triggered warning
Email Warning#emailWarning"Check your email!" warning (hidden until focus)
Submit Button#submitBtn"๐Ÿ” REGISTRE-SE! ๐Ÿ”" โ€” disables on submit
Receipt Page#pageReceiptHidden; shown after successful submit
Receipt Card#receiptCaptureDiv captured by html2canvas for PNG
Receipt Fields#rcptPlatform #rcptGameId #rcptEmail #rcptDateFilled dynamically after submit
Download#btnDownloadManual receipt PNG download
Back ButtonresetForm()Reset form, show form page
Toast#toastPopup notification bar
Footer.mcd-footer"amo muito tudo issoโ„ข" branding
DevTools BlockInline <script>Disables F12, Ctrl+Shift+I/J/C, Ctrl+U, right-click
Hidden Field#platformAlways "POPFOI" (hidden input)
src/app.js โ€” Core Application Logic
Function / BlockWhat It Does
WORKER_URLhttps://mcd.danilla-vargas1923.workers.dev
loadHtml2Canvas()Lazy-loads html2canvas from jsDelivr CDN
Preload on window.loadStarts loading html2canvas 1s after page load (non-blocking)
gameIdInput listenerShows tier table on first keystroke
email focus listenerShows email warning on first focus
showToast(msg)Shows toast notification (3.5s duration)
resetForm()Clears form, hides receipt, scrolls to top
generateTicketId()Creates MCD-XXXX-XXXX ticket (defined but NOT used)
getSaoPauloDate()Gets current date in America/Sao_Paulo timezone
formatDate(d)โ†’ "Mon, 09 Mar 2026"
formatTime(d)โ†’ "14:30:05"
showReceipt(...)Fills receipt fields, toggles pages, auto-download after 2s
downloadReceipt()html2canvas captures #receiptCapture as PNG
sendToWorker(data, retries)POST to Worker with 3 retries; 4xx = no retry, 5xx = retry
form.submit handlerValidate โ†’ disable btn โ†’ send โ†’ receipt or error
โœ… Client-Side Validation Rules
  • Game ID: exactly 10 digits (/^\d{10}$/)
  • Email: basic format (/^[^\s@]+@[^\s@]+\.[^\s@]+$/)
  • Both fields required
src/food-bg.js โ€” Background Animation
WhatDetail
Emojis๐Ÿ” ๐ŸŸ ๐Ÿฅค ๐Ÿฆ ๐ŸŒฎ ๐Ÿ— โ€” randomly chosen
Count12 floating emojis
PositionLeft 0-20% or right 80-100% of screen
AnimationFloat upward, 10-20s duration, random delay
Click GameClick emoji โ†’ burst animation + platform logo flash
Logosbea.png foi.png luz.png n1.png sur.png zoe.png
RespawnNew emoji replaces clicked one after burst
Cloudflare Worker/index.js โ€” Backend Proxy
SectionDetail
CORSAll origins (*), POST + OPTIONS only
Method CheckOnly POST (405 for others)
Validation5 required fields, game_id 10 digits, valid email
Google SheetsretryFetch() โ€” 3 attempts, 200ms backoff
Sheet CheckVerifies JSON {success:true} (not HTML error page)
TelegramsendTelegram() โ€” 2 attempts, 300ms delay
ParallelSheet + Telegram via Promise.allSettled
Error LogicSheet fail โ†’ 502; Telegram fail โ†’ silent
EscapingescapeMarkdown() for MarkdownV2 special chars
Google App Script/script.gs โ€” Sheet Writer
WhatDetail
FunctiondoPost(e) โ€” triggered by HTTP POST
InputJSON from Cloudflare Worker
Columnsregistered_date | registered_time | platform | game_id | email
FlushSpreadsheetApp.flush() forces immediate write
Response{success: true} or {success: false, error: "..."}
src/style.css โ€” Styling (733 lines)
AreaClasses
BaseRed background #da291c, diagonal stripe pattern
Wrapper.page-wrapper โ€” max 420px, centered, rounded
Banner.mcd-banner โ€” top logo bar
Banner Image.banner-img โ€” breathing animation (8s)
Form.card โ€” white card, rounded corners
InputsStyled with focus glow, shake on invalid
Tier Table.tier-table โ€” alternating rows, branded
Submit Button.btn-submit โ€” golden gradient, shine effect
Receipt.receipt-container โ€” zigzag edge card
Toast.toast โ€” slide-up popup
Food BG.bg-food span โ€” float upward animation
๐Ÿ”ง Troubleshooting

Click any problem to expand the solution.

๐Ÿšซ Form submits but nothing happens / "Falha na conexรฃo" โ–ถ
  1. Browser Console โ†’ Look for network errors or CORS issues
  2. Worker URL โ†’ Is https://mcd.danilla-vargas1923.workers.dev alive?
    Test: curl -X POST <URL> -H "Content-Type: application/json" -d '{"platform":"test","game_id":"1234567890","email":"t@t.com","registered_date":"x","registered_time":"x"}'
  3. Worker Logs โ†’ Cloudflare Dashboard โ†’ Workers โ†’ Logs
  4. Google Sheet URL โ†’ Is Apps Script deployed as Web App?
    Must be: Execute as Me, Access: Anyone
    Check GOOGLE_SHEET_URL env var is set
๐Ÿ“ฉ Data saved to sheet but no Telegram notification โ–ถ
  1. Check TG_BOT_TOKEN env var is set in Cloudflare Worker
  2. Check TG_CHAT_ID env var is set in Cloudflare Worker
  3. Bot must be added to the chat/group with send message permission
  4. Telegram failures are silent โ€” check Worker logs for "Telegram attempt X" errors
๐Ÿ“Š Google Sheet not receiving data โ–ถ
  1. Apps Script deployment โ€” Must be deployed as Web App (not just saved)
  2. Redeployment โ€” After editing script.gs, create a New Deployment
  3. Sheet permissions โ€” Script must have Sheets access authorized
  4. Worker env var โ€” GOOGLE_SHEET_URL must point to /exec URL (not /dev)
  5. Response format โ€” Worker checks for JSON {success:true}; HTML = retry & fail
๐Ÿ“ธ Receipt image not downloading โ–ถ
  1. html2canvas CDN โ€” Check if cdn.jsdelivr.net is reachable
  2. Mixed content โ€” All images must be HTTPS or local
  3. CORS on images โ€” useCORS: true is set, but external images may block
  4. Popup blocker โ€” Auto-download at 2s may be blocked; user can click "๐Ÿ“ฅ Baixar"
โš ๏ธ Form validation errors โ–ถ
Error MessageCauseFix
"Preencha todos os campos!"Empty game_id or emailFill both fields
"ID do jogo deve ter exatamente 10 dรญgitos!"Not 10 digitsEnter exactly 10 digits
Input shakesInvalid game_idCheck digit count
"Por favor, insira um e-mail vรกlido."Email fails regexEnter valid email
"Dados invรกlidos"Worker rejects (4xx)Check validation rules
๐Ÿ”— CORS errors in browser console โ–ถ
  1. Worker returns Access-Control-Allow-Origin: * on all responses
  2. Preflight (OPTIONS) returns 204 with CORS headers
  3. If you see CORS errors, the Worker may be down or misconfigured
  4. Check Cloudflare dashboard for Worker status
๐ŸŽจ Page looks broken / unstyled โ–ถ
  1. Check src/style.css is loading (Network tab)
  2. Check Google Fonts (fonts.googleapis.com) is reachable
  3. Check media/ images exist and are accessible
  4. Clear browser cache
๐ŸŸ Floating emojis not showing โ–ถ
  1. food-bg.js must load after DOM (defer attribute)
  2. Check console for JS errors
  3. .bg-food container is prepended to <body> by the script
  4. @keyframes foodFloat must exist in style.css
๐ŸŒ Custom domain not working โ–ถ
  1. CNAME file contains popfood.vip
  2. DNS must point to GitHub Pages (or your host)
  3. HTTPS certificate must be provisioned (GitHub Pages โ†’ Settings โ†’ Pages)
  4. Cloudflare DNS proxy may interfere โ€” check DNS settings
๐Ÿ”‘ Environment Variables

Set in Cloudflare Workers โ†’ Settings โ†’ Variables

GOOGLE_SHEET_URL = https://script.google.com/macros/s/XXXX.../exec
TG_BOT_TOKEN = 123456:ABC-DEF...
TG_CHAT_ID = -100XXXXXXXXXX
๐Ÿ”— Key URLs & Endpoints
WhatURL
Live Sitehttps://popfood.vip
Worker APIhttps://mcd.danilla-vargas1923.workers.dev POST
Worker DashboardCloudflare โ†’ Workers & Pages โ†’ mcd
Apps Script EditorGoogle Apps Script dashboard โ†’ find project
Google SheetLinked to Apps Script (getActiveSpreadsheet())
html2canvas CDNcdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js
Fontsfonts.googleapis.com (Nunito + Courier Prime)
๐Ÿ”„ How to Update / Redeploy
FRONTEND index.html, src/, media/
  1. Edit files locally
  2. Push to GitHub (or upload to static host)
  3. GitHub Pages auto-deploys from branch
WORKER Cloudflare Worker
  1. Edit Cloudflare Worker/index.js
  2. Cloudflare Dashboard โ†’ Workers โ†’ mcd โ†’ Quick Edit (or Wrangler CLI)
  3. Paste updated code โ†’ Save and Deploy
BACKEND Google Apps Script
  1. Edit Google App Script/script.gs
  2. Go to Apps Script editor โ†’ paste code
  3. Deploy โ†’ New Deployment (must create NEW, not just save)
  4. Copy the new /exec URL
  5. Update GOOGLE_SHEET_URL in Worker env vars if URL changed
โšก Security Measures
MeasureWhereWhat
DevTools Blockedindex.htmlF12, Ctrl+Shift+I/J/C, Ctrl+U, Ctrl+S, right-click
Double Validationapp.js + WorkerClient AND server validate game_id & email
CORS RestrictedWorkerOnly POST + OPTIONS allowed
Retry + BackoffClient + Worker3x client, 3x sheet, 2x telegram
Error IsolationWorkerTelegram fail doesn't block registration
Input SanitizationWorkerMarkdownV2 chars escaped for Telegram

๐Ÿ”’ Enter Password