388 lines
12 KiB
HTML
388 lines
12 KiB
HTML
<!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;
|
|
margin: 0;
|
|
padding: 20px;
|
|
box-sizing: border-box;
|
|
min-height: 100lvh;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
/* Utility Classes */
|
|
.text-primary {
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
.text-muted {
|
|
color: #888;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
.mb-small {
|
|
margin: 0 0 5px 0;
|
|
}
|
|
|
|
.btn-full {
|
|
width: 100%;
|
|
padding: 8px;
|
|
}
|
|
|
|
.warning-box {
|
|
background: #252525;
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
margin-bottom: 20px;
|
|
text-align: left;
|
|
}
|
|
|
|
.destination-url {
|
|
color: white;
|
|
display: block;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
</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,
|
|
/* toSolidBytes */ (match, p1) =>
|
|
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(
|
|
(c) =>
|
|
`%${(
|
|
"00" + c.charCodeAt(0).toString(16)
|
|
).slice(-2)}`
|
|
)
|
|
.join("")
|
|
);
|
|
},
|
|
};
|
|
const html = (strings, ...values) =>
|
|
String.raw({ raw: strings }, ...values); // mdn
|
|
const app = document.getElementById("app");
|
|
const params = new URLSearchParams(location.search);
|
|
const redirectParam = params.get("redirect");
|
|
|
|
// --- Views ---
|
|
const renderCreator = () => {
|
|
app.innerHTML = html`
|
|
<h1 class="text-primary">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 class="text-muted mb-small">Your Shielded Link:</p>
|
|
<a
|
|
id="generatedLink"
|
|
href="#"
|
|
target="_blank"
|
|
class="link-display"
|
|
></a>
|
|
<button class="secondary btn-full" 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 class="warning-box">
|
|
<span class="text-muted">Destination:</span><br />
|
|
<strong class="destination-url" 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 = new URL(location);
|
|
shieldUrl.search = "";
|
|
shieldUrl.searchParams.append("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 = () => {
|
|
history.back();
|
|
if (history.length <= 1) window.close();
|
|
const newURL = new URL(window.location);
|
|
newURL.search = "";
|
|
window.location.replace(newURL);
|
|
};
|
|
|
|
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>
|