feat: update index.html

This commit is contained in:
2025-09-12 10:39:12 -07:00
parent c1a36aae08
commit ee905ee7e7

View File

@@ -108,14 +108,15 @@
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().replace(/\.xpi$/, '.zip');
.then(data => (status.textContent = 'Downloading file...', fetch(data.current_version.file.url).then(res => res.ok ? res.blob() : Promise.reject(new Error(`File download failed: ${res.status}`))).then(blob => ({blob, url: data.current_version.file.url}))))
.then(({blob, url}) => {
const a = document.createElement('a'), fileName = url.split('/').pop().replace(/\.xpi$/, '.zip');
a.href = URL.createObjectURL(blob);
a.download = fileName;
document.body.appendChild(a).click();
URL.revokeObjectURL(a.href);
document.body.removeChild(a);
status.className = 'success';
status.textContent = `Download initiated for ${a.download}.`;
status.className = 'success'; status.textContent = `Download initiated for ${fileName}.`;
})
.catch(err => { status.className = 'error'; status.textContent = `Error: ${err.message}.`; })
.finally(() => setTimeout(() => status.textContent = status.className = '', 5000));