mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 10:39:57 +00:00
Always show "Cast..." menu item
This commit is contained in:
@@ -91,8 +91,8 @@ async function initMenus () {
|
|||||||
|
|
||||||
type MenuId = string | number;
|
type MenuId = string | number;
|
||||||
|
|
||||||
|
let menuIdCast: MenuId;
|
||||||
let menuIdMediaCast: MenuId;
|
let menuIdMediaCast: MenuId;
|
||||||
let menuIdMirroringCast: MenuId;
|
|
||||||
let menuIdWhitelist: MenuId;
|
let menuIdWhitelist: MenuId;
|
||||||
let menuIdWhitelistRecommended: MenuId;
|
let menuIdWhitelistRecommended: MenuId;
|
||||||
|
|
||||||
@@ -101,6 +101,12 @@ async function initMenus () {
|
|||||||
|
|
||||||
const opts = await options.getAll();
|
const opts = await options.getAll();
|
||||||
|
|
||||||
|
// Global "Cast..." menu item
|
||||||
|
menuIdCast = await browser.menus.create({
|
||||||
|
contexts: [ "browser_action", "page", "tools_menu" ]
|
||||||
|
, title: _("contextCast")
|
||||||
|
});
|
||||||
|
|
||||||
// <video>/<audio> "Cast..." context menu item
|
// <video>/<audio> "Cast..." context menu item
|
||||||
menuIdMediaCast = await browser.menus.create({
|
menuIdMediaCast = await browser.menus.create({
|
||||||
contexts: [ "audio", "video" ]
|
contexts: [ "audio", "video" ]
|
||||||
@@ -111,16 +117,6 @@ async function initMenus () {
|
|||||||
: URL_PATTERNS_REMOTE
|
: URL_PATTERNS_REMOTE
|
||||||
});
|
});
|
||||||
|
|
||||||
// Screen/Tab mirroring "Cast..." context menu item
|
|
||||||
menuIdMirroringCast = await browser.menus.create({
|
|
||||||
contexts: [ "browser_action", "page", "tools_menu" ]
|
|
||||||
, title: _("contextCast")
|
|
||||||
, visible: opts.mirroringEnabled
|
|
||||||
|
|
||||||
// Mirroring doesn't work from file:// urls
|
|
||||||
, documentUrlPatterns: URL_PATTERNS_REMOTE
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
menuIdWhitelist = await browser.menus.create({
|
menuIdWhitelist = await browser.menus.create({
|
||||||
contexts: [ "browser_action" ]
|
contexts: [ "browser_action" ]
|
||||||
@@ -195,7 +191,7 @@ async function initMenus () {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case menuIdMirroringCast: {
|
case menuIdCast: {
|
||||||
const selection = await ReceiverSelectorManager.getSelection(
|
const selection = await ReceiverSelectorManager.getSelection(
|
||||||
tab.id, info.frameId);
|
tab.id, info.frameId);
|
||||||
|
|
||||||
@@ -372,12 +368,6 @@ async function initMenus () {
|
|||||||
const alteredOpts = ev.detail;
|
const alteredOpts = ev.detail;
|
||||||
const newOpts = await options.getAll();
|
const newOpts = await options.getAll();
|
||||||
|
|
||||||
if (alteredOpts.includes("mirroringEnabled")) {
|
|
||||||
browser.menus.update(menuIdMirroringCast, {
|
|
||||||
visible: newOpts.mirroringEnabled
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alteredOpts.includes("mediaEnabled")) {
|
if (alteredOpts.includes("mediaEnabled")) {
|
||||||
browser.menus.update(menuIdMediaCast, {
|
browser.menus.update(menuIdMediaCast, {
|
||||||
visible: newOpts.mediaEnabled
|
visible: newOpts.mediaEnabled
|
||||||
|
|||||||
Reference in New Issue
Block a user