<iframe.*?src%3D['"]([^'"]+)['"]/i)%3B if (iframeMatch) { videoUrl %3D iframeMatch[1]%3B } // YouTube const ytMatch %3D videoUrl.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?|shorts|live)\/|.*[?&]v%3D)|youtu\.be\/)([^"&?\/ ]{11})/i)%3B if (ytMatch) { const ytId %3D ytMatch[1]%3B return { type: 'youtube', isEmbed: true, embedUrl: `https://www.youtube-nocookie.com/embed/${ytId}?autoplay%3D0&playsinline%3D1&rel%3D0&modestbranding%3D1`, directUrl: videoUrl, thumbnailUrl: `https://img.youtube.com/vi/${ytId}/hqdefault.jpg` }%3B } // Google Drive const driveMatch %3D videoUrl.match(/drive\.google\.com\/(?:file\/d\/|open\?id%3D|uc\?id%3D)([a-zA-Z0-9_-]{20,})/i)%3B if (driveMatch) { const driveId %3D driveMatch[1]%3B return { type: 'googledrive', isEmbed: true, embedUrl: `https://drive.google.com/file/d/${driveId}/preview`, directUrl: videoUrl, thumbnailUrl: `https://drive.google.com/thumbnail?id%3D${driveId}&sz%3Dw1200` }%3B } // Vimeo const vimeoMatch %3D videoUrl.match(/vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)/i)%3B if (vimeoMatch) { const vimeoId %3D vimeoMatch[3]%3B return { type: 'vimeo', isEmbed: true, embedUrl: `https://player.vimeo.com/video/${vimeoId}?autoplay%3D0&muted%3D0&dnt%3D1`, directUrl: videoUrl, thumbnailUrl: `https://vumbnail.com/${vimeoId}.jpg` }%3B } // Dailymotion const dmMatch %3D videoUrl.match(/(?:dailymotion\.com\/(?:video|embed\/video)\/|dai\.ly\/)([a-zA-Z0-9]+)/i)%3B if (dmMatch) { const dmId %3D dmMatch[1]%3B return { type: 'dailymotion', isEmbed: true, embedUrl: `https://www.dailymotion.com/embed/video/${dmId}?autoplay%3D0`, directUrl: videoUrl, thumbnailUrl: `https://www.dailymotion.com/thumbnail/video/${dmId}` }%3B } // Streamable const streamableMatch %3D videoUrl.match(/streamable\.com\/(?:[e|o]\/)?([a-zA-Z0-9]+)/i)%3B if (streamableMatch) { const streamableCode %3D streamableMatch[1]%3B return { type: 'streamable', isEmbed: true, embedUrl: `https://streamable.com/e/${streamableCode}`, directUrl: videoUrl, thumbnailUrl: `https://cdn-cf-east.streamable.com/image/${streamableCode}.jpg` }%3B } // Facebook if (/facebook\.com|fb\.watch/i.test(videoUrl)) { return { type: 'facebook', isEmbed: true, embedUrl: `https://www.facebook.com/plugins/video.php?href%3D${encodeURIComponent(videoUrl)}&show_text%3Dfalse&autoplay%3Dfalse`, directUrl: videoUrl, thumbnailUrl: '' }%3B } // TikTok const ttMatch %3D videoUrl.match(/tiktok\.com\/(?:@[^\/]+\/video\/|v\/|embed\/v2\/)(\d+)/i)%3B if (ttMatch) { return { type: 'tiktok', isEmbed: true, embedUrl: `https://www.tiktok.com/player/v1/${ttMatch[1]}?autoplay%3D0`, directUrl: videoUrl, thumbnailUrl: '' }%3B } // Instagram const igMatch %3D videoUrl.match(/instagram\.com\/(?:reel|p|tv)\/([a-zA-Z0-9_-]+)/i)%3B if (igMatch) { return { type: 'instagram', isEmbed: true, embedUrl: `https://www.instagram.com/p/${igMatch[1]}/embed`, directUrl: videoUrl, thumbnailUrl: '' }%3B } // Doodstream const doodMatch %3D videoUrl.match(/(?:doodstream\.com|dood\.to|dood\.so|dood\.ws|dood\.pm|dood\.wf|dood\.cx|dood\.la|dood\.yt|ds2play\.com)\/(?:[edpf]\/)?([a-zA-Z0-9]+)/i)%3B if (doodMatch) { return { type: 'doodstream', isEmbed: true, embedUrl: `https://doodstream.com/e/${doodMatch[1]}`, directUrl: videoUrl, thumbnailUrl: '' }%3B } // Streamtape const stMatch %3D videoUrl.match(/(?:streamtape\.com|streamta\.pe)\/(?:[ve]\/)?([a-zA-Z0-9_-]+)/i)%3B if (stMatch) { return { type: 'streamtape', isEmbed: true, embedUrl: `https://streamtape.com/e/${stMatch[1]}`, directUrl: videoUrl, thumbnailUrl: '' }%3B } // Rumble const rumbleMatch %3D videoUrl.match(/rumble\.com\/(?:embed\/|v)?([a-zA-Z0-9_-]+)/i)%3B if (rumbleMatch) { const embedUrl %3D videoUrl.includes('rumble.com/embed/') ? videoUrl : `https://rumble.com/embed/${rumbleMatch[1]}/`%3B return { type: 'rumble', isEmbed: true, embedUrl: embedUrl, directUrl: videoUrl, thumbnailUrl: '' }%3B } // Videy const videyMatch %3D videoUrl.match(/videy\.co\/v\?id%3D([a-zA-Z0-9]+)/i)%3B if (videyMatch) { return { type: 'direct', isEmbed: false, embedUrl: '', directUrl: `https://cdn.videy.co/${videyMatch[1]}.mp4`, thumbnailUrl: '' }%3B } // HLS (.m3u8) if (/\.m3u8(\?.*)?$/i.test(videoUrl)) { return { type: 'hls', isEmbed: false, embedUrl: '', directUrl: videoUrl, thumbnailUrl: '' }%3B } // Generic embed if (/\/(?:embed|player|video-embed)\//i.test(videoUrl)) { return { type: 'custom_embed', isEmbed: true, embedUrl: videoUrl, directUrl: videoUrl, thumbnailUrl: '' }%3B } // Direct Video return { type: 'direct', isEmbed: false, embedUrl: '', directUrl: videoUrl, thumbnailUrl: '' }%3B } function extractVideoThumbnailJs(videoUrl) { const info %3D parseVideoSourceJs(videoUrl)%3B return info.thumbnailUrl || ''%3B } // %3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D // Real-time Live Preview Handler // %3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D function setupRealtimePreview() { // 1. Video URL / Stream Preview if (videoSourceUrl) { const updateVideoSource %3D () %3D> { const url %3D videoSourceUrl.value.trim()%3B if (url && (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('blob:') || url.length > 6)) { const parsed %3D parseVideoSourceJs(url)%3B const customPoster %3D videoPosterInput ? videoPosterInput.value.trim() : ''%3B const autoThumb %3D parsed.thumbnailUrl || extractVideoThumbnailJs(url)%3B if (parsed.isEmbed) { // Switch to iframe preview if (livePreviewVideo) { livePreviewVideo.style.display %3D 'none'%3B livePreviewVideo.removeAttribute('src')%3B } if (livePreviewIframe) { livePreviewIframe.src %3D parsed.embedUrl%3B livePreviewIframe.style.display %3D 'block'%3B } if (previewEmptyPlaceholder) previewEmptyPlaceholder.style.display %3D 'none'%3B } else { // Switch to video element preview if (livePreviewIframe) { livePreviewIframe.style.display %3D 'none'%3B livePreviewIframe.removeAttribute('src')%3B } if (livePreviewVideo) { if (customPoster) { livePreviewVideo.poster %3D customPoster%3B } else if (autoThumb) { livePreviewVideo.poster %3D autoThumb%3B } else { livePreviewVideo.removeAttribute('poster')%3B } livePreviewVideo.src %3D parsed.directUrl || url%3B livePreviewVideo.style.display %3D 'block'%3B livePreviewVideo.load()%3B } if (previewEmptyPlaceholder) previewEmptyPlaceholder.style.display %3D 'none'%3B } } else { if (livePreviewVideo) { livePreviewVideo.style.display %3D 'none'%3B livePreviewVideo.removeAttribute('src')%3B } if (livePreviewIframe) { livePreviewIframe.style.display %3D 'none'%3B livePreviewIframe.removeAttribute('src')%3B } if (previewEmptyPlaceholder) previewEmptyPlaceholder.style.display %3D 'flex'%3B } }%3B videoSourceUrl.addEventListener('input', updateVideoSource)%3B videoSourceUrl.addEventListener('change', updateVideoSource)%3B videoSourceUrl.addEventListener('paste', () %3D> setTimeout(updateVideoSource, 50))%3B } // 2. Video Title Preview if (videoTitleInput && previewVideoTitle) { const updateTitle %3D () %3D> { const title %3D videoTitleInput.value.trim()%3B previewVideoTitle.textContent %3D title || 'Watch Video Online'%3B }%3B videoTitleInput.addEventListener('input', updateTitle)%3B videoTitleInput.addEventListener('change', updateTitle)%3B } // 3. Poster Image Preview if (videoPosterInput && livePreviewVideo) { const updatePoster %3D () %3D> { const customPoster %3D videoPosterInput.value.trim()%3B if (customPoster) { livePreviewVideo.poster %3D customPoster%3B } else { const autoThumb %3D extractVideoThumbnailJs(videoSourceUrl ? videoSourceUrl.value.trim() : '')%3B if (autoThumb) { livePreviewVideo.poster %3D autoThumb%3B } else { livePreviewVideo.removeAttribute('poster')%3B } } }%3B videoPosterInput.addEventListener('input', updatePoster)%3B videoPosterInput.addEventListener('change', updatePoster)%3B } // 4. Click Redirection Preview Badge if (redirectOnClickInput && previewClickBadge) { const updateClickBadge %3D () %3D> { previewClickBadge.style.display %3D redirectOnClickInput.checked ? 'inline-flex' : 'none'%3B }%3B redirectOnClickInput.addEventListener('change', updateClickBadge)%3B updateClickBadge()%3B } // 5. Action Buttons Preview const updateButtonsPreview %3D () %3D> { const b1 %3D btn1TextInput ? btn1TextInput.value.trim() : ''%3B const b2 %3D btn2TextInput ? btn2TextInput.value.trim() : ''%3B if (previewBtn1Element && previewBtn1Text) { if (b1) { previewBtn1Text.textContent %3D b1%3B previewBtn1Element.style.display %3D 'inline-flex'%3B } else { previewBtn1Element.style.display %3D 'none'%3B } } if (previewBtn2Element && previewBtn2Text) { if (b2) { previewBtn2Text.textContent %3D b2%3B previewBtn2Element.style.display %3D 'inline-flex'%3B } else { previewBtn2Element.style.display %3D 'none'%3B } } }%3B if (btn1TextInput) { btn1TextInput.addEventListener('input', updateButtonsPreview)%3B btn1TextInput.addEventListener('change', updateButtonsPreview)%3B } if (btn2TextInput) { btn2TextInput.addEventListener('input', updateButtonsPreview)%3B btn2TextInput.addEventListener('change', updateButtonsPreview)%3B } // 6. Timer Delay Preview const previewTimerNotice %3D document.getElementById('previewTimerNotice')%3B const previewTimerVal %3D document.getElementById('previewTimerVal')%3B if (btnTimerSelect && previewTimerNotice && previewTimerVal) { btnTimerSelect.addEventListener('change', () %3D> { const sec %3D parseInt(btnTimerSelect.value) || 0%3B if (sec > 0) { previewTimerVal.textContent %3D sec%3B previewTimerNotice.style.display %3D 'flex'%3B } else { previewTimerNotice.style.display %3D 'none'%3B } })%3B } // 7. Phase 8: Social OG Engine & Live Social Mockup Initializer initSocialOgEngine()%3B } // %3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D // Phase 8: Social OG Watermark & Preview Engine // %3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D function initSocialOgEngine() { const ogPresetChips %3D document.querySelectorAll('#ogPresetChips .preset-chip')%3B const ogPlayStyleSelect %3D document.getElementById('ogPlayStyleSelect')%3B const ogDurationInput %3D document.getElementById('ogDurationInput')%3B const durationPillBtns %3D document.querySelectorAll('.duration-pill-btn')%3B const ogImageWatermarkedUrl %3D document.getElementById('ogImageWatermarkedUrl')%3B const btnPreviewLandingMode %3D document.getElementById('btnPreviewLandingMode')%3B const btnPreviewSocialMode %3D document.getElementById('btnPreviewSocialMode')%3B const landingPreviewMode %3D document.getElementById('landingPreviewMode')%3B const socialOgPreviewMode %3D document.getElementById('socialOgPreviewMode')%3B const socialPlatBtns %3D document.querySelectorAll('.social-plat-btn')%3B const mockupBoxes %3D document.querySelectorAll('.social-mockup-box')%3B const btnBakeWatermark %3D document.getElementById('btnBakeWatermark')%3B const btnDownloadOgCanvas %3D document.getElementById('btnDownloadOgCanvas')%3B const liveOgCanvas %3D document.getElementById('liveOgCanvas')%3B // Presets Definition const presetsData %3D { 'viral_clip': { title: 'OMG! You Won\'t Believe What Happened (Full Clip)', poster: 'https://images.unsplash.com/photo-1574375927938-d5a98e8ffe85?w%3D1200&auto%3Dformat&fit%3Dcrop&q%3D80', duration: '03:45 HD', style: 'youtube_red' }, 'cyber_stream': { title: 'Exclusive High-Speed 4K Media Stream', poster: 'https://images.unsplash.com/photo-1536240478700-b869070f9279?w%3D1200&auto%3Dformat&fit%3Dcrop&q%3D80', duration: '07:20 4K', style: 'glass_cyan' }, 'breaking_news': { title: ' LIVE Broadcast: Uncensored Footage Just Released', poster: 'https://images.unsplash.com/photo-1585829365295-ab7cd400c167?w%3D1200&auto%3Dformat&fit%3Dcrop&q%3D80', duration: 'LIVE ', style: 'youtube_red' }, 'neon_gaming': { title: 'Insane Gameplay Highlights & Clutch Moments', poster: 'https://images.unsplash.com/photo-1542751371-adc38448a05e?w%3D1200&auto%3Dformat&fit%3Dcrop&q%3D80', duration: '05:12 HD', style: 'neon_pulse' }, 'crystal_media': { title: 'Direct Access Media Player & Vault Link', poster: 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w%3D1200&auto%3Dformat&fit%3Dcrop&q%3D80', duration: '02:30 HD', style: 'crystal_white' } }%3B // 1. Mode Switcher (Landing vs Social OG) if (btnPreviewLandingMode && btnPreviewSocialMode) { btnPreviewLandingMode.addEventListener('click', () %3D> { btnPreviewLandingMode.classList.add('active')%3B btnPreviewSocialMode.classList.remove('active')%3B if (landingPreviewMode) landingPreviewMode.style.display %3D 'block'%3B if (socialOgPreviewMode) socialOgPreviewMode.style.display %3D 'none'%3B })%3B btnPreviewSocialMode.addEventListener('click', () %3D> { btnPreviewSocialMode.classList.add('active')%3B btnPreviewLandingMode.classList.remove('active')%3B if (landingPreviewMode) landingPreviewMode.style.display %3D 'none'%3B if (socialOgPreviewMode) socialOgPreviewMode.style.display %3D 'block'%3B renderSocialMockup()%3B })%3B } // 2. Social Platform Switcher (Facebook, Twitter, Telegram, WhatsApp) socialPlatBtns.forEach(btn %3D> { btn.addEventListener('click', () %3D> { const plat %3D btn.getAttribute('data-platform')%3B socialPlatBtns.forEach(b %3D> b.classList.remove('active'))%3B btn.classList.add('active')%3B mockupBoxes.forEach(box %3D> { box.style.display %3D 'none'%3B box.classList.remove('active')%3B })%3B const targetMockup %3D document.getElementById('mockup' + plat.charAt(0).toUpperCase() + plat.slice(1))%3B if (targetMockup) { targetMockup.style.display %3D 'block'%3B targetMockup.classList.add('active')%3B } })%3B })%3B // 3. Preset Chips Selection ogPresetChips.forEach(chip %3D> { chip.addEventListener('click', () %3D> { const pKey %3D chip.getAttribute('data-preset')%3B const preset %3D presetsData[pKey]%3B if (!preset) return%3B ogPresetChips.forEach(c %3D> c.classList.remove('active'))%3B chip.classList.add('active')%3B if (videoTitleInput) { videoTitleInput.value %3D preset.title%3B if (previewVideoTitle) previewVideoTitle.textContent %3D preset.title%3B } if (videoPosterInput) { videoPosterInput.value %3D preset.poster%3B if (livePreviewVideo) livePreviewVideo.poster %3D preset.poster%3B } if (ogDurationInput) ogDurationInput.value %3D preset.duration%3B if (ogPlayStyleSelect) ogPlayStyleSelect.value %3D preset.style%3B // Sync duration pills durationPillBtns.forEach(p %3D> { if (p.getAttribute('data-dur') %3D%3D%3D preset.duration) p.classList.add('active')%3B else p.classList.remove('active')%3B })%3B renderSocialMockup()%3B })%3B })%3B // 4. Duration Pill Selectors durationPillBtns.forEach(pill %3D> { pill.addEventListener('click', () %3D> { durationPillBtns.forEach(p %3D> p.classList.remove('active'))%3B pill.classList.add('active')%3B const dur %3D pill.getAttribute('data-dur')%3B if (ogDurationInput) ogDurationInput.value %3D dur%3B renderSocialMockup()%3B })%3B })%3B if (ogDurationInput) { ogDurationInput.addEventListener('input', () %3D> { renderSocialMockup()%3B })%3B } if (ogPlayStyleSelect) { ogPlayStyleSelect.addEventListener('change', () %3D> { renderSocialMockup()%3B })%3B } if (videoTitleInput) { videoTitleInput.addEventListener('input', () %3D> { renderSocialMockup()%3B })%3B } if (videoPosterInput) { videoPosterInput.addEventListener('input', () %3D> { renderSocialMockup()%3B })%3B } // 5. Render Social Mockup Elements function renderSocialMockup() { const currentTitle %3D (videoTitleInput ? videoTitleInput.value.trim() : '') || 'OMG! You Won\'t Believe What Happened (Full Clip)'%3B const currentPoster %3D (videoPosterInput ? videoPosterInput.value.trim() : '') || 'https://images.unsplash.com/photo-1574375927938-d5a98e8ffe85?w%3D1200&auto%3Dformat&fit%3Dcrop&q%3D80'%3B const currentDur %3D (ogDurationInput ? ogDurationInput.value.trim() : '') || '03:45 HD'%3B const currentStyle %3D (ogPlayStyleSelect ? ogPlayStyleSelect.value : 'youtube_red')%3B // Current domain label let domainLabel %3D window.location.host%3B if (videoDomainSelect && videoDomainSelect.value && videoDomainSelect.value !%3D%3D 'default') { domainLabel %3D videoDomainSelect.value.replace(/^https?:\/\//, '')%3B } // Update Titles const fbCardTitle %3D document.getElementById('fbCardTitle')%3B const twCardTitle %3D document.getElementById('twCardTitle')%3B const tgCardTitle %3D document.getElementById('tgCardTitle')%3B const waCardTitle %3D document.getElementById('waCardTitle')%3B if (fbCardTitle) fbCardTitle.textContent %3D currentTitle%3B if (twCardTitle) twCardTitle.textContent %3D currentTitle%3B if (tgCardTitle) tgCardTitle.textContent %3D ' ' + currentTitle%3B if (waCardTitle) waCardTitle.textContent %3D ' ' + currentTitle%3B // Update Domains const fbCardDomain %3D document.getElementById('fbCardDomain')%3B const twCardDomain %3D document.getElementById('twCardDomain')%3B const waCardDomain %3D document.getElementById('waCardDomain')%3B if (fbCardDomain) fbCardDomain.textContent %3D domainLabel%3B if (twCardDomain) twCardDomain.textContent %3D domainLabel%3B if (waCardDomain) waCardDomain.textContent %3D domainLabel%3B // Update Duration Badges const durBadges %3D [ document.getElementById('ogDurationBadgeFb'), document.getElementById('ogDurationBadgeTw'), document.getElementById('ogDurationBadgeTg'), document.getElementById('ogDurationBadgeWa') ]%3B durBadges.forEach(b %3D> { if (b) b.textContent %3D currentDur%3B })%3B // Update Play Watermark Classes & Overlays const watermarkOverlays %3D [ document.getElementById('ogWatermarkOverlayFb'), document.getElementById('ogWatermarkOverlayTw'), document.getElementById('ogWatermarkOverlayTg'), document.getElementById('ogWatermarkOverlayWa') ]%3B watermarkOverlays.forEach(w %3D> { if (w) { w.className %3D 'watermark-play-overlay ' + currentStyle%3B } })%3B // Update Poster Images const previewImgs %3D [ document.getElementById('ogPreviewImageFb'), document.getElementById('ogPreviewImageTw'), document.getElementById('ogPreviewImageTg'), document.getElementById('ogPreviewImageWa') ]%3B previewImgs.forEach(img %3D> { if (img) img.src %3D currentPoster%3B })%3B } // Initial render renderSocialMockup()%3B // 6. Real-time Canvas Rendering Function (1200x630) function renderCanvasOg(callback) { if (!liveOgCanvas) return%3B const ctx %3D liveOgCanvas.getContext('2d')%3B const w %3D 1200%3B const h %3D 630%3B liveOgCanvas.width %3D w%3B liveOgCanvas.height %3D h%3B const posterSrc %3D (videoPosterInput ? videoPosterInput.value.trim() : '') || 'https://images.unsplash.com/photo-1574375927938-d5a98e8ffe85?w%3D1200&auto%3Dformat&fit%3Dcrop&q%3D80'%3B const style %3D (ogPlayStyleSelect ? ogPlayStyleSelect.value : 'youtube_red')%3B const duration %3D (ogDurationInput ? ogDurationInput.value.trim() : '03:45 HD')%3B const img %3D new Image()%3B img.crossOrigin %3D 'anonymous'%3B img.onload %3D () %3D> { // Draw cover image const imgRatio %3D img.width / img.height%3B const canvasRatio %3D w / h%3B let srcW, srcH, srcX, srcY%3B if (imgRatio > canvasRatio) { srcH %3D img.height%3B srcW %3D img.height * canvasRatio%3B srcX %3D (img.width - srcW) / 2%3B srcY %3D 0%3B } else { srcW %3D img.width%3B srcH %3D img.width / canvasRatio%3B srcX %3D 0%3B srcY %3D (img.height - srcH) / 2%3B } ctx.drawImage(img, srcX, srcY, srcW, srcH, 0, 0, w, h)%3B // Subtle dark vignette ctx.fillStyle %3D 'rgba(0, 0, 0, 0.18)'%3B ctx.fillRect(0, 0, w, h)%3B // Draw Play Button in center drawPlayButtonOnCanvas(ctx, w / 2, h / 2, style)%3B // Draw Duration Badge in bottom-right drawDurationBadgeOnCanvas(ctx, w, h, duration)%3B if (callback) callback(liveOgCanvas)%3B }%3B img.onerror %3D () %3D> { // Fallback gradient backdrop const grad %3D ctx.createLinearGradient(0, 0, w, h)%3B grad.addColorStop(0, '#0f172a')%3B grad.addColorStop(1, '#1e1b4b')%3B ctx.fillStyle %3D grad%3B ctx.fillRect(0, 0, w, h)%3B drawPlayButtonOnCanvas(ctx, w / 2, h / 2, style)%3B drawDurationBadgeOnCanvas(ctx, w, h, duration)%3B if (callback) callback(liveOgCanvas)%3B }%3B img.src %3D posterSrc%3B } function drawPlayButtonOnCanvas(ctx, cx, cy, style) { ctx.save()%3B if (style %3D%3D%3D 'youtube_red') { const bw %3D 160%3B const bh %3D 110%3B const rad %3D 32%3B ctx.shadowColor %3D 'rgba(0, 0, 0, 0.5)'%3B ctx.shadowBlur %3D 25%3B ctx.shadowOffsetY %3D 6%3B ctx.fillStyle %3D '#ef4444'%3B roundRect(ctx, cx - bw / 2, cy - bh / 2, bw, bh, rad)%3B ctx.fill()%3B // White Play Triangle ctx.shadowColor %3D 'transparent'%3B ctx.fillStyle %3D '#ffffff'%3B ctx.beginPath()%3B ctx.moveTo(cx - 16, cy - 26)%3B ctx.lineTo(cx + 26, cy)%3B ctx.lineTo(cx - 16, cy + 26)%3B ctx.closePath()%3B ctx.fill()%3B } else if (style %3D%3D%3D 'glass_cyan') { const r %3D 70%3B ctx.shadowColor %3D 'rgba(34, 211, 238, 0.8)'%3B ctx.shadowBlur %3D 30%3B ctx.fillStyle %3D 'rgba(15, 23, 42, 0.6)'%3B ctx.beginPath()%3B ctx.arc(cx, cy, r, 0, Math.PI * 2)%3B ctx.fill()%3B ctx.strokeStyle %3D '#22d3ee'%3B ctx.lineWidth %3D 4%3B ctx.stroke()%3B ctx.fillStyle %3D '#ffffff'%3B ctx.beginPath()%3B ctx.moveTo(cx - 14, cy - 24)%3B ctx.lineTo(cx + 24, cy)%3B ctx.lineTo(cx - 14, cy + 24)%3B ctx.closePath()%3B ctx.fill()%3B } else if (style %3D%3D%3D 'crystal_white') { const r %3D 68%3B ctx.shadowColor %3D 'rgba(0, 0, 0, 0.6)'%3B ctx.shadowBlur %3D 24%3B ctx.fillStyle %3D 'rgba(255, 255, 255, 0.2)'%3B ctx.beginPath()%3B ctx.arc(cx, cy, r, 0, Math.PI * 2)%3B ctx.fill()%3B ctx.strokeStyle %3D '#ffffff'%3B ctx.lineWidth %3D 4%3B ctx.stroke()%3B ctx.fillStyle %3D '#ffffff'%3B ctx.beginPath()%3B ctx.moveTo(cx - 14, cy - 24)%3B ctx.lineTo(cx + 24, cy)%3B ctx.lineTo(cx - 14, cy + 24)%3B ctx.closePath()%3B ctx.fill()%3B } else { // neon_pulse const r %3D 70%3B ctx.shadowColor %3D 'rgba(192, 132, 252, 0.85)'%3B ctx.shadowBlur %3D 30%3B ctx.fillStyle %3D 'rgba(88, 28, 135, 0.65)'%3B ctx.beginPath()%3B ctx.arc(cx, cy, r, 0, Math.PI * 2)%3B ctx.fill()%3B ctx.strokeStyle %3D '#c084fc'%3B ctx.lineWidth %3D 4%3B ctx.stroke()%3B ctx.fillStyle %3D '#ffffff'%3B ctx.beginPath()%3B ctx.moveTo(cx - 14, cy - 24)%3B ctx.lineTo(cx + 24, cy)%3B ctx.lineTo(cx - 14, cy + 24)%3B ctx.closePath()%3B ctx.fill()%3B } ctx.restore()%3B } function drawDurationBadgeOnCanvas(ctx, w, h, text) { ctx.save()%3B ctx.font %3D 'bold 24px "Outfit", sans-serif'%3B const metrics %3D ctx.measureText(text)%3B const padX %3D 18%3B const padY %3D 10%3B const bw %3D metrics.width + padX * 2%3B const bh %3D 44%3B const bx %3D w - bw - 35%3B const by %3D h - bh - 35%3B ctx.fillStyle %3D 'rgba(0, 0, 0, 0.85)'%3B roundRect(ctx, bx, by, bw, bh, 8)%3B ctx.fill()%3B ctx.strokeStyle %3D 'rgba(255, 255, 255, 0.3)'%3B ctx.lineWidth %3D 1.5%3B roundRect(ctx, bx, by, bw, bh, 8)%3B ctx.stroke()%3B ctx.fillStyle %3D '#ffffff'%3B ctx.fillText(text, bx + padX, by + 30)%3B ctx.restore()%3B } function roundRect(ctx, x, y, w, h, r) { ctx.beginPath()%3B ctx.moveTo(x + r, y)%3B ctx.lineTo(x + w - r, y)%3B ctx.quadraticCurveTo(x + w, y, x + w, y + r)%3B ctx.lineTo(x + w, y + h - r)%3B ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h)%3B ctx.lineTo(x + r, y + h)%3B ctx.quadraticCurveTo(x, y + h, x, y + h - r)%3B ctx.lineTo(x, y + r)%3B ctx.quadraticCurveTo(x, y, x + r, y)%3B ctx.closePath()%3B } // 7. Apply Watermark Button if (btnBakeWatermark) { btnBakeWatermark.addEventListener('click', () %3D> Not flagged