Add popup options link, results preview, and context menu for archive.org download pages
This commit is contained in:
parent
a7966ebebe
commit
3fdd76d631
5 changed files with 62 additions and 3 deletions
|
|
@ -17,6 +17,8 @@ const els = {
|
|||
rpcSecret: document.getElementById('rpc-secret'),
|
||||
count: document.getElementById('count'),
|
||||
status: document.getElementById('status'),
|
||||
openOptions: document.getElementById('open-options'),
|
||||
preview: document.getElementById('preview'),
|
||||
};
|
||||
|
||||
let allItems = [];
|
||||
|
|
@ -59,6 +61,7 @@ function filtered() {
|
|||
|
||||
function updateCount() {
|
||||
els.count.textContent = String(filtered().length);
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
async function copyLinks() {
|
||||
|
|
@ -103,6 +106,7 @@ function wire() {
|
|||
els.btnRefresh.addEventListener('click', refresh);
|
||||
els.btnCopy.addEventListener('click', copyLinks);
|
||||
els.btnSend.addEventListener('click', sendToAria2);
|
||||
els.openOptions.addEventListener('click', (e) => { e.preventDefault(); browser.runtime.openOptionsPage(); });
|
||||
[
|
||||
els.fType, els.fTypeRe, els.fName, els.fNameRe, els.fSizeMin, els.fSizeMax,
|
||||
els.fDateFrom, els.fDateTo, els.fCase
|
||||
|
|
@ -115,3 +119,19 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
await refresh();
|
||||
});
|
||||
|
||||
function renderPreview() {
|
||||
if (!els.preview) return;
|
||||
const items = filtered();
|
||||
const max = 50;
|
||||
els.preview.innerHTML = '';
|
||||
for (const it of items.slice(0, max)) {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = it.name || it.url;
|
||||
els.preview.appendChild(li);
|
||||
}
|
||||
if (items.length > max) {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = `…and ${items.length - max} more`;
|
||||
els.preview.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue