Hanaz Writers

Expand Your Story

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(function () { // Prevent duplicate loading if (window.freeExpandLoaded) return; window.freeExpandLoaded = true; // ===================================== // FREE USAGE RESTRICTION // ===================================== const STORAGE_KEY = "hanaz_expand_story_used"; function getFingerprint() { return btoa( navigator.userAgent + screen.width + screen.height + navigator.language + Intl.DateTimeFormat() .resolvedOptions() .timeZone ); } const browserFingerprint = getFingerprint(); // ✅ FREE API const API_URL = "https://ai.hanazwriters.org/free/expand"; // ✅ One-time use let usedOnce = localStorage.getItem(STORAGE_KEY) === "used"; document .getElementById("expandBtn") .addEventListener("click", expandStory); // ===================================== // SHOW PREMIUM BOX IF ALREADY USED // ===================================== if (usedOnce) { document .getElementById("expandBtn") .disabled = true; document .getElementById("storyResultBox") .innerHTML = `

Unlock Premium Version

Free version allows one expansion only.

`; } async function expandStory() { const prompt = document.getElementById("storyPromptInput") .value .trim(); const chapters = document.getElementById("chapterSelect") .value; const resultBox = document.getElementById("storyResultBox"); // 🚫 BLOCK SECOND USE if (usedOnce) { resultBox.innerHTML = `

Unlock Premium Version

Free version allows one expansion only.

`; return; } // Validation if (!prompt) { resultBox.innerHTML = "

Please enter a prompt.

"; return; } resultBox.innerHTML = "

Expanding story...

"; try { const response = await fetch(API_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ prompt, chapters, fingerprint: browserFingerprint }) }); // ===================================== // FREE LIMIT REACHED // ===================================== if (response.status === 403) { resultBox.innerHTML = `

Unlock Premium Version

Free version allows one expansion only.

`; localStorage.setItem( STORAGE_KEY, "used" ); document .getElementById("expandBtn") .disabled = true; return; } if (!response.ok) { throw new Error("Server responded with an error"); } const data = await response.json(); resultBox.innerHTML = `Expanded Story:
${data.expandedStory}`; // ✅ Mark used // ✅ Mark used permanently usedOnce = true; localStorage.setItem( STORAGE_KEY, "used" ); } catch (err) { resultBox.innerHTML = `

Error: ${err.message}

`; } } })();