diff --git a/app.js b/app.js index f6c230f..78a1262 100644 --- a/app.js +++ b/app.js @@ -24,6 +24,12 @@ import { readBooleanSetting, writeBooleanSetting } from "./storage.js"; +import { + applyHorribleAttribute, + bindHorriblePage, + popHorribleStamp, + spawnHorribleConfetti +} from "./horrible.js"; const form = document.querySelector("#clean-form"); const input = document.querySelector("#url-input"); @@ -69,6 +75,7 @@ const totdDetails = document.querySelector("#totd-details"); const totdToggle = document.querySelector("#totd-toggle"); const themeToggle = document.querySelector("#theme-toggle"); const themeColorMeta = document.querySelector('meta[name="theme-color"]'); +const horribleMode = document.querySelector("#horrible-mode"); let cleanedValue = ""; let batchCopyValue = ""; @@ -172,8 +179,32 @@ function setTotdToggleLabel(expanded) { totdToggle.append(wrap); } +function applyHorribleMode(enabled) { + applyHorribleAttribute(document.documentElement, enabled); + if (horribleMode) horribleMode.checked = enabled; + horribleEffects.setEnabled(enabled); +} + +function celebrateHorribleClean() { + spawnHorribleConfetti(document); + popHorribleStamp(document.querySelector(".horrible-pow")); +} + +let horribleEffects = { + setEnabled() {} +}; + +function decorateHorribleToggle() { + if (!horribleMode) return; + const label = horribleMode.closest("label"); + if (!label || label.querySelector(".icon")) return; + horribleMode.after(createIcon("flame", { size: 16 })); +} + function initTheme() { applyTheme(activeTheme()); + applyHorribleMode(readSetting(STORAGE_KEYS.horrible, false)); + decorateHorribleToggle(); window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => { const storage = openThemeStorage(globalThis); if (!storage || readStoredThemePreference(storage) === null) { @@ -425,6 +456,7 @@ function showCleanResult(result, { allowAutoCopy = true, originalValue = "", rev : "Already clean β€” no tracking parameters found."; showMessage(baseMessage, result.unwrapLimitReached ? "info" : "success"); + celebrateHorribleClean(); if (allowAutoCopy && autoCopy.checked) { copyText(cleanedValue).then((copied) => { @@ -487,6 +519,7 @@ function showBatchResults(entries, { allowAutoCopy = true } = {}) { ? `${cleaned.length} URL${cleaned.length === 1 ? "" : "s"} cleaned.` : `${cleaned.length} cleaned, ${failed} failed.`; showMessage(baseMessage, cleaned.length > 0 ? "success" : "error"); + if (cleaned.length > 0) celebrateHorribleClean(); if (allowAutoCopy && autoCopy.checked && batchCopyValue) { copyText(batchCopyValue).then((copied) => { @@ -792,6 +825,26 @@ themeToggle.addEventListener("click", () => { applyTheme(next); }); +if (horribleMode) { + horribleMode.addEventListener("change", () => { + saveSetting(STORAGE_KEYS.horrible, horribleMode.checked); + applyHorribleMode(horribleMode.checked); + }); +} + +horribleEffects = bindHorriblePage({ + stopButton: document.querySelector("#horrible-stop"), + cleanButton: document.querySelector("#clean-form button.primary-button[type='submit']"), + popupHost: document.querySelector("#horrible-popups"), + hitCounter: document.querySelector(".horrible-hit-counter"), + guestbook: document.querySelector("#horrible-guestbook"), + onStop: () => { + saveSetting(STORAGE_KEYS.horrible, false); + applyHorribleMode(false); + } +}); +horribleEffects.setEnabled(document.documentElement.dataset.horrible === "on"); + totdToggle.addEventListener("click", () => { totdCollapsed = !totdCollapsed; saveSetting(STORAGE_KEYS.totdCollapsed, totdCollapsed); diff --git a/horrible.css b/horrible.css new file mode 100644 index 0000000..196f5cc --- /dev/null +++ b/horrible.css @@ -0,0 +1,1013 @@ +/* Horrible mode: 1997 GeoCities fever dream. Off = this file is a no-op. */ + +html[data-horrible="on"] { + --horrible-ink: #1a0033; + --horrible-hot: #ff2d95; + --horrible-lime: #39ff14; + --horrible-cyan: #00e5ff; + --horrible-gold: #ffe600; + --horrible-orange: #ff8c1a; + --horrible-comic: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive; + font-family: var(--horrible-comic); + color: var(--horrible-ink); + background: #ff4ecd; +} + +html[data-horrible="on"] :is(body, button, input, textarea, label, legend, h1, h2, h3, p, li, span, output, code) { + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] body { + background: transparent; + overflow-x: clip; +} + +html[data-horrible="on"]::before { + content: ""; + position: fixed; + inset: 0; + z-index: -2; + pointer-events: none; + background: + radial-gradient(circle at 20% 10%, #ff4ecd 0 18%, transparent 42%), + radial-gradient(circle at 80% 20%, #7cff3e 0 16%, transparent 40%), + radial-gradient(circle at 15% 80%, #00e5ff 0 18%, transparent 44%), + radial-gradient(circle at 85% 75%, #ffe600 0 16%, transparent 42%), + linear-gradient(160deg, #ff4ecd, #ff8c1a, #ffe600, #7cff3e, #00e5ff, #c44dff, #ff4ecd); + background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 280% 280%; +} + +html[data-horrible="on"] .app-shell { + position: relative; + z-index: 2; + max-width: 720px; +} + +html[data-horrible="on"] .construction-banner { + display: block; + position: relative; + z-index: 4; + margin: 0; + padding: 0.45rem 0.75rem; + border-bottom: 3px solid #111; + background: repeating-linear-gradient( + -45deg, + #111 0 14px, + #ffe600 14px 28px, + #111 28px 42px, + #ff4ecd 42px 56px + ); + color: #fff; + font-family: var(--horrible-comic); + font-size: 1.05rem; + letter-spacing: 0.12em; + text-align: center; + text-shadow: 2px 2px 0 #111; +} + +html[data-horrible="on"] .visitor-banner, +html[data-horrible="on"] .horrible-ticker { + display: block; + position: relative; + z-index: 4; + overflow: hidden; + margin: 0; + padding: 0.35rem 0; + border-bottom: 2px dotted #39ff14; + background: #000; + color: #39ff14; + font-family: var(--horrible-comic); + font-size: 0.95rem; + white-space: nowrap; +} + +html[data-horrible="on"] .horrible-ticker { + border-bottom-color: #00e5ff; + color: #00e5ff; +} + +html[data-horrible="on"] .visitor-marquee, +html[data-horrible="on"] .horrible-ticker-track { + display: inline-block; + margin: 0; + padding-left: 100%; +} + +html[data-horrible="on"] .page-toolbar .eyebrow { + color: #fff; + font-family: var(--horrible-comic); + text-shadow: 2px 2px 0 #ff2d95, 4px 4px 0 #00e5ff; +} + +html[data-horrible="on"] h1 { + position: relative; + margin: 1.5rem 0 0.75rem; + font-family: var(--horrible-comic); + font-size: clamp(2.6rem, 9vw, 4.2rem); + line-height: 1; + letter-spacing: 0.02em; + background-image: linear-gradient( + 90deg, + #ff2d95, + #ff8c1a, + #ffe600, + #39ff14, + #00e5ff, + #b14dff, + #ff2d95 + ); + background-size: 220% 100%; + -webkit-background-clip: text; + background-clip: text; + color: transparent; + filter: + drop-shadow(4px 4px 0 #ffe600) + drop-shadow(8px 8px 0 #39ff14) + drop-shadow(12px 12px 0 #00e5ff) + drop-shadow(16px 16px 0 #ff2d95); +} + +html[data-horrible="on"] h1::before { + content: "NEW!"; + position: absolute; + left: -0.4rem; + top: -1.15rem; + padding: 0.2rem 0.45rem; + border: 2px solid #fff; + background: #ff2d95; + color: #ffe600; + font-family: var(--horrible-comic); + font-size: 0.85rem; + letter-spacing: 0.08em; + transform: rotate(-18deg); + filter: none; + -webkit-text-fill-color: #ffe600; +} + +html[data-horrible="on"] h1::after { + content: "Β© 2026 ALL RIGHTS RESERVED"; + position: absolute; + right: 0; + bottom: -1.1rem; + color: #1a0033; + font-family: var(--horrible-comic); + font-size: 0.65rem; + letter-spacing: 0.04em; + filter: none; + -webkit-text-fill-color: #1a0033; +} + +html[data-horrible="on"] .intro { + margin-top: 1.6rem; + color: #3b0066; + font-family: var(--horrible-comic); + font-size: 1.05rem; +} + +html[data-horrible="on"] .clean-form { + margin-top: 1.25rem; + padding: 1rem 1.1rem 1.15rem; + border: 5px dashed #ff2d95; + background: #fff38a; + box-shadow: 10px 10px 0 #00e5ff, -4px 6px 0 #39ff14; + transform: rotate(-2deg); +} + +html[data-horrible="on"] .clean-form label[for="url-input"] { + color: #9b0870; + font-family: var(--horrible-comic); + font-size: 1.15rem; + letter-spacing: 0.06em; +} + +html[data-horrible="on"] #url-input { + border: 3px inset #fff; + background: #fff; + color: #111; + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .input-row { + align-items: center; + justify-content: space-between; +} + +html[data-horrible="on"] .input-row .secondary-button { + border: 3px outset #c47bff; + background: #c47bff; + color: #fff; + font-family: var(--horrible-comic); + box-shadow: 3px 3px 0 #3b0066; +} + +html[data-horrible="on"] .input-row .primary-button { + position: relative; + z-index: 3; + width: 9.6rem; + height: 9.6rem; + padding: 0.6rem; + border: 4px solid #fff; + border-radius: 50%; + background: #ffe600; + color: #ff2d95; + font-family: var(--horrible-comic); + font-size: 1.2rem; + line-height: 1.1; + text-transform: uppercase; + box-shadow: + 0 0 0 4px #ff2d95, + 0 0 18px #ffe600; + transform: rotate(-8deg); +} + +html[data-horrible="on"] .input-row .primary-button::before { + content: ""; + position: absolute; + inset: -1.15rem; + z-index: -1; + background: repeating-conic-gradient(#ffe600 0 9deg, transparent 9deg 20deg); + border-radius: 50%; +} + +html[data-horrible="on"] .input-row .primary-button.horrible-dodge-a { + transform: translate(4.4rem, -1.6rem) rotate(-18deg); +} + +html[data-horrible="on"] .input-row .primary-button.horrible-dodge-b { + transform: translate(-3.8rem, 2rem) rotate(14deg); +} + +html[data-horrible="on"] .input-row .primary-button.horrible-dodge-c { + transform: translate(3rem, 2.4rem) rotate(-6deg); +} + +html[data-horrible="on"] .settings legend { + color: #9b0870; + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .setting { + color: #1a0033; + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .setting:nth-of-type(1) { transform: rotate(-4deg); } +html[data-horrible="on"] .setting:nth-of-type(2) { transform: rotate(5deg); } +html[data-horrible="on"] .setting:nth-of-type(3) { transform: rotate(-7deg); } +html[data-horrible="on"] .setting:nth-of-type(4) { transform: rotate(6deg); } +html[data-horrible="on"] .setting:nth-of-type(5) { transform: rotate(-2deg); } + +html[data-horrible="on"] .setting input[type="checkbox"] { + border: 2px solid #ff2d95; + background: #fff; +} + +html[data-horrible="on"] .setting input[type="checkbox"]:checked { + border-color: #39ff14; + background-color: #39ff14; +} + +html[data-horrible="on"] .message[data-kind="success"] { + padding: 0.4rem 0.6rem; + border: 3px ridge #39ff14; + background: #39ff14; + color: #062; + font-family: var(--horrible-comic); + letter-spacing: 0.04em; +} + +html[data-horrible="on"] .result-panel, +html[data-horrible="on"] .fingerprint-summary { + border-color: #fff; + background: rgba(255, 255, 255, 0.18); + box-shadow: 6px 6px 0 #00e5ff; +} + +html[data-horrible="on"] .result-panel { + transform: skew(-1.4deg) rotate(0.8deg); +} + +html[data-horrible="on"] h2, +html[data-horrible="on"] h3 { + font-family: var(--horrible-comic); + color: #1a0033; +} + +html[data-horrible="on"] .url-output, +html[data-horrible="on"] .url-parts dd, +html[data-horrible="on"] .totd-example-url, +html[data-horrible="on"] .totd-name, +html[data-horrible="on"] .batch-list .batch-url { + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .fingerprint-score { + width: 7.2rem; + height: 7.2rem; + min-width: 7.2rem; + border: 6px solid #fff; + border-radius: 50%; + background: #ffe600; + color: #1a0033; + box-shadow: 0 0 0 4px #ff2d95; + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .fingerprint-count-value { + font-size: 2.4rem; +} + +html[data-horrible="on"] .removed-list { + gap: 0.7rem 0.9rem; +} + +html[data-horrible="on"] .removed-list li { + border: 2px dashed #1a0033; + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .removed-list li:nth-child(3n + 1) { + background: #ff90e8; + transform: rotate(-8deg) translate(0.3rem, 0.2rem); +} + +html[data-horrible="on"] .removed-list li:nth-child(3n + 2) { + background: #7cff3e; + transform: rotate(7deg) translate(-0.2rem, 0.35rem); +} + +html[data-horrible="on"] .removed-list li:nth-child(3n) { + background: #00e5ff; + transform: rotate(-3deg) translate(0.55rem, -0.15rem); +} + +html[data-horrible="on"] .totd { + border: 10px solid #c4a574; + border-radius: 18px 18px 8px 8px; + background: + linear-gradient(#f7e7c2, #f0d9a0); + box-shadow: inset 0 0 24px #c4a574, 8px 8px 0 #6b4a1b; + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .totd-label { + color: #6b4a1b; + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .privacy-note { + color: #1a0033; + font-family: var(--horrible-comic); + text-shadow: 1px 1px 0 #ffe600; +} + +html[data-horrible="on"] .horrible-footer { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + margin-top: 1rem; +} + +html[data-horrible="on"] .horrible-best-viewed { + margin: 0; + color: #1a0033; + font-family: var(--horrible-comic); + letter-spacing: 0.04em; +} + +html[data-horrible="on"] .horrible-hit-counter { + margin: 0; + padding: 0.2rem 0.55rem; + border: 4px double #39ff14; + background: #111; + color: #39ff14; + font-family: var(--horrible-comic); + letter-spacing: 0.16em; +} + +html[data-horrible="on"] .horrible-webring, +html[data-horrible="on"] .horrible-guestbook { + display: block; + margin: 0.6rem 0 0; + color: #1a0033; + font-family: var(--horrible-comic); +} + +html[data-horrible="on"] .horrible-webring button, +html[data-horrible="on"] .horrible-guestbook { + border: 2px outset #ddd; + background: #eee; + color: blue; + font-family: var(--horrible-comic); + text-decoration: underline; +} + +html[data-horrible="on"] .horrible-seal { + display: flex; + align-items: center; + justify-content: center; + width: 7.5rem; + height: 7.5rem; + margin: 1rem auto 0; + border: 6px double #c00; + border-radius: 50%; + background: #fff8dc; + color: #c00; + font-family: var(--horrible-comic); + font-size: 0.72rem; + letter-spacing: 0.04em; + text-align: center; +} + +html[data-horrible="on"] .horrible-stop { + display: inline-flex; + position: fixed; + top: 0.7rem; + right: 0.7rem; + z-index: 2147483000; + align-items: center; + justify-content: center; + min-height: 44px; + padding: 0.45rem 0.8rem; + border: 3px solid #111; + border-radius: 4px; + background: #111; + color: #ffe600; + font-family: var(--horrible-comic); + font-size: 0.95rem; + letter-spacing: 0.06em; + text-transform: uppercase; + box-shadow: 4px 4px 0 #ffe600; + pointer-events: auto; + transform: none !important; + animation: none !important; +} + +html[data-horrible="on"] .horrible-stop:focus-visible { + outline: 3px solid #fff; + outline-offset: 3px; +} + +html[data-horrible="on"] .horrible-dvd { + display: flex; + position: fixed; + top: 12vh; + left: 6vw; + z-index: 6; + align-items: center; + justify-content: center; + width: 8.6rem; + padding: 0.35rem 0.5rem; + border: 3px solid #fff; + background: #111; + color: #39ff14; + font-family: var(--horrible-comic); + letter-spacing: 0.08em; + pointer-events: none; +} + +html[data-horrible="on"] .horrible-stars, +html[data-horrible="on"] .horrible-confetti, +html[data-horrible="on"] .horrible-toasters { + display: block; + position: fixed; + inset: 0; + z-index: 1; + pointer-events: none; + overflow: hidden; +} + +html[data-horrible="on"] .horrible-stars span { + position: absolute; + width: 7px; + height: 7px; + background: #fff; + box-shadow: 0 0 6px #ffe600; +} + +html[data-horrible="on"] .horrible-stars span:nth-child(1) { top: 12%; left: 8%; } +html[data-horrible="on"] .horrible-stars span:nth-child(2) { top: 22%; left: 78%; } +html[data-horrible="on"] .horrible-stars span:nth-child(3) { top: 48%; left: 18%; } +html[data-horrible="on"] .horrible-stars span:nth-child(4) { top: 63%; left: 88%; } +html[data-horrible="on"] .horrible-stars span:nth-child(5) { top: 81%; left: 28%; } +html[data-horrible="on"] .horrible-stars span:nth-child(6) { top: 16%; left: 52%; } +html[data-horrible="on"] .horrible-stars span:nth-child(7) { top: 72%; left: 62%; } +html[data-horrible="on"] .horrible-stars span:nth-child(8) { top: 38%; left: 92%; } + +html[data-horrible="on"] .horrible-confetti span { + position: absolute; + font-size: 1.4rem; +} + +html[data-horrible="on"] .horrible-confetti span:nth-child(1) { top: 18%; left: 4%; } +html[data-horrible="on"] .horrible-confetti span:nth-child(2) { top: 44%; right: 5%; } +html[data-horrible="on"] .horrible-confetti span:nth-child(3) { bottom: 18%; left: 9%; } +html[data-horrible="on"] .horrible-confetti span:nth-child(4) { top: 8%; right: 18%; } +html[data-horrible="on"] .horrible-confetti span:nth-child(5) { bottom: 10%; right: 12%; } + +html[data-horrible="on"] .horrible-toasters span { + position: absolute; + width: 2.4rem; + height: 1.5rem; + border: 2px solid #6b3a1f; + border-radius: 0.2rem 0.2rem 0.35rem 0.35rem; + background: #c47a3a; +} + +html[data-horrible="on"] .horrible-toasters span:nth-child(1) { top: 20%; left: -10%; } +html[data-horrible="on"] .horrible-toasters span:nth-child(2) { top: 55%; left: -16%; } +html[data-horrible="on"] .horrible-toasters span:nth-child(3) { top: 78%; left: -8%; } + +html[data-horrible="on"] .horrible-popups { + display: block; +} + +html[data-horrible="on"] .horrible-joke-tag { + display: inline-block; + margin: 0 0 0.4rem; + padding: 0.1rem 0.4rem; + border: 2px dashed #111; + border-radius: 999px; + background: #ffe600; + color: #1a0033; + font-size: 0.75rem; + letter-spacing: 0.03em; +} + +html[data-horrible="on"] .horrible-popup { + position: fixed; + z-index: 60; + width: min(16.5rem, calc(100vw - 2.4rem)); + padding: 0.7rem 0.75rem 0.8rem; + border: 4px solid #111; + border-radius: 1.4rem 0.4rem 1.6rem 0.7rem; + color: #1a0033; + box-shadow: 8px 8px 0 #111; +} + +html[data-horrible="on"] .horrible-popup h2 { + margin: 0 2.2rem 0.35rem 0; + font-size: 1.05rem; + line-height: 1.2; +} + +html[data-horrible="on"] .horrible-popup p { + margin: 0 0 0.55rem; + font-size: 0.92rem; +} + +html[data-horrible="on"] .horrible-popup-skin-1 { background: #ff90e8; } +html[data-horrible="on"] .horrible-popup-skin-2 { background: #7cff3e; } +html[data-horrible="on"] .horrible-popup-skin-3 { background: #00e5ff; } +html[data-horrible="on"] .horrible-popup-skin-4 { background: #ffe600; } + +html[data-horrible="on"] .horrible-popup-slot-0 { top: 18%; left: 3%; } +html[data-horrible="on"] .horrible-popup-slot-1 { top: 30%; left: 58%; } +html[data-horrible="on"] .horrible-popup-slot-2 { top: 46%; left: 5%; } +html[data-horrible="on"] .horrible-popup-slot-3 { top: 54%; left: 56%; } +html[data-horrible="on"] .horrible-popup-slot-4 { top: 68%; left: 8%; } +html[data-horrible="on"] .horrible-popup-slot-5 { top: 72%; left: 52%; } +html[data-horrible="on"] .horrible-popup-slot-6 { top: auto; bottom: 6%; left: 18%; } +html[data-horrible="on"] .horrible-popup-slot-7 { top: 38%; left: 28%; } + +html[data-horrible="on"] .horrible-popup-x { + position: absolute; + top: 0.4rem; + right: 0.45rem; + width: 2rem; + height: 2rem; + padding: 0; + border: 3px solid #111; + border-radius: 50%; + background: #fff; + color: #c00; + font-size: 1rem; + line-height: 1; +} + +html[data-horrible="on"] .horrible-popup-x.horrible-dodge-a { transform: translate(-2.4rem, 1.2rem); } +html[data-horrible="on"] .horrible-popup-x.horrible-dodge-b { transform: translate(-3.2rem, 2rem); } +html[data-horrible="on"] .horrible-popup-x.horrible-dodge-c { transform: translate(-1.4rem, 2.6rem); } + +html[data-horrible="on"] .horrible-popup-action { + border: 3px solid #111; + border-radius: 999px; + background: #fff; + color: #1a0033; + padding: 0.35rem 0.7rem; +} + +html[data-horrible="on"] .horrible-loading { + display: block; + position: fixed; + left: 0; + right: 22%; + bottom: 0; + z-index: 35; + padding: 0.55rem 0.8rem 0.7rem; + border-top: 4px solid #111; + background: #ff2d95; + color: #fff; + pointer-events: none; +} + +html[data-horrible="on"] .horrible-loading p { + margin: 0 0 0.35rem; +} + +html[data-horrible="on"] .horrible-loading-track { + height: 1rem; + border: 3px solid #111; + background: #fff; +} + +html[data-horrible="on"] .horrible-loading-bar { + display: block; + width: 99%; + height: 100%; + background: repeating-linear-gradient(45deg, #ffe600 0 10px, #39ff14 10px 20px); +} + +html[data-horrible="on"] .horrible-spin-banner { + display: flex; + position: fixed; + left: 0.6rem; + bottom: 5.6rem; + z-index: 8; + width: 8.4rem; + height: 8.4rem; + align-items: center; + justify-content: center; + padding: 0.6rem; + border: 5px dashed #ffe600; + border-radius: 50%; + background: #1a0033; + color: #39ff14; + text-align: center; + font-size: 0.72rem; + pointer-events: none; +} + +html[data-horrible="on"] .horrible-pow { + display: none; + position: fixed; + top: 28%; + left: 50%; + z-index: 55; + margin: 0; + padding: 0.4rem 0.7rem; + border: 4px solid #111; + background: #ffe600; + color: #c00; + font-family: var(--horrible-comic); + font-size: clamp(1.6rem, 6vw, 2.8rem); + letter-spacing: 0.04em; + pointer-events: none; + transform: translate(-50%, -50%) rotate(-8deg); +} + +html[data-horrible="on"] .horrible-pow.is-popping { + display: block; +} + +html[data-horrible="on"] .horrible-trail-dot { + position: fixed; + left: var(--tx); + top: var(--ty); + z-index: 50; + width: 11px; + height: 11px; + margin: -5px 0 0 -5px; + border-radius: 50%; + background: #ffe600; + box-shadow: 0 0 8px #ff2d95; + pointer-events: none; +} + +html[data-horrible="on"] .horrible-burst { + position: fixed; + inset: 0; + z-index: 48; + pointer-events: none; +} + +html[data-horrible="on"] .horrible-burst-piece { + position: absolute; + left: 50%; + top: 42%; + width: 10px; + height: 14px; + background: #ff2d95; +} + +html[data-horrible="on"] .horrible-burst-piece:nth-child(4n) { background: #39ff14; } +html[data-horrible="on"] .horrible-burst-piece:nth-child(4n + 1) { background: #00e5ff; } +html[data-horrible="on"] .horrible-burst-piece:nth-child(4n + 2) { background: #ffe600; } +html[data-horrible="on"] .horrible-burst-piece:nth-child(4n + 3) { background: #ff8c1a; } + +html[data-horrible="on"] .theme-toggle { + border: 2px dashed #ffe600; + background: rgba(0, 0, 0, 0.25); + color: #ffe600; +} + +@media (max-width: 580px) { + html[data-horrible="on"] .input-row .primary-button { + order: 0; + flex: none; + width: 8.6rem; + max-width: 8.6rem; + height: 8.6rem; + } +} + +@media (prefers-reduced-motion: no-preference) { + html[data-horrible="on"]::before { + animation: horrible-bg-shift 28s linear infinite, horrible-hue 40s linear infinite; + } + + html[data-horrible="on"] .construction-banner { + animation: horrible-wobble 2.4s ease-in-out infinite; + } + + html[data-horrible="on"] .visitor-marquee { + animation: horrible-marquee 18s linear infinite; + } + + html[data-horrible="on"] .horrible-ticker-track { + animation: horrible-marquee 22s linear infinite; + } + + html[data-horrible="on"] h1 { + animation: horrible-rainbow-shift 8s linear infinite, horrible-title-drift 6s ease-in-out infinite; + } + + html[data-horrible="on"] h1::before { + animation: horrible-spin 6s linear infinite; + } + + html[data-horrible="on"] .intro { + animation: horrible-wobble 3.2s ease-in-out infinite; + } + + html[data-horrible="on"] .clean-form { + animation: horrible-card-pulse 3.6s ease-in-out infinite; + } + + html[data-horrible="on"] #url-input { + animation: horrible-input-jiggle 4.8s ease-in-out infinite; + } + + html[data-horrible="on"] .horrible-popup { + animation: horrible-popup-wiggle 1.6s ease-in-out infinite; + } + + html[data-horrible="on"] .horrible-popup-slot-1, + html[data-horrible="on"] .horrible-popup-slot-3, + html[data-horrible="on"] .horrible-popup-slot-5 { + animation-direction: reverse; + } + + html[data-horrible="on"] .horrible-loading-bar { + animation: horrible-loading-shimmer 1.2s linear infinite; + } + + html[data-horrible="on"] .horrible-spin-banner { + animation: horrible-spin 8s linear infinite; + } + + html[data-horrible="on"] .input-row .primary-button { + animation: horrible-blink 1s step-end infinite; + transition: transform 0.22s ease; + } + + html[data-horrible="on"] .setting:nth-of-type(1) { animation: horrible-wobble 3.1s ease-in-out infinite; } + html[data-horrible="on"] .setting:nth-of-type(2) { animation: horrible-wobble 2.7s ease-in-out infinite reverse; } + html[data-horrible="on"] .setting:nth-of-type(3) { animation: horrible-wobble 3.4s ease-in-out infinite; } + html[data-horrible="on"] .setting:nth-of-type(4) { animation: horrible-wobble 2.9s ease-in-out infinite reverse; } + html[data-horrible="on"] .setting:nth-of-type(5) { animation: horrible-wobble 3.6s ease-in-out infinite; } + + html[data-horrible="on"] .result-panel { + animation: horrible-card-pulse 4.2s ease-in-out infinite; + } + + html[data-horrible="on"] .fingerprint-score { + animation: horrible-score-pulse 2.2s ease-in-out infinite; + } + + html[data-horrible="on"] .removed-list li:nth-child(3n + 1) { + animation: horrible-chip-spin 7s linear infinite; + } + + html[data-horrible="on"] .removed-list li:nth-child(3n + 2) { + animation: horrible-chip-spin 8s linear infinite reverse; + } + + html[data-horrible="on"] .removed-list li:nth-child(3n) { + animation: horrible-chip-spin 6.5s linear infinite; + } + + html[data-horrible="on"] .totd { + animation: horrible-scroll-drift 5s ease-in-out infinite; + } + + html[data-horrible="on"] .horrible-dvd { + animation: horrible-dvd 18s linear infinite, horrible-hue 7s linear infinite; + } + + html[data-horrible="on"] .horrible-stars span { + animation: horrible-twinkle 1.2s step-end infinite; + } + + html[data-horrible="on"] .horrible-stars span:nth-child(odd) { + animation-delay: 0.6s; + } + + html[data-horrible="on"] .horrible-confetti span:nth-child(1) { animation: horrible-float 5.2s ease-in-out infinite; } + html[data-horrible="on"] .horrible-confetti span:nth-child(2) { animation: horrible-float 6s ease-in-out infinite reverse; } + html[data-horrible="on"] .horrible-confetti span:nth-child(3) { animation: horrible-spin 8s linear infinite; } + html[data-horrible="on"] .horrible-confetti span:nth-child(4) { animation: horrible-float 4.6s ease-in-out infinite; } + html[data-horrible="on"] .horrible-confetti span:nth-child(5) { animation: horrible-spin 7s linear infinite reverse; } + + html[data-horrible="on"] .horrible-toasters span:nth-child(1) { animation: horrible-toaster 14s linear infinite; } + html[data-horrible="on"] .horrible-toasters span:nth-child(2) { animation: horrible-toaster 17s linear infinite; animation-delay: -6s; } + html[data-horrible="on"] .horrible-toasters span:nth-child(3) { animation: horrible-toaster 15s linear infinite; animation-delay: -10s; } + + html[data-horrible="on"] .horrible-seal { + animation: horrible-spin 10s linear infinite; + } + + html[data-horrible="on"] .horrible-hit-counter { + animation: horrible-wobble 2.8s ease-in-out infinite; + } + + html[data-horrible="on"] .page-toolbar .eyebrow { + animation: horrible-rainbow-text 6s linear infinite; + } + + html[data-horrible="on"] .horrible-pow.is-popping { + animation: horrible-pow-pop 1.6s ease-out forwards; + } + + html[data-horrible="on"] .horrible-trail-dot { + animation: horrible-trail-fade 0.7s linear forwards; + } + + html[data-horrible="on"] .horrible-burst-piece { + animation: horrible-burst 1.8s ease-out forwards; + } + + html[data-horrible="on"] .horrible-burst-piece:nth-child(1) { --dx: -8rem; --dy: -6rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(2) { --dx: 7rem; --dy: -7rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(3) { --dx: -3rem; --dy: 8rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(4) { --dx: 9rem; --dy: 4rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(5) { --dx: -10rem; --dy: 1rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(6) { --dx: 2rem; --dy: -9rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(7) { --dx: 6rem; --dy: 8rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(8) { --dx: -6rem; --dy: -9rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(9) { --dx: 10rem; --dy: -2rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(10) { --dx: -1rem; --dy: 9rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(11) { --dx: 4rem; --dy: -5rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(12) { --dx: -7rem; --dy: 6rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(13) { --dx: 8rem; --dy: 1rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(14) { --dx: -9rem; --dy: -3rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(15) { --dx: 1rem; --dy: -8rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(16) { --dx: 5rem; --dy: 7rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(17) { --dx: -4rem; --dy: -7rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(18) { --dx: 3rem; --dy: 9rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(19) { --dx: -8rem; --dy: 8rem; } + html[data-horrible="on"] .horrible-burst-piece:nth-child(20) { --dx: 9rem; --dy: -6rem; } +} + +@media (prefers-reduced-motion: reduce) { + html[data-horrible="on"] *, + html[data-horrible="on"] *::before, + html[data-horrible="on"] *::after { + animation: none !important; + transition: none !important; + } +} + +@keyframes horrible-hue { + to { filter: hue-rotate(360deg); } +} + +@keyframes horrible-bg-shift { + 0% { background-position: 0 0, 0 0, 0 0, 0 0, 0% 0%; } + 50% { background-position: 0 0, 0 0, 0 0, 0 0, 100% 60%; } + 100% { background-position: 0 0, 0 0, 0 0, 0 0, 0% 0%; } +} + +@keyframes horrible-marquee { + from { transform: translateX(0); } + to { transform: translateX(-100%); } +} + +@keyframes horrible-rainbow-shift { + to { background-position: 220% 0; } +} + +@keyframes horrible-rainbow-text { + 0%, 100% { color: #fff; } + 33% { color: #ffe600; } + 66% { color: #00e5ff; } +} + +@keyframes horrible-title-drift { + 0%, 100% { transform: translateX(0) rotate(-1deg); } + 50% { transform: translateX(0.4rem) rotate(1deg); } +} + +@keyframes horrible-wobble { + 0%, 100% { transform: rotate(-2deg); } + 50% { transform: rotate(2deg); } +} + +@keyframes horrible-popup-wiggle { + 0%, 100% { transform: rotate(-2deg) translateY(0); } + 50% { transform: rotate(2deg) translateY(-4px); } +} + +@keyframes horrible-input-jiggle { + 0%, 78%, 100% { transform: translateX(0); } + 82% { transform: translateX(-5px) rotate(-0.5deg); } + 86% { transform: translateX(5px) rotate(0.5deg); } + 90% { transform: translateX(-3px); } + 94% { transform: translateX(2px); } +} + +@keyframes horrible-loading-shimmer { + from { filter: brightness(1); } + 50% { filter: brightness(1.18); } + to { filter: brightness(1); } +} + +@keyframes horrible-card-pulse { + 0%, 100% { box-shadow: 10px 10px 0 #00e5ff, -4px 6px 0 #39ff14; } + 50% { box-shadow: 14px 14px 0 #ff2d95, -8px 8px 0 #ffe600; } +} + +@keyframes horrible-blink { + 50% { filter: brightness(1.22); } +} + +@keyframes horrible-score-pulse { + 0%, 100% { transform: scale(1); } + 50% { transform: scale(1.06); } +} + +@keyframes horrible-chip-spin { + from { transform: rotate(-8deg); } + to { transform: rotate(352deg); } +} + +@keyframes horrible-scroll-drift { + 0%, 100% { transform: translateY(0) rotate(-0.6deg); } + 50% { transform: translateY(0.35rem) rotate(0.6deg); } +} + +@keyframes horrible-dvd { + 0% { transform: translate(0, 0); } + 20% { transform: translate(62vw, 18vh); } + 40% { transform: translate(8vw, 58vh); } + 60% { transform: translate(54vw, 68vh); } + 80% { transform: translate(18vw, 8vh); } + 100% { transform: translate(0, 0); } +} + +@keyframes horrible-twinkle { + 0%, 49% { opacity: 1; } + 50%, 100% { opacity: 0.2; } +} + +@keyframes horrible-float { + 0%, 100% { transform: translateY(0); } + 50% { transform: translateY(-12px); } +} + +@keyframes horrible-spin { + to { transform: rotate(360deg); } +} + +@keyframes horrible-toaster { + from { transform: translateX(0) translateY(0); } + to { transform: translateX(120vw) translateY(-18vh); } +} + +@keyframes horrible-pow-pop { + 0% { transform: translate(-50%, -50%) rotate(-8deg) scale(0.4); opacity: 0; } + 20% { transform: translate(-50%, -50%) rotate(-8deg) scale(1.15); opacity: 1; } + 70% { opacity: 1; } + 100% { transform: translate(-50%, -50%) rotate(-8deg) scale(1); opacity: 0; } +} + +@keyframes horrible-trail-fade { + to { transform: scale(0.2); opacity: 0; } +} + +@keyframes horrible-burst { + from { transform: translate(-50%, -50%) scale(1); opacity: 1; } + to { transform: translate(calc(-50% + var(--dx, 6rem)), calc(-50% + var(--dy, -6rem))) scale(0.4); opacity: 0; } +} diff --git a/horrible.js b/horrible.js new file mode 100644 index 0000000..6f5e826 --- /dev/null +++ b/horrible.js @@ -0,0 +1,359 @@ +import { STORAGE_KEYS, openAppStorage, readBooleanSetting, writeBooleanSetting } from "./storage.js"; + +export const HORRIBLE_STORAGE_KEY = STORAGE_KEYS.horrible; +export const HORRIBLE_HITS_KEY = "url-cleaner.horrible-hits"; +export const HORRIBLE_DODGE_CLASSES = ["horrible-dodge-a", "horrible-dodge-b", "horrible-dodge-c"]; +export const HORRIBLE_DODGE_LIMIT = 3; +export const HORRIBLE_POPUP_CAP = 8; +export const HORRIBLE_POPUP_CAP_REDUCED = 2; +export const HORRIBLE_POPUP_MULTIPLY = 2; +export const HORRIBLE_CLEAN_WINDOW_EVERY = 3; +export const HORRIBLE_CLEAN_WINDOW_MS = 6000; +export const HORRIBLE_JOKE_TAG = "it's a joke 🀑"; + +export const HORRIBLE_POPUP_COPY = [ + { title: "HOT TRACKERS IN YOUR AREA", body: "want to follow you!!!", action: "wow ok" }, + { title: "YOUR LAPTOP HAS 47 UTM PARAMETERS!!!", body: "CLEAN NOW or they will tell your bookmarks.", action: "i guess" }, + { title: "Congratulations, you are the 1,000,000th URL!", body: "You won nothing. Absolutely nothing.", action: "claim nothing" }, + { title: "Download more RAM", body: "We will not. This button does not download anything.", action: "no thanks" }, + { title: "Your fbclid misses you", body: "It wrote you a sad little query string.", action: "tell it no" }, + { title: "Click here to remove 1 weird tracker", body: "Just kidding. That would be too easy.", action: "nice try" }, + { title: "URGENT: gclid ate the group project", body: "It left a note that says utm_medium=chaos.", action: "unbelievable" }, + { title: "Install Toolbar 99 (joke)", body: "There is no toolbar. There is no installer. There is only this box.", action: "decline" } +]; + +export function readHorriblePreference(storage) { + return readBooleanSetting(storage, STORAGE_KEYS.horrible, false); +} + +export function writeHorriblePreference(storage, enabled) { + writeBooleanSetting(storage, STORAGE_KEYS.horrible, Boolean(enabled)); +} + +export function toggleHorribleMode(currentlyEnabled, storage) { + const next = !currentlyEnabled; + writeHorriblePreference(storage, next); + return next; +} + +export function applyHorribleAttribute(documentElement, enabled) { + if (!documentElement) return; + if (enabled) { + documentElement.dataset.horrible = "on"; + } else { + delete documentElement.dataset.horrible; + } +} + +export function openHorribleStorage(globalObject) { + return openAppStorage(globalObject); +} + +export function resolveHorribleMode(globalObject) { + const storage = openHorribleStorage(globalObject); + return storage ? readHorriblePreference(storage) : false; +} + +export function prefersReducedMotion(globalObject = globalThis) { + try { + return Boolean(globalObject.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches); + } catch { + return false; + } +} + +export function nextDodgeClass(step) { + return HORRIBLE_DODGE_CLASSES[Math.abs(step) % HORRIBLE_DODGE_CLASSES.length]; +} + +export function resolveCleanDodge(dodges, tiredUntil, now, restMs = 4000) { + if (now < tiredUntil) return { action: "stay", dodges, tiredUntil }; + if (dodges >= HORRIBLE_DODGE_LIMIT) { + return { action: "rest", dodges: 0, tiredUntil: now + restMs }; + } + return { action: "dodge", dodges: dodges + 1, tiredUntil }; +} + +export function formatHitCounter(count) { + const safe = Number.isFinite(count) ? Math.max(0, Math.trunc(count)) : 1337; + return String(safe).padStart(8, "0"); +} + +export function bumpHitCounter(storage, current = 1337) { + const next = (Number.parseInt(String(current), 10) || 1337) + 1; + if (storage) { + try { + storage.setItem(HORRIBLE_HITS_KEY, String(next)); + } catch { + // The joke counter is optional. + } + } + return next; +} + +export function popupCap(reducedMotion) { + return reducedMotion ? HORRIBLE_POPUP_CAP_REDUCED : HORRIBLE_POPUP_CAP; +} + +export function popupsToSpawnOnClose(openCount, cap, multiply = HORRIBLE_POPUP_MULTIPLY, inCleanWindow = false) { + if (inCleanWindow) return 0; + const afterRemoval = Math.max(0, openCount - 1); + return Math.min(multiply, Math.max(0, cap - afterRemoval)); +} + +export function nextCleanWindowUntil(closesAfterThis, now, every = HORRIBLE_CLEAN_WINDOW_EVERY, windowMs = HORRIBLE_CLEAN_WINDOW_MS) { + if (closesAfterThis > 0 && closesAfterThis % every === 0) return now + windowMs; + return 0; +} + +export function pickPopupSlot(usedSlots, slotCount = HORRIBLE_POPUP_CAP) { + for (let index = 0; index < slotCount; index += 1) { + if (!usedSlots.has(index)) return index; + } + return 0; +} + +export function nextPopupCopy(index) { + return HORRIBLE_POPUP_COPY[Math.abs(index) % HORRIBLE_POPUP_COPY.length]; +} + +export function spawnHorribleConfetti(root, { pieceCount = 20, ttlMs = 1800 } = {}) { + if (!root || prefersReducedMotion(root.defaultView || globalThis)) return null; + if (root.documentElement?.dataset.horrible !== "on") return null; + + const burst = root.createElement("div"); + burst.className = "horrible-burst"; + burst.setAttribute("aria-hidden", "true"); + for (let index = 0; index < pieceCount; index += 1) { + const piece = root.createElement("span"); + piece.className = "horrible-burst-piece"; + burst.append(piece); + } + root.body.append(burst); + root.defaultView?.setTimeout(() => burst.remove(), ttlMs); + return burst; +} + +export function popHorribleStamp(stamp) { + if (!stamp || prefersReducedMotion()) return; + stamp.classList.add("is-popping"); + globalThis.setTimeout(() => stamp.classList.remove("is-popping"), 1600); +} + +function bindRunawayClose(button, root) { + if (!button) return; + let dodges = 0; + let tiredUntil = 0; + button.addEventListener("mouseenter", () => { + if (prefersReducedMotion(root.defaultView || globalThis)) return; + const now = Date.now(); + const next = resolveCleanDodge(dodges, tiredUntil, now); + dodges = next.dodges; + tiredUntil = next.tiredUntil; + button.classList.remove(...HORRIBLE_DODGE_CLASSES); + if (next.action === "dodge") { + button.classList.add(nextDodgeClass(dodges - 1)); + } + }); +} + +export function bindHorriblePage({ + document: rootDocument = globalThis.document, + stopButton, + cleanButton, + popupHost, + hitCounter, + guestbook, + onStop +} = {}) { + const root = rootDocument; + if (!root) return { dispose() {}, setEnabled() {}, clearPopups() {} }; + + const dodgeClasses = [...HORRIBLE_DODGE_CLASSES]; + let dodges = 0; + let tiredUntil = 0; + let lastTrail = 0; + let copyIndex = 0; + let closes = 0; + let cleanWindowUntil = 0; + let spawnTimer = 0; + let enabled = false; + + const isHorrible = () => root.documentElement.dataset.horrible === "on"; + const view = () => root.defaultView || globalThis; + const reduced = () => prefersReducedMotion(view()); + const cap = () => popupCap(reduced()); + const usedSlots = () => new Set([...popupHost?.querySelectorAll("[data-slot]") || []].map((node) => Number(node.dataset.slot))); + + const clearDodges = () => { + if (!cleanButton) return; + cleanButton.classList.remove(...dodgeClasses); + }; + + const onCleanEnter = () => { + if (!isHorrible() || reduced()) return; + const now = Date.now(); + const next = resolveCleanDodge(dodges, tiredUntil, now); + dodges = next.dodges; + tiredUntil = next.tiredUntil; + if (next.action === "stay") return; + clearDodges(); + if (next.action === "dodge") { + cleanButton.classList.add(nextDodgeClass(dodges - 1)); + } + }; + + const onPointerMove = (event) => { + if (!isHorrible() || reduced()) return; + const now = Date.now(); + if (now - lastTrail < 40) return; + lastTrail = now; + const dot = root.createElement("span"); + dot.className = "horrible-trail-dot"; + dot.setAttribute("aria-hidden", "true"); + dot.style.setProperty("--tx", `${event.clientX}px`); + dot.style.setProperty("--ty", `${event.clientY}px`); + root.body.append(dot); + view().setTimeout(() => dot.remove(), 700); + }; + + const openCount = () => popupHost?.querySelectorAll(".horrible-popup").length || 0; + + const spawnPopup = () => { + if (!enabled || !isHorrible() || !popupHost) return null; + if (openCount() >= cap()) return null; + if (Date.now() < cleanWindowUntil) return null; + + const copy = nextPopupCopy(copyIndex); + copyIndex += 1; + const slot = pickPopupSlot(usedSlots()); + const skin = (slot % 4) + 1; + const popup = root.createElement("aside"); + popup.className = `horrible-popup horrible-popup-slot-${slot} horrible-popup-skin-${skin}`; + popup.dataset.slot = String(slot); + popup.setAttribute("role", "dialog"); + popup.setAttribute("aria-label", "Joke popup"); + + const tag = root.createElement("p"); + tag.className = "horrible-joke-tag"; + tag.textContent = HORRIBLE_JOKE_TAG; + + const close = root.createElement("button"); + close.type = "button"; + close.className = "horrible-popup-x"; + close.setAttribute("aria-label", "Close joke popup"); + close.textContent = "X"; + + const title = root.createElement("h2"); + title.textContent = copy.title; + + const body = root.createElement("p"); + body.textContent = copy.body; + + const action = root.createElement("button"); + action.type = "button"; + action.className = "horrible-popup-action"; + action.textContent = copy.action; + + popup.append(tag, close, title, body, action); + popupHost.append(popup); + bindRunawayClose(close, root); + close.addEventListener("click", () => dismissPopup(popup)); + action.addEventListener("click", () => dismissPopup(popup)); + return popup; + }; + + const dismissPopup = (popup) => { + if (!popup?.isConnected) return; + const current = openCount(); + const inWindow = Date.now() < cleanWindowUntil; + const extras = popupsToSpawnOnClose(current, cap(), HORRIBLE_POPUP_MULTIPLY, inWindow); + popup.remove(); + closes += 1; + const nextWindow = nextCleanWindowUntil(closes, Date.now()); + if (nextWindow) cleanWindowUntil = nextWindow; + for (let index = 0; index < extras; index += 1) spawnPopup(); + }; + + const clearPopups = () => { + if (!popupHost) return; + popupHost.replaceChildren(); + }; + + const stopStorm = () => { + if (spawnTimer) view().clearInterval(spawnTimer); + spawnTimer = 0; + clearPopups(); + cleanWindowUntil = 0; + closes = 0; + }; + + const startStorm = () => { + stopStorm(); + enabled = true; + spawnPopup(); + if (!reduced()) spawnPopup(); + const interval = reduced() ? 5000 : 2800; + spawnTimer = view().setInterval(() => { + if (Date.now() >= cleanWindowUntil) spawnPopup(); + }, interval); + }; + + const setEnabled = (nextEnabled) => { + enabled = Boolean(nextEnabled); + if (enabled && isHorrible()) startStorm(); + else stopStorm(); + }; + + const stopEverything = () => { + enabled = false; + stopStorm(); + onStop?.(); + }; + + const onEscape = (event) => { + if (event.key !== "Escape") return; + if (!isHorrible() && !enabled) return; + event.preventDefault(); + stopEverything(); + }; + + if (cleanButton) { + cleanButton.addEventListener("mouseenter", onCleanEnter); + cleanButton.addEventListener("focus", clearDodges); + } + root.addEventListener("pointermove", onPointerMove, { passive: true }); + stopButton?.addEventListener("click", stopEverything); + view().addEventListener?.("keydown", onEscape); + guestbook?.addEventListener("click", () => { + guestbook.textContent = "THANKS FOR SIGNING MY GUESTBOOK!!!1"; + }); + + if (hitCounter) { + const storage = openHorribleStorage(view()); + let current = 1337; + try { + const stored = storage?.getItem(HORRIBLE_HITS_KEY); + if (stored) current = Number.parseInt(stored, 10) || 1337; + } catch { + current = 1337; + } + if (isHorrible()) { + current = bumpHitCounter(storage, current); + } + hitCounter.textContent = formatHitCounter(current); + } + + return { + dispose() { + stopStorm(); + cleanButton?.removeEventListener("mouseenter", onCleanEnter); + cleanButton?.removeEventListener("focus", clearDodges); + root.removeEventListener("pointermove", onPointerMove); + view().removeEventListener?.("keydown", onEscape); + }, + setEnabled, + clearPopups, + spawnPopup + }; +} diff --git a/icons.js b/icons.js index 6d1e00d..81fa496 100644 --- a/icons.js +++ b/icons.js @@ -58,6 +58,9 @@ const ICONS = { bookOpen: [ "M12 7v14", "M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z" + ], + flame: [ + "M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z" ] }; diff --git a/index.html b/index.html index 78ee206..86f1ead 100644 --- a/index.html +++ b/index.html @@ -16,9 +16,35 @@ + URL Cleaner + +
+ + +

UNDER CONSTRUCTION SINCE 1997

+ + + + + +
@@ -59,6 +85,7 @@

URL Cleaner

+

Aggressive cleaning also removes broader names such as ref and source, which some sites need. Leave duplicate cleanup off for signed links.

@@ -159,7 +186,21 @@

Batch results

Runs entirely in your browser. URLs are never uploaded or stored; only your settings are saved on this device.

+
+ diff --git a/storage.js b/storage.js index 6fd9597..123d7ba 100644 --- a/storage.js +++ b/storage.js @@ -4,7 +4,8 @@ export const STORAGE_KEYS = { totdCollapsed: "url-cleaner.totd-collapsed", aggressiveMode: "url-cleaner.aggressive-mode", removeDuplicates: "url-cleaner.remove-duplicates", - theme: "url-cleaner.theme" + theme: "url-cleaner.theme", + horrible: "url-cleaner.horrible" }; /** @param {Pick | null | undefined} storage */ diff --git a/styles.css b/styles.css index decd805..7f8d5b5 100644 --- a/styles.css +++ b/styles.css @@ -148,6 +148,10 @@ body { overflow-x: clip; } +.horrible-only { + display: none; +} + button, input, textarea { font: inherit; } .app-shell { @@ -1030,6 +1034,10 @@ html[data-theme="dark"] .setting input[type="checkbox"]:checked { grid-column: 1 / -1; margin-top: var(--space-2); } + + .horrible-setting { + grid-column: 1 / -1; + } } @media (max-width: 580px) { diff --git a/tests/horrible.test.js b/tests/horrible.test.js new file mode 100644 index 0000000..720e820 --- /dev/null +++ b/tests/horrible.test.js @@ -0,0 +1,138 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { STORAGE_KEYS } from "../storage.js"; +import { + HORRIBLE_DODGE_CLASSES, + HORRIBLE_DODGE_LIMIT, + HORRIBLE_JOKE_TAG, + HORRIBLE_POPUP_CAP, + HORRIBLE_POPUP_COPY, + HORRIBLE_STORAGE_KEY, + applyHorribleAttribute, + formatHitCounter, + nextCleanWindowUntil, + nextDodgeClass, + nextPopupCopy, + popupCap, + popupsToSpawnOnClose, + prefersReducedMotion, + readHorriblePreference, + resolveCleanDodge, + toggleHorribleMode, + writeHorriblePreference +} from "../horrible.js"; + +const root = join(dirname(fileURLToPath(import.meta.url)), ".."); + +class MemoryStorage { + #values = new Map(); + getItem(key) { + return this.#values.has(key) ? this.#values.get(key) : null; + } + setItem(key, value) { + this.#values.set(key, String(value)); + } +} + +test("horrible mode defaults off and persists through reload", () => { + const storage = new MemoryStorage(); + assert.equal(readHorriblePreference(storage), false); + + writeHorriblePreference(storage, true); + assert.equal(readHorriblePreference(storage), true); + assert.equal(storage.getItem(STORAGE_KEYS.horrible), "true"); + + const reloaded = readHorriblePreference(storage); + assert.equal(reloaded, true); + assert.equal(toggleHorribleMode(reloaded, storage), false); + assert.equal(readHorriblePreference(storage), false); +}); + +test("horrible storage key stays in the url-cleaner namespace", () => { + assert.equal(HORRIBLE_STORAGE_KEY, STORAGE_KEYS.horrible); + assert.equal(HORRIBLE_STORAGE_KEY, "url-cleaner.horrible"); +}); + +test("index wires a labeled toggle, stop button, and self-hosted stylesheet", () => { + const html = readFileSync(join(root, "index.html"), "utf8"); + assert.match(html, /id="horrible-mode"/); + assert.match(html, /Horrible mode/); + assert.match(html, /id="horrible-stop"/); + assert.match(html, />Make it stop]*src=)/); + assert.doesNotMatch(html, /horrible-nag|Question\.exe|Tahoma|Windows|Defender/); +}); + +test("theme-init applies stored horrible mode before paint", () => { + const init = readFileSync(join(root, "theme-init.js"), "utf8"); + assert.match(init, /url-cleaner\.horrible/); + assert.match(init, /dataset\.horrible/); +}); + +test("horrible.css keeps motion optional and blinks at or under 2Hz", () => { + const css = readFileSync(join(root, "horrible.css"), "utf8"); + assert.match(css, /html\[data-horrible="on"\]/); + assert.match(css, /prefers-reduced-motion:\s*no-preference/); + assert.match(css, /prefers-reduced-motion:\s*reduce/); + assert.match(css, /animation:\s*none\s*!important/); + assert.match(css, /horrible-blink 1s/); + assert.match(css, /horrible-twinkle 1\.2s/); + assert.match(css, /z-index:\s*2147483000/); + assert.doesNotMatch(css, /@import/); + assert.doesNotMatch(css, /https?:\/\//); + assert.doesNotMatch(css, /Tahoma|MS Sans Serif|navy|silver/); +}); + +test("app stops horrible mode from the panic button and Escape", () => { + const app = readFileSync(join(root, "app.js"), "utf8"); + const js = readFileSync(join(root, "horrible.js"), "utf8"); + assert.match(app, /onStop/); + assert.match(js, /Escape/); + assert.match(js, /stopEverything/); +}); + +test("dodge helpers cycle a few classes then give up", () => { + assert.equal(HORRIBLE_DODGE_LIMIT, 3); + assert.equal(nextDodgeClass(0), HORRIBLE_DODGE_CLASSES[0]); + assert.equal(nextDodgeClass(3), HORRIBLE_DODGE_CLASSES[0]); + assert.equal(formatHitCounter(1337), "00001337"); + assert.equal(resolveCleanDodge(3, 0, 1000, 4000).action, "rest"); + assert.equal(resolveCleanDodge(0, 5000, 1000).action, "stay"); + assert.equal(resolveCleanDodge(0, 0, 1000).action, "dodge"); +}); + +test("parody popups multiply until the cap, then leave a clean window", () => { + assert.equal(popupCap(false), HORRIBLE_POPUP_CAP); + assert.equal(popupCap(true), 2); + assert.equal(popupsToSpawnOnClose(3, 8, 2, false), 2); + assert.equal(popupsToSpawnOnClose(8, 8, 2, false), 1); + assert.equal(popupsToSpawnOnClose(8, 8, 2, true), 0); + assert.equal(popupsToSpawnOnClose(1, 2, 2, false), 2); + assert.equal(nextCleanWindowUntil(3, 1000), 7000); + assert.equal(nextCleanWindowUntil(2, 1000), 0); + assert.match(HORRIBLE_JOKE_TAG, /joke/); + assert.match(nextPopupCopy(0).title, /HOT TRACKERS/); + assert.ok(HORRIBLE_POPUP_COPY.every((copy) => copy.title && copy.body && copy.action)); +}); + +test("applyHorribleAttribute toggles data-horrible without touching theme", () => { + const element = { dataset: { theme: "light" } }; + applyHorribleAttribute(element, true); + assert.equal(element.dataset.horrible, "on"); + assert.equal(element.dataset.theme, "light"); + applyHorribleAttribute(element, false); + assert.equal(element.dataset.horrible, undefined); +}); + +test("prefersReducedMotion is false when matchMedia is missing", () => { + assert.equal(prefersReducedMotion({}), false); +}); diff --git a/theme-init.js b/theme-init.js index 82cf884..4520ae3 100644 --- a/theme-init.js +++ b/theme-init.js @@ -22,4 +22,16 @@ if (meta) { meta.setAttribute("content", theme === "dark" ? "#141414" : "#ffffff"); } + + var horrible = false; + try { + horrible = localStorage.getItem("url-cleaner.horrible") === "true"; + } catch { + horrible = false; + } + if (horrible) { + document.documentElement.dataset.horrible = "on"; + } else { + delete document.documentElement.dataset.horrible; + } })();