-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathembeddr.html
More file actions
143 lines (134 loc) · 7.01 KB
/
embeddr.html
File metadata and controls
143 lines (134 loc) · 7.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Embed Link Generator</title>
<style>
:root {
--bg: #121212; --surface: #1e1e1e; --primary: #bb86fc;
--text-main: #e0e0e0; --text-secondary: #a0a0a0; --border-color: #333;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--bg); color: var(--text-main); display: flex;
align-items: center; justify-content: center; min-height: 100vh; padding: 1rem;
}
.container {
width: 100%; max-width: 600px; background: var(--surface); border-radius: 12px;
padding: 2rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); border: 1px solid var(--border-color);
}
.header { text-align: center; margin-bottom: 2rem; }
.header h1 { font-size: 2.5rem; font-weight: 700; color: var(--primary); letter-spacing: -1px; }
.header p { color: var(--text-secondary); margin-top: 0.5rem; }
.form-label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
.url-input {
width: 100%; padding: 0.8rem 1rem; border-radius: 6px; border: 1px solid var(--border-color);
background: var(--bg); color: var(--text-main); font-size: 1rem; margin-bottom: 1rem; transition: border-color 0.2s;
}
.url-input:focus { outline: none; border-color: var(--primary); }
.options-section { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; color: var(--text-secondary); font-size: 0.9rem; }
#skip-checkbox { accent-color: var(--primary); }
.generate-btn {
width: 100%; padding: 0.8rem 1rem; border: none; border-radius: 6px; background: var(--primary);
color: var(--bg); font-size: 1rem; font-weight: 700; cursor: pointer; transition: background-color 0.2s;
}
.generate-btn:hover { background-color: #a966fa; }
.result-section { display: none; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); }
.result-section.show { display: block; }
.result-group { position: relative; }
.result-input {
width: 100%; padding: 0.8rem 1rem; border: 1px solid var(--border-color); border-radius: 6px;
font-family: monospace; font-size: 0.9rem; background: var(--bg); color: var(--text-main); padding-right: 80px;
}
.copy-btn {
position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 0.5rem 0.8rem;
background: #333; color: var(--text-main); border: 1px solid var(--border-color); border-radius: 4px; cursor: pointer;
}
.copy-btn.copied { background: #5a5a5a; color: var(--primary); }
.notification {
position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); padding: 0.75rem 1.5rem;
background: var(--surface); color: var(--primary); border: 1px solid var(--primary); border-radius: 6px;
opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
.notification.show { opacity: 1; transform: translateX(-50%) translateY(-10px); }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Embed Link Generator</h1>
<p>Create a proxy link to embed any website.</p>
</div>
<div class="form-section">
<label for="url-input" class="form-label">Website URL</label>
<input type="text" id="url-input" class="url-input" placeholder="example.com">
<div class="options-section">
<input type="checkbox" id="skip-checkbox">
<label for="skip-checkbox">Skip loading screen</label>
</div>
<button id="generate-btn" class="generate-btn">Generate</button>
</div>
<div id="result-section" class="result-section">
<label class="form-label">Your Embed Link</label>
<div class="result-group">
<input type="text" id="embed-url" class="result-input" readonly>
<button id="copy-btn" class="copy-btn">Copy</button>
</div>
</div>
</div>
<div id="notification" class="notification">Copied!</div>
<script>
const urlInput = document.getElementById('url-input');
const generateBtn = document.getElementById('generate-btn');
const resultSection = document.getElementById('result-section');
const embedUrlInput = document.getElementById('embed-url');
const copyBtn = document.getElementById('copy-btn');
const notification = document.getElementById('notification');
const skipCheckbox = document.getElementById('skip-checkbox');
function generateLink() {
let targetUrl = urlInput.value.trim();
if (!targetUrl) return;
if (!/^https?:\/\//.test(targetUrl)) {
targetUrl = 'https://' + targetUrl;
}
// *** FIX: Changed the URL generation logic. ***
// This now correctly assumes index.html and embed.html are in the same directory.
// It will resolve to '.../embed/embed.html' instead of '.../embed/embed/embed.html'.
let embedPageUrl = new URL('embed.html', window.location.href).href;
if (skipCheckbox.checked) {
embedPageUrl += '?skip';
}
const finalUrl = `${embedPageUrl}#${encodeURIComponent(targetUrl)}`;
embedUrlInput.value = finalUrl;
resultSection.classList.add('show');
}
generateBtn.addEventListener('click', generateLink);
urlInput.addEventListener('keypress', (e) => e.key === 'Enter' && generateLink());
copyBtn.addEventListener('click', () => {
const urlToCopy = embedUrlInput.value;
// Use the modern, secure Clipboard API with a fallback.
navigator.clipboard.writeText(urlToCopy).then(() => {
copyBtn.textContent = 'Copied!';
copyBtn.classList.add('copied');
notification.classList.add('show');
setTimeout(() => {
copyBtn.textContent = 'Copy';
copyBtn.classList.remove('copied');
notification.classList.remove('show');
}, 2000);
}).catch(err => {
console.error('Failed to copy text: ', err);
// Fallback for older browsers.
try {
embedUrlInput.select();
document.execCommand('copy');
} catch (e) {
console.error('Fallback copy failed: ', e);
}
});
});
</script>
</body>
</html>