Hide cast and browser default menu items in extension pages

This commit is contained in:
hensm
2020-02-15 08:19:41 +00:00
parent 705a676fe3
commit ae82679a8f
3 changed files with 23 additions and 0 deletions

View File

@@ -226,6 +226,22 @@ async function initMenus () {
}
});
// Hide cast item on extension pages
browser.menus.onShown.addListener(info => {
if (info.pageUrl?.startsWith(browser.runtime.getURL(""))) {
browser.menus.update(menuIdCast, {
visible: false
});
browser.menus.refresh();
}
});
browser.menus.onHidden.addListener(() => {
browser.menus.update(menuIdCast, {
visible: true
});
});
browser.menus.onShown.addListener(async info => {
// Only rebuild menus if whitelist menu present
// WebExt typings are broken again here, so ugly casting

View File

@@ -49,6 +49,7 @@
, "permissions": [
"history"
, "menus"
, "menus.overrideContext"
, "nativeMessaging"
, "storage"
, "tabs"

View File

@@ -361,3 +361,9 @@ window.addEventListener("load", () => {
<PopupApp />
, document.querySelector("#root"));
});
window.addEventListener("contextmenu", () => {
browser.menus.overrideContext({
showDefaults: false
});
});