Loading Clickbait Generator...
/gmi, ""); const scriptContent = doc.querySelector('script') ? doc.querySelector('script').innerHTML : ''; // 2. Inject into WordPress const root = document.getElementById('clickbait-tool-root'); root.innerHTML = `
${bodyContent}
`; // 3. Execute the Logic const scriptEl = document.createElement('script'); scriptEl.text = scriptContent; document.body.appendChild(scriptEl); // 4. OVERRIDE THE POPUP LOGIC TO SHOW IN-PAGE // Highjacking the tool's original openPopup function window.openPopup = function() { const emptyState = document.getElementById('empty-state'); const outputSection = document.getElementById('output-area') || document.getElementById('output'); const listContainer = document.getElementById('clickbait-results-list'); if(emptyState) emptyState.style.display = 'none'; if(outputSection) outputSection.style.display = 'block'; listContainer.innerHTML = ''; // Use the tool's internal array (usually allTitles or allPOVs) const items = (typeof allTitles !== 'undefined') ? allTitles : (typeof allPOVs !== 'undefined' ? allPOVs : []); items.forEach((t, i) => { const card = document.createElement('div'); card.className = 'tc'; // Use the tool's native title card class card.innerHTML = `
TITLE #${i+1} ${t.type || 'Viral'}
${t.open} ${t.topic} ${t.sass} ${t.twist}. ${t.close}
`; listContainer.appendChild(card); }); // Smooth scroll to results listContainer.scrollIntoView({ behavior: 'smooth', block: 'start' }); }; // Initialize counter setTimeout(() => { if (typeof updateCount === 'function') updateCount(); }, 100); }) .catch(err => { document.getElementById('clickbait-tool-root').innerHTML = "Error loading Clickbait Generator."; console.error(err); }); })();