function updateMenuItem(linkHostname) {
browser.menus.update(openLabeledId, {
title: `Open (${linkHostname})`,
});
browser.menus.refresh();
}
browser.menus.onShown.addListener((info) => {
if (!info.linkUrl) {
return;
}
let linkElement = document.createElement("a");
linkElement.href = info.linkUrl;
updateMenuItem(linkElement.hostname);
});menus.refresh() / notebook
menus.refresh()
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.