commit
Add origin host, flavour lines and a Konami-code jam
- Show the hostname the visitor came in on - Show a random flavour line under the spinner - 1 in 4 visits jam the page, persisted in localStorage, until the Konami code is entered; touch screens get an on-screen keypad, everyone gets a hint - Move the meta refresh fallback into noscript so it cannot bypass a jam Co-Authored-By: Sandrone <[email protected]>
diff --git a/index.html b/index.html
index 48e50fd..7c4c21e 100644
--- a/index.html
+++ b/index.html
@@ -7,8 +7,10 @@
<meta name="robots" content="noindex">
<title>Redirecting…</title>
- <!-- No-JS fallback: plain redirect to the homepage after 2s -->
- <meta http-equiv="refresh" content="2;url=https://doughmination.gay/">
+ <!-- No-JS fallback only, so a jammed page can't be redirected out from under the visitor -->
+ <noscript>
+ <meta http-equiv="refresh" content="2;url=https://doughmination.gay/">
+ </noscript>
<link rel="stylesheet" href="/style.css">
<script src="/redirect.js" defer></script>
@@ -16,8 +18,34 @@
<body>
<div class="spinner" aria-hidden="true"></div>
- <p role="status">
+ <p class="origin">
+ You came in via <strong id="origin">this link</strong>
+ </p>
+
+ <p class="working-only" role="status">
Taking you to <a id="target" href="https://doughmination.gay/">doughmination.gay</a>…
</p>
+
+ <p class="working-only flavour" id="flavour"></p>
+
+ <div class="broken-only">
+ <p class="jammed" role="alert">
+ Something jammed. Enter the Konami code to fix it.
+ </p>
+
+ <div class="keypad">
+ <button type="button" data-key="ArrowUp" aria-label="Up">↑</button>
+ <button type="button" data-key="ArrowDown" aria-label="Down">↓</button>
+ <button type="button" data-key="ArrowLeft" aria-label="Left">←</button>
+ <button type="button" data-key="ArrowRight" aria-label="Right">→</button>
+ <button type="button" data-key="b">B</button>
+ <button type="button" data-key="a">A</button>
+ </div>
+
+ <details class="hint">
+ <summary>Hint</summary>
+ <p>↑ ↑ ↓ ↓ ← → ← → B A</p>
+ </details>
+ </div>
</body>
</html>
diff --git a/redirect.js b/redirect.js
index 473bcf0..03559f1 100644
--- a/redirect.js
+++ b/redirect.js
@@ -5,12 +5,107 @@ const destination = "https://doughmination.gay";
// How long the spinner shows before redirecting
const delayMs = 1200;
+// Chance that a fresh visit jams the page
+const breakChance = 0.25;
+
+const brokenKey = "redirectBroken";
+
+const konamiCode = [
+ "ArrowUp",
+ "ArrowUp",
+ "ArrowDown",
+ "ArrowDown",
+ "ArrowLeft",
+ "ArrowRight",
+ "ArrowLeft",
+ "ArrowRight",
+ "b",
+ "a",
+];
+
+const flavourLines = [
+ "Tightening the gears…",
+ "Following the pink thread…",
+ "Warming up the teapot…",
+ "Rolling out the dough…",
+ "Recalibrating the compass…",
+ "Polishing the cogs…",
+ "Asking the cat for directions…",
+ "Untangling the marionette strings…",
+];
+
// Keep the path and query, so fae.is-a.dev/foo goes to doughmination.gay/foo
const target = destination + location.pathname + location.search + location.hash;
document.getElementById("target").href = target;
+document.getElementById("origin").textContent = location.hostname || "this link";
+document.getElementById("flavour").textContent = flavourLines[Math.floor(Math.random() * flavourLines.length)];
+
+// Storage can throw in private windows; the jam then lasts only this load
+function readBroken() {
+ try {
+ return localStorage.getItem(brokenKey) === "1";
+ } catch {
+ return false;
+ }
+}
+
+function writeBroken(isBroken) {
+ try {
+ if (isBroken) {
+ localStorage.setItem(brokenKey, "1");
+ } else {
+ localStorage.removeItem(brokenKey);
+ }
+ } catch {}
+}
+
+function startRedirect() {
+ setTimeout(
+ () => location.replace(target),
+ delayMs,
+ );
+}
+
+function jam() {
+ writeBroken(true);
+ document.body.classList.add("broken");
+
+ const listeners = new AbortController();
+ const enteredKeys = [];
+
+ function press(key) {
+ enteredKeys.push(key);
+
+ if (enteredKeys.length > konamiCode.length) {
+ enteredKeys.shift();
+ }
+
+ if (enteredKeys.join() === konamiCode.join()) {
+ listeners.abort();
+ writeBroken(false);
+ document.body.classList.remove("broken");
+ startRedirect();
+ }
+ }
+
+ document.addEventListener(
+ "keydown",
+ (event) => press(event.key.length === 1 ? event.key.toLowerCase() : event.key),
+ { signal: listeners.signal },
+ );
+
+ for (const button of document.querySelectorAll("[data-key]")) {
+ button.addEventListener(
+ "click",
+ () => press(button.dataset.key),
+ { signal: listeners.signal },
+ );
+ }
+}
-setTimeout(
- () => location.replace(target),
- delayMs,
-);
+if (readBroken() || Math.random() < breakChance) {
+ jam();
+} else {
+ startRedirect();
+}
diff --git a/style.css b/style.css
index 36487b8..91eee59 100644
--- a/style.css
+++ b/style.css
@@ -52,3 +52,127 @@ body {
a {
color: var(--accent);
}
+
+p {
+ margin: 0;
+ text-align: center;
+}
+
+.origin {
+ font-size: 0.9rem;
+ opacity: 0.75;
+}
+
+.flavour {
+ font-style: italic;
+ opacity: 0.75;
+}
+
+.broken-only {
+ display: none;
+}
+
+body.broken .working-only {
+ display: none;
+}
+
+body.broken .broken-only {
+ display: grid;
+ justify-items: center;
+ gap: 1rem;
+}
+
+body.broken .spinner {
+ border-top-color: var(--track);
+ border-right-color: var(--accent);
+ animation: jam 1.6s steps(1) infinite;
+}
+
+body.broken .jammed {
+ animation: glitch 2.4s steps(1) infinite;
+}
+
+@keyframes jam {
+ 0% {
+ transform: rotate(37deg);
+ }
+ 40% {
+ transform: rotate(52deg) translateX(2px);
+ }
+ 45% {
+ transform: rotate(31deg) translateX(-2px);
+ }
+ 50% {
+ transform: rotate(37deg);
+ }
+}
+
+@keyframes glitch {
+ 0% {
+ transform: none;
+ }
+ 92% {
+ transform: skewX(-12deg) translateX(3px);
+ }
+ 95% {
+ transform: skewX(8deg) translateX(-3px);
+ }
+ 98% {
+ transform: none;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ body.broken .spinner,
+ body.broken .jammed {
+ animation: none;
+ }
+}
+
+/* Touch screens only; keyboards type the code directly */
+.keypad {
+ display: none;
+}
+
+@media (hover: none) and (pointer: coarse) {
+ .keypad {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ gap: 0.5rem;
+ }
+}
+
+.hint summary {
+ color: var(--accent);
+ cursor: pointer;
+ text-align: center;
+}
+
+.hint p {
+ margin-top: 0.5rem;
+ font-weight: 600;
+ letter-spacing: 0.1em;
+}
+
+.keypad button {
+ min-width: 2.75rem;
+ min-height: 2.75rem;
+ border: 2px solid var(--accent);
+ border-radius: 0.5rem;
+ background: var(--track);
+ color: var(--text);
+ font: inherit;
+ font-weight: 600;
+ cursor: pointer;
+}
+
+.keypad button:active {
+ background: var(--accent);
+ color: var(--background);
+}
+
+.keypad button:focus-visible {
+ outline: 3px solid var(--accent);
+ outline-offset: 2px;
+}