mirror of
https://github.com/EverythingPublic/firefox-ext-dl.git
synced 2026-01-13 16:18:04 +00:00
Update index.html
This commit is contained in:
129
index.html
Normal file
129
index.html
Normal file
@@ -0,0 +1,129 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Firefox Extension Downloader</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg-color: #121212;
|
||||
--surface-color: #1e1e1e;
|
||||
--primary-color: #00aaff;
|
||||
--primary-hover: #0088cc;
|
||||
--text-color: #e0e0e0;
|
||||
--border-color: #333;
|
||||
--error-color: #ff4d4d;
|
||||
--success-color: #4dff4d;
|
||||
}
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
html, body { height: 100%; }
|
||||
body {
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-color);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 1rem;
|
||||
}
|
||||
main {
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
background-color: var(--surface-color);
|
||||
padding: 2.5rem 2rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
||||
text-align: center;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
p {
|
||||
margin-bottom: 1.5rem;
|
||||
color: #aaa;
|
||||
}
|
||||
#dl-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
#addon-url {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
background-color: var(--bg-color);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
color: var(--text-color);
|
||||
font-size: 1rem;
|
||||
outline: none;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
#addon-url:focus {
|
||||
border-color: var(--primary-color);
|
||||
box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.2);
|
||||
}
|
||||
button {
|
||||
padding: 0.75rem 1rem;
|
||||
background-color: var(--primary-color);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
button:hover, button:focus {
|
||||
background-color: var(--primary-hover);
|
||||
outline: none;
|
||||
}
|
||||
#status {
|
||||
margin-top: 1.5rem;
|
||||
margin-bottom: -1rem; /* prevent layout shift */
|
||||
min-height: 1.2em;
|
||||
font-weight: 600;
|
||||
}
|
||||
#status.error { color: var(--error-color); }
|
||||
#status.success { color: var(--success-color); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Extension Downloader</h1>
|
||||
<p>Master, provide a Firefox Add-on Store URL to download its <code>.xpi</code> source file.</p>
|
||||
<form id="dl-form">
|
||||
<input type="url" id="addon-url" placeholder="https://addons.mozilla.org/..." required autocomplete="off">
|
||||
<button type="submit">Download Source</button>
|
||||
</form>
|
||||
<p id="status"></p>
|
||||
</main>
|
||||
<script>
|
||||
document.getElementById('dl-form').addEventListener('submit', e => {
|
||||
e.preventDefault();
|
||||
const status = document.getElementById('status');
|
||||
status.className = ''; status.textContent = 'Acquiring target...';
|
||||
try {
|
||||
fetch(`https://addons.mozilla.org/api/v5/addons/addon/${document.getElementById('addon-url').value.match(/\/addon\/([^/]+)/)[1]}/`)
|
||||
.then(res => res.ok ? res.json() : Promise.reject(new Error(`Server responded ${res.status}`)))
|
||||
.then(data => {
|
||||
const a = document.createElement('a');
|
||||
a.href = data.current_version.file.url;
|
||||
a.download = a.href.split('/').pop();
|
||||
document.body.appendChild(a).click();
|
||||
document.body.removeChild(a);
|
||||
status.className = 'success';
|
||||
status.textContent = `Download initiated for ${a.download}.`;
|
||||
})
|
||||
.catch(err => { status.className = 'error'; status.textContent = `Error: ${err.message}.`; })
|
||||
.finally(() => setTimeout(() => { status.textContent = ''; status.className = ''; }, 5000));
|
||||
} catch (err) {
|
||||
status.className = 'error'; status.textContent = 'Error: Invalid URL format.';
|
||||
setTimeout(() => { status.textContent = ''; status.className = ''; }, 5000);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user