Skip to content
Open
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
50 changes: 49 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,62 @@ function showResult(type, title, desc, url, threats) {
<div class="result-body">
<div class="result-title">${title}</div>
<div class="result-desc">${desc}</div>
${url ? `<div class="result-url">${url}</div>` : ''}
${url ? `<div class="result-url">
<span class="result-url-text">${url}</span>
<button class="copy-url-btn" type="button" aria-label="Copy URL" onclick="copyResultUrl(this)">
<svg class="copy-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="9" y="9" width="13" height="13" rx="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
<svg class="check-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="copy-url-label">Copy</span>
</button>
</div>` : ''}
${threats && threats.length
? `<div class="threat-tags">${threats.map(t => `<span class="threat-tag">${t}</span>`).join('')}</div>`
: ''}
</div>
</div>`;
}
function copyResultUrl(btn) {
const textEl = btn.previousElementSibling;
const text = textEl ? textEl.textContent : '';
if (!text) return;

const label = btn.querySelector('.copy-url-label');
const markCopied = () => {
btn.classList.add('copied');
if (label) label.textContent = 'Copied';
clearTimeout(btn._copyResetTimer);
btn._copyResetTimer = setTimeout(() => {
btn.classList.remove('copied');
if (label) label.textContent = 'Copy';
}, 2000);
};

if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(markCopied).catch(() => {
fallbackCopy(text);
markCopied();
});
} else {
fallbackCopy(text);
markCopied();
}
}

function fallbackCopy(text) {
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.style.position = 'fixed';
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.select();
try { document.execCommand('copy'); } catch (e) { /* no-op */ }
document.body.removeChild(textarea);
}
async function checkSecurity() {
const input = document.getElementById('urlInput');
const btn = document.getElementById('scanBtn');
Expand Down
42 changes: 41 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -560,20 +560,60 @@ html.light-mode input[type="text"]:focus {
color: var(--text-sub);
line-height: 1.6;
}

.result-url {
margin-top: 10px;
display: flex;
align-items: center;
gap: 10px;
font-family: 'Courier New', monospace;
font-size: 11px;
color: var(--text-muted);
background: rgba(0,0,0,0.2);
border-radius: 8px;
padding: 8px 12px;
}

.result-url-text {
flex: 1;
word-break: break-all;
}

html.light-mode .result-url { background: rgba(0,0,0,0.06); }

.copy-url-btn {
flex-shrink: 0;
display: flex;
align-items: center;
gap: 5px;
background: rgba(0,245,255,0.1);
border: 1px solid rgba(0,245,255,0.25);
border-radius: 6px;
padding: 4px 9px;
color: var(--accent-cyan);
font-family: inherit;
font-size: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.04em;
cursor: pointer;
transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.copy-url-btn:hover {
background: rgba(0,245,255,0.18);
border-color: var(--accent-cyan);
}

.copy-url-btn .check-icon { display: none; }

.copy-url-btn.copied {
background: rgba(0,255,136,0.14);
border-color: rgba(0,255,136,0.4);
color: var(--accent-green);
}

.copy-url-btn.copied .copy-icon { display: none; }
.copy-url-btn.copied .check-icon { display: block; }
.threat-tags {
display: flex;
flex-wrap: wrap;
Expand Down