mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 18:39:58 +00:00
Fix webcomponents polyfill loading
This commit is contained in:
@@ -257,6 +257,15 @@ browser.menus.onShown.addListener(info => {
|
|||||||
*/
|
*/
|
||||||
browser.webRequest.onBeforeRequest.addListener(
|
browser.webRequest.onBeforeRequest.addListener(
|
||||||
async details => {
|
async details => {
|
||||||
|
await browser.tabs.executeScript(details.tabId, {
|
||||||
|
code: `
|
||||||
|
window.isFramework = ${
|
||||||
|
details.url === CAST_FRAMEWORK_LOADER_SCRIPT_URL};
|
||||||
|
`
|
||||||
|
, frameId: details.frameId
|
||||||
|
, runAt: "document_start"
|
||||||
|
});
|
||||||
|
|
||||||
await browser.tabs.executeScript(details.tabId, {
|
await browser.tabs.executeScript(details.tabId, {
|
||||||
file: "shim/contentBridge.js"
|
file: "shim/contentBridge.js"
|
||||||
, frameId: details.frameId
|
, frameId: details.frameId
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ import { CAST_LOADER_SCRIPT_URL
|
|||||||
, CAST_SCRIPT_URLS } from "../endpoints";
|
, CAST_SCRIPT_URLS } from "../endpoints";
|
||||||
|
|
||||||
|
|
||||||
const _window = (window.wrappedJSObject as any);
|
(window.wrappedJSObject as any).chrome = cloneInto({}, window);
|
||||||
|
|
||||||
_window.chrome = cloneInto({}, window);
|
|
||||||
_window.navigator.presentation = cloneInto({}, window);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import { onMessageResponse, sendMessage } from "./eventMessageChannel";
|
import { onMessageResponse, sendMessage } from "./eventMessageChannel";
|
||||||
|
import { loadScript } from "../lib/utils";
|
||||||
|
|
||||||
|
|
||||||
|
const { isFramework }
|
||||||
|
: { isFramework: boolean } = (window as any);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Framework API library requires webcomponents for the cast
|
||||||
|
* button custom element (<google-cast-launcher>).
|
||||||
|
*/
|
||||||
|
if (isFramework) {
|
||||||
|
loadScript(browser.runtime.getURL("vendor/webcomponents-lite.js"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Message port to background script
|
// Message port to background script
|
||||||
|
|||||||
@@ -47,12 +47,6 @@ if (document.currentScript) {
|
|||||||
|
|
||||||
isFramework = true;
|
isFramework = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* Framework API library requires webcomponents for the cast
|
|
||||||
* button custom element (<google-cast-launcher>).
|
|
||||||
*/
|
|
||||||
loadScript(browser.runtime.getURL("vendor/webcomponents-lite.js"));
|
|
||||||
|
|
||||||
const script = loadScript(CAST_FRAMEWORK_SCRIPT_URL);
|
const script = loadScript(CAST_FRAMEWORK_SCRIPT_URL);
|
||||||
script.addEventListener("load", ev => {
|
script.addEventListener("load", ev => {
|
||||||
callPageReadyFunction();
|
callPageReadyFunction();
|
||||||
|
|||||||
Reference in New Issue
Block a user