Convert mediaCast sender to typescript

This commit is contained in:
hensm
2019-06-14 12:49:10 +01:00
parent 2996e50f5e
commit 0427e08b6a
5 changed files with 127 additions and 90 deletions

View File

@@ -429,17 +429,17 @@ browser.menus.onClicked.addListener(async (info, tab) => {
const { frameId } = info;
const mirroringAppId = await options.get("mirroringAppId");
// Load cast setup script
await browser.tabs.executeScript(tab.id, {
file: "shim/content.js"
, frameId
});
switch (info.menuItemId) {
case mirrorCastMenuId: {
mirrorCastTabId = tab.id;
mirrorCastFrameId = frameId;
// Load cast setup script
await browser.tabs.executeScript(tab.id, {
file: "shim/content.js"
, frameId
});
await browser.tabs.executeScript(tab.id, {
code: `
var selectedMedia = ${info.pageUrl
@@ -456,6 +456,12 @@ browser.menus.onClicked.addListener(async (info, tab) => {
, frameId
});
// Load cast API
await browser.tabs.executeScript(tab.id, {
file: "shim/bundle.js"
, frameId
});
break;
}
@@ -465,8 +471,10 @@ browser.menus.onClicked.addListener(async (info, tab) => {
// Pass media URL to media sender app
await browser.tabs.executeScript(tab.id, {
code: `var srcUrl = "${info.srcUrl}";
var targetElementId = ${info.targetElementId};`
code: `
window.srcUrl = "${info.srcUrl}";
window.targetElementId = ${info.targetElementId};
`
, frameId
});
@@ -480,12 +488,6 @@ browser.menus.onClicked.addListener(async (info, tab) => {
}
}
// Load cast API
await browser.tabs.executeScript(tab.id, {
file: "shim/bundle.js"
, frameId
});
return;
}