Better media element detection

This commit is contained in:
hensm
2018-09-26 21:33:12 +01:00
parent b43f6e4579
commit b347a75157
3 changed files with 24 additions and 11 deletions

View File

@@ -165,7 +165,8 @@ browser.menus.onClicked.addListener(async (info, tab) => {
// Pass media URL to media sender app
await browser.tabs.executeScript(tab.id, {
code: `const srcUrl = "${info.srcUrl}";`
code: `const srcUrl = "${info.srcUrl}";
const targetElementId = ${info.targetElementId};`
, frameId
});

View File

@@ -12,9 +12,7 @@ let currentMedia;
const isLocalFile = srcUrl.startsWith("file:");
const mediaElement = isLocalFile
? document.querySelector("video, audio")
: document.querySelector(`[src="${srcUrl}"]`);
const mediaElement = browser.menus.getTargetElement(targetElementId);
window.addEventListener("beforeunload", () => {
browser.runtime.sendMessage({