side-tracked

https://ldlda.com/nsfw-shield/
This commit is contained in:
lda committed 2025-12-23 16:30:11 +07:00
1 parent ff7e9d2a07
commit 064236bff6
1 file changed
+303
+303
View File
@@ -0,0 +1,303 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NSFW Shield</title>
<style>
:root {
--bg-color: #121212;
--surface-color: #1e1e1e;
--primary-color: #bb86fc;
--text-color: #e0e0e0;
--error-color: #cf6679;
--success-color: #03dac6;
}
body {
background-color: var(--bg-color);
color: var(--text-color);
font-family: system-ui, -apple-system, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
box-sizing: border-box;
}
.card {
background-color: var(--surface-color);
padding: 2rem;
border-radius: 12px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
max-width: 400px;
width: 100%;
text-align: center;
border: 1px solid #333;
}
h1 {
margin-top: 0;
color: var(--error-color);
font-size: 1.8rem;
}
p {
line-height: 1.5;
margin-bottom: 1.5rem;
}
input {
width: 100%;
padding: 12px;
margin: 10px 0;
background: #2d2d2d;
border: 1px solid #444;
color: white;
border-radius: 6px;
box-sizing: border-box;
font-size: 1rem;
}
input:focus {
outline: 2px solid var(--primary-color);
border-color: transparent;
}
.buttons {
display: flex;
gap: 10px;
justify-content: center;
margin-top: 20px;
}
button {
padding: 12px 24px;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
font-size: 1rem;
transition: transform 0.1s, opacity 0.2s;
}
button:active {
transform: scale(0.98);
}
button.primary {
background-color: var(--error-color);
color: #000;
}
button.create-btn {
background-color: var(--primary-color);
color: #000;
}
button.secondary {
background-color: #333;
color: #fff;
border: 1px solid #444;
}
button:hover {
opacity: 0.9;
}
.hidden {
display: none;
}
#result-area {
margin-top: 20px;
padding: 15px;
background: #252525;
border-radius: 6px;
border: 1px solid #333;
text-align: left;
}
.link-display {
word-break: break-all;
color: var(--primary-color);
margin-bottom: 10px;
display: block;
font-family: monospace;
}
.copy-feedback {
display: none;
color: var(--success-color);
font-size: 0.8rem;
margin-left: 10px;
opacity: 0;
transition: opacity 0.3s;
}
.copy-feedback.show {
opacity: 1;
display: unset;
}
footer {
margin-top: 30px;
font-size: 0.8rem;
color: #666;
}
footer a {
color: #888;
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="card" id="app">
<!-- Content injected by JS -->
</div>
<script>
// --- Utilities ---
const Base64 = {
encode: (str) => {
return btoa(
encodeURIComponent(str).replace(
/%([0-9A-F]{2})/g,
function toSolidBytes(match, p1) {
return String.fromCharCode("0x" + p1);
}
)
)
.replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");
},
decode: (str) => {
str = str.replace(/-/g, "+").replace(/_/g, "/");
while (str.length % 4) str += "=";
return decodeURIComponent(
atob(str)
.split("")
.map(function (c) {
return (
"%" +
("00" + c.charCodeAt(0).toString(16)).slice(
-2
)
);
})
.join("")
);
},
};
const app = document.getElementById("app");
const params = new URLSearchParams(location.search);
const redirectParam = params.get("redirect");
// --- Views ---
const renderCreator = () => {
app.innerHTML = /* html */ `
<h1 style="color: var(--primary-color)">Shield Generator</h1>
<p>Create a warning wrapper for NSFW or sensitive links.</p>
<input type="url" id="urlInput" placeholder="https://example.com/sensitive-content" autocomplete="off" />
<div class="buttons">
<button class="create-btn" onclick="generateLink()">Generate Shield</button>
</div>
<div id="result-area" class="hidden">
<p style="margin:0 0 5px 0; font-size:0.8em; color:#888;">Your Shielded Link:</p>
<a id="generatedLink" href="#" target="_blank" class="link-display"></a>
<button class="secondary" style="width:100%; padding: 8px;" onclick="copyLink()">
Copy to Clipboard <span id="copyMsg" class="copy-feedback">Copied!</span>
</button>
</div>
`;
setTimeout(
() => document.getElementById("urlInput").focus(),
100
);
document
.getElementById("urlInput")
.addEventListener("keypress", (e) => {
if (e.key === "Enter") generateLink();
});
};
const renderWarning = (targetUrl) => {
let domain = "Unknown Domain";
try {
domain = new URL(targetUrl).href;
} catch (e) {}
app.innerHTML = /* html */ `
<h1>NSFW Warning</h1>
<p>The link you are about to visit contains content marked as <strong>Not Safe For Work</strong>.</p>
<div style="background: #252525; padding: 10px; border-radius: 4px; margin-bottom: 20px; text-align: left;">
<span style="color: #888; font-size: 0.9em;">Destination:</span><br>
<strong style="color: white; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;" title="${domain}">${domain}</strong>
</div>
<div class="buttons">
<button class="secondary" onclick="goBack()">I'm out</button>
<button class="primary" onclick="proceed('${targetUrl}')">Proceed</button>
</div>
<footer>
<a href="${location.pathname}">Create your own shield</a>
</footer>
`;
};
// --- Actions ---
window.generateLink = () => {
const input = document.getElementById("urlInput");
const resultArea = document.getElementById("result-area");
const link = document.getElementById("generatedLink");
if (!input.value.trim()) return;
try {
let rawUrl = input.value.trim();
if (!/^https?:\/\//i.test(rawUrl)) {
rawUrl = "https://" + rawUrl;
}
new URL(rawUrl);
const encoded = Base64.encode(rawUrl);
const shieldUrl = `${location.origin}${location.pathname}?redirect=${encoded}`;
link.href = shieldUrl;
link.textContent = shieldUrl;
resultArea.classList.remove("hidden");
} catch (e) {
alert("Please enter a valid URL.");
}
};
window.copyLink = () => {
const linkText =
document.getElementById("generatedLink").textContent;
navigator.clipboard.writeText(linkText).then(() => {
const msg = document.getElementById("copyMsg");
msg.classList.add("show");
setTimeout(() => msg.classList.remove("show"), 2000);
});
};
window.goBack = () => {
if (history.length > 1) history.back();
else window.close();
/* window.location.href = "https://google.com"; */
};
window.proceed = (url) => {
window.location.replace(url);
};
// --- Router ---
if (redirectParam) {
try {
const targetUrl = Base64.decode(redirectParam);
renderWarning(targetUrl);
} catch (e) {
console.error("Failed to decode redirect param", e);
renderCreator(); // Fallback if decode fails
}
} else {
renderCreator();
}
</script>
</body>
</html>