function onShowing(success) {
console.log(`Showing download item: ${success}`);
}
function onError(error) {
console.log(`Error opening item: ${error}`);
}
function openDownload(downloadItems) {
if (downloadItems.length > 0) {
latestDownloadId = downloadItems[0].id;
let showing = browser.downloads.show(latestDownloadId);
showing.then(onShowing, onError);
}
}
let searching = browser.downloads.search({
limit: 1,
orderBy: ["-startTime"],
});
searching.then(openDownload, onError);downloads.show() / notebook
downloads.show()
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.