Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ function showCleanResult(result, { allowAutoCopy = true, originalValue = "", rev

showMessage(baseMessage, result.unwrapLimitReached ? "info" : "success");
celebrateHorribleClean();
horribleEffects.afterClean?.({ url: result.url, source: "single" });

if (allowAutoCopy && autoCopy.checked) {
copyText(cleanedValue).then((copied) => {
Expand Down Expand Up @@ -520,6 +521,7 @@ function showBatchResults(entries, { allowAutoCopy = true } = {}) {
: `${cleaned.length} cleaned, ${failed} failed.`;
showMessage(baseMessage, cleaned.length > 0 ? "success" : "error");
if (cleaned.length > 0) celebrateHorribleClean();
if (cleaned.length > 0) horribleEffects.afterClean?.({ url: batchCopyValue, source: "batch" });

if (allowAutoCopy && autoCopy.checked && batchCopyValue) {
copyText(batchCopyValue).then((copied) => {
Expand All @@ -531,6 +533,17 @@ function showBatchResults(entries, { allowAutoCopy = true } = {}) {
}
}

function requestClean(options = {}) {
if (!input.value.trim()) {
showMessage("Paste or type a URL to clean.", "error");
return;
}
if (horribleEffects.beforeClean?.({ source: options.source || "form", proceed: () => runClean(options) })) {
return;
}
runClean(options);
}

function runClean(options = {}) {
hideResults();

Expand Down Expand Up @@ -742,11 +755,22 @@ renderTrackerOfTheDay();

form.addEventListener("submit", (event) => {
event.preventDefault();
if (!input.value.trim()) {
showMessage("Paste or type a URL to clean.", "error");
requestClean({ source: "form" });
});

input.addEventListener("keydown", (event) => {
if (event.key !== "Enter") return;
const chord = event.ctrlKey || event.metaKey;
const horribleOn = document.documentElement.dataset.horrible === "on";
if (chord) {
event.preventDefault();
requestClean({ source: "keyboard" });
return;
}
runClean();
if (horribleOn && !event.shiftKey) {
event.preventDefault();
requestClean({ source: "keyboard" });
}
});

input.addEventListener("input", () => {
Expand Down Expand Up @@ -838,6 +862,7 @@ horribleEffects = bindHorriblePage({
popupHost: document.querySelector("#horrible-popups"),
hitCounter: document.querySelector(".horrible-hit-counter"),
guestbook: document.querySelector("#horrible-guestbook"),
onClean: () => runClean(),
onStop: () => {
saveSetting(STORAGE_KEYS.horrible, false);
applyHorribleMode(false);
Expand All @@ -862,6 +887,14 @@ clipboardOfferDismiss.addEventListener("click", () => {
clipboardOfferValue = "";
});

window.__urlCleaner = {
cleanCurrentInput: () => requestClean({ source: "keyboard" }),
setHorribleMode: (enabled) => {
saveSetting(STORAGE_KEYS.horrible, Boolean(enabled));
applyHorribleMode(Boolean(enabled));
}
};

if (!loadHandoff()) {
offerClipboardIfPermitted();
}
Expand Down
38 changes: 21 additions & 17 deletions horrible.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ html[data-horrible="on"] .construction-banner {
margin: 0;
padding: 0.45rem 0.75rem;
border-bottom: 3px solid #111;
/* Static hazard stripes. They do not scroll or flash; wobble is 2.4s pose-only. */
background: repeating-linear-gradient(
-45deg,
#111 0 14px,
Expand Down Expand Up @@ -522,6 +523,10 @@ html[data-horrible="on"] .horrible-toasters span:nth-child(3) { top: 78%; left:

html[data-horrible="on"] .horrible-popups {
display: block;
position: fixed;
inset: 0;
z-index: 2147482998;
pointer-events: none;
}

html[data-horrible="on"] .horrible-joke-tag {
Expand All @@ -538,13 +543,14 @@ html[data-horrible="on"] .horrible-joke-tag {

html[data-horrible="on"] .horrible-popup {
position: fixed;
z-index: 60;
z-index: 2147482998;
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;
pointer-events: none;
}

html[data-horrible="on"] .horrible-popup h2 {
Expand Down Expand Up @@ -576,6 +582,7 @@ html[data-horrible="on"] .horrible-popup-x {
position: absolute;
top: 0.4rem;
right: 0.45rem;
z-index: 2147482999;
width: 2rem;
height: 2rem;
padding: 0;
Expand All @@ -585,18 +592,24 @@ html[data-horrible="on"] .horrible-popup-x {
color: #c00;
font-size: 1rem;
line-height: 1;
transform: none !important;
animation: none !important;
pointer-events: auto;
}

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:hover,
html[data-horrible="on"] .horrible-popup:focus-within {
animation: none !important;
transform: none;
}

html[data-horrible="on"] .horrible-popup-action {
border: 3px solid #111;
border-radius: 999px;
background: #fff;
color: #1a0033;
padding: 0.35rem 0.7rem;
pointer-events: auto;
}

html[data-horrible="on"] .horrible-loading {
Expand Down Expand Up @@ -725,6 +738,7 @@ html[data-horrible="on"] .theme-toggle {

@media (prefers-reduced-motion: no-preference) {
html[data-horrible="on"]::before {
/* Luminance cycle ~0.04 Hz (28s). Stay well under the 2 Hz cap. */
animation: horrible-bg-shift 28s linear infinite, horrible-hue 40s linear infinite;
}

Expand Down Expand Up @@ -760,26 +774,16 @@ html[data-horrible="on"] .theme-toggle {
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;
animation: horrible-loading-shimmer 2.4s 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;
animation: horrible-blink 1.6s step-end infinite;
transition: transform 0.22s ease;
}

Expand Down Expand Up @@ -818,7 +822,7 @@ html[data-horrible="on"] .theme-toggle {
}

html[data-horrible="on"] .horrible-stars span {
animation: horrible-twinkle 1.2s step-end infinite;
animation: horrible-twinkle 2s step-end infinite;
}

html[data-horrible="on"] .horrible-stars span:nth-child(odd) {
Expand Down
Loading
Loading