{
let submit = 0;
const screenshotContainer = htl.html`<div><p>Waiting for a new URL...</p></div>`;
yield screenshotContainer;
for await (let info of Generators.input(viewof urlSubmitForm)) {
if (submit === info.submit) continue;
submit = info.submit;
const url = info.url;
if (!url) {
screenshotContainer.innerHTML = "";
screenshotContainer.append(
htl.html`<p>URL is empty. Waiting for a new one...</p>`
);
continue;
}
const win = await api.windows.create({
url,
focused: true,
type: "popup",
width: 800,
height: 600
});
try {
await Promises.delay(info.timeout);
const imgUrl = await api.tabs.captureVisibleTab(win.id, {
format: "png"
});
const img = htl.html`<img src="${imgUrl}" />`;
screenshotContainer.innerText = "";
screenshotContainer.appendChild(img);
} finally {
await api.windows.remove(win.id);
}
}
}