Ghost Story Snippet Generator

(Uses procedural generation, not actual AI, to create spooky scenes)

Generated Snippet(s)

Could not generate snippets with current selections.

'; return; } snippets.forEach(snippetData => { const entryDiv = document.createElement('div'); entryDiv.classList.add('pgsgv2-snippet-entry'); // Use new class entryDiv.textContent = snippetData.text; snippetResultsDiv.appendChild(entryDiv); }); outputHeading.textContent = `Generated Snippet(s) (${params.count})`; contextInfoElement.textContent = `Overall Parameters: Setting[${params.setting}], Character[${params.character}], Phenomenon[${params.phenomenon}]`; outputArea.style.display = 'block'; pdfBtn.disabled = false; } // --- Generate Button Listener --- generateBtn.addEventListener('click', () => { console.log("[Ghost Story Gen] Generate button clicked."); const settingPref = settingSelect.value; const characterPref = characterSelect.value; const phenomenonPref = phenomenonSelect.value; const quantity = parseInt(quantityInput.value, 10) || 1; const count = Math.max(1, Math.min(5, quantity)); generatedSnippets = []; snippetResultsDiv.innerHTML = ''; let generationAttempts = 0; const maxAttempts = count * 3; for (let i = 0; i < count && generationAttempts < maxAttempts; i++, generationAttempts++) { const setting = (settingPref === 'Any') ? getRandomElement(settings.filter(s => s !== 'Any')) : settingPref; const character = (characterPref === 'Any') ? getRandomElement(characterTypes.filter(c => c !== 'Any')) : characterPref; const phenomenon = (phenomenonPref === 'Any') ? getRandomElement(phenomenonTypes.filter(p => p !== 'Any')) : phenomenonPref; const snippetText = generateSnippet(setting, character, phenomenon); if (snippetText && !snippetText.includes('[')) { generatedSnippets.push({ text: snippetText, params: { setting, character, phenomenon } }); } else { console.warn("Snippet generation failed/incomplete, retrying.", snippetText); i--; } } if(generationAttempts >= maxAttempts) console.error("Max generation attempts reached."); generationParams = { setting: settingPref, character: characterPref, phenomenon: phenomenonPref, count: generatedSnippets.length }; displaySnippets(generatedSnippets, generationParams); console.log(`[Ghost Story Gen] Generated ${generatedSnippets.length} snippets.`); }); // --- Attach PDF Listener --- pdfBtn.addEventListener('click', generatePdf); console.log("[Ghost Story Gen] Event listeners attached."); // --- Initial Setup --- populateDropdowns(); // Call revised populate function pdfBtn.disabled = true; console.log("Ghost Story Snippet Generator Initialized."); }); // End DOMContentLoaded listener })(); // End of IIFE

Key Features of the Tool:

  1. Interactive Inputs: Users can enter a character name, setting, and theme to customize their ghost story.

  2. Instant Story Generation: The tool generates a unique ghost story instantly based on the inputs.

  3. Clean White Design: The white color scheme ensures a modern and professional look.

  4. PDF Download: Users can download the generated story as a PDF, which retains the same color scheme and formatting.

    Benefits for End Users:

    1. Creative Inspiration: Writers and storytellers can use this tool to spark creativity and overcome writer’s block.

    2. Entertainment: Ghost story enthusiasts can enjoy generating and reading unique stories.

    3. Educational Use: Teachers can use this tool to engage students in creative writing exercises.

    4. Personalization: Users can create stories tailored to their preferences by customizing the inputs.

Scroll to Top