mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 09:39:58 +00:00
Better media element detection
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user