${newPost.text}
${newPost.tags}
`; postResultsDiv.appendChild(postCard); } generationParams = { topic: topic, count: count }; outputHeading.textContent = `Generated Posts (${count})`; contextInfoElement.textContent = `Topic Focus: ${topic}`; outputArea.style.display = 'block'; pdfBtn.disabled = false; console.log(`Generated ${count} posts.`); }); // --- PDF Generation Function --- function generatePdf() { console.log("Generating PDF for Social Posts"); if (!generatedPosts || generatedPosts.length === 0) { alert("Please generate some posts first!"); return; } try { const { jsPDF } = window.jspdf; if (!jsPDF) { console.error("jsPDF not loaded!"); alert("Error: PDF library not found."); return; } const doc = new jsPDF(); // Colors const pdfTitleColor = '#6A82FB'; // Blue const pdfHeadingColor = '#FC5C7D'; // Pink const pdfTextColor = '#333333'; // Dark Grey const pdfTagColor = '#6A82FB'; // Blue for tags const pdfContextColor = '#555555'; // Setup const pageHeight = doc.internal.pageSize.height || doc.internal.pageSize.getHeight(); const pageWidth = doc.internal.pageSize.width || doc.internal.pageSize.getWidth(); const margin = 15; let currentY = margin; const lineHeight = 6; // Smaller line height const titleSize = 16; const contextSize = 9; const postTextSize = 10; const tagSize = 9; const contentWidth = pageWidth - (margin * 2); // Helper function addTextBlock(text, size, style, color, yPos, spaceAfter, align = 'left') { doc.setFontSize(size); doc.setTextColor(color); doc.setFont('helvetica', style); const lines = doc.splitTextToSize(text || "", contentWidth); const requiredHeight = lines.length * lineHeight * (size/10); // Estimate height if (yPos + requiredHeight + spaceAfter > pageHeight - margin) { doc.addPage(); currentY = margin; yPos = margin; } doc.text(lines, align === 'center' ? pageWidth / 2 : margin, yPos, { align: align }); return yPos + requiredHeight + spaceAfter; } // Add Title currentY = addTextBlock("Funny Social Media Post Ideas", titleSize, 'bold', pdfTitleColor, currentY, lineHeight, 'center'); // Add Context const contextText = `Generated ${generationParams.count} posts with Topic Focus: ${generationParams.topic}`; currentY = addTextBlock(contextText, contextSize, 'italic', pdfContextColor, currentY); currentY += lineHeight * 1.5; // Add Posts generatedPosts.forEach((post, index) => { const postNumberText = `Post ${index + 1}:`; // Estimate height for number + text + tags + spacing const textLines = doc.splitTextToSize(post.text, contentWidth); const tagLines = doc.splitTextToSize(post.tags, contentWidth); const requiredHeight = (lineHeight * 1.5) + (textLines.length * lineHeight * (postTextSize/10)) + lineHeight + (tagLines.length * lineHeight * (tagSize/10)) + lineHeight*2; if (currentY + requiredHeight > pageHeight - margin) { doc.addPage(); currentY = margin; } // Draw post number currentY = addTextBlock(postNumberText, contextSize + 1, 'bold', pdfHeadingColor, currentY, lineHeight * 0.5); // Draw post text currentY = addTextBlock(post.text, postTextSize, 'normal', pdfTextColor, currentY, lineHeight * 0.2); // Draw tags currentY = addTextBlock(post.tags, tagSize, 'italic', pdfTagColor, currentY, lineHeight * 2); // Add more space after tags }); doc.save('funny-social-posts.pdf'); console.log("Social Posts PDF Generated."); } catch(error) { console.error("Error generating PDF:", error); alert("An error occurred while generating the PDF."); } } // --- Attach Event Listeners --- // generateBtn listener added inside DOMContentLoaded pdfBtn.addEventListener('click', generatePdf); console.log("Social Post Gen Event listeners attached."); // --- Initial Setup --- populateDropdowns(); // Call after elements are assigned pdfBtn.disabled = true; console.log("Social Media Post Generator Initialized."); }); // End DOMContentLoaded listener })(); // End of IIFEKey Features of the Tool
Random Post Generation: The tool generates hilarious and creative social media post ideas with each click.
PDF Download: Users can download their favorite posts as PDFs, complete with the same color scheme and professional formatting.
User-Friendly Interface: The design is clean, intuitive, and visually appealing, making it easy for users to interact with the tool.
Fully Responsive: The tool is designed to work seamlessly on all devices, including desktops, tablets, and mobile phones.
Benefits for End Users
Instant Inspiration: This tool is perfect for social media managers, influencers, or anyone looking for quick and funny post ideas.
Time-Saving: Instead of spending hours brainstorming, users can generate engaging posts in seconds.
Portable Content: The PDF download feature allows users to save and share their favorite posts easily.
Engagement Boost: Humorous and creative posts are more likely to engage followers and increase interaction on social media platforms.

Funny Social Media Post Generator
Generated Posts