mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 01:29:58 +00:00
Splits some background script functionality into separate modules: - Receiver selector handling is moved to ./SelectorManager. - Status bridge handling is moved to ./StatusManager. - Menu creation and updates are handled in ./createMenus. - Shim creation is handled in ./createShim. TypedEventTarget allows EventTarget-derived classes to export typed events. Options type definition is moved to ./lib/options, module assumes more responsibility for update handling and provides a "changed" event. Private cast._requestSession method allows bypassing receiver selector.
36 lines
906 B
TypeScript
36 lines
906 B
TypeScript
"use strict";
|
|
|
|
import { CAST_LOADER_SCRIPT_URL
|
|
, CAST_SCRIPT_URLS } from "../lib/endpoints";
|
|
|
|
|
|
(window.wrappedJSObject as any).chrome = cloneInto({}, window);
|
|
|
|
|
|
/**
|
|
* Replace the src property setter on <script> elements to
|
|
* intercept the new value.
|
|
*
|
|
* If it matches one of Chrome's cast extension sender script
|
|
* URLs, replace it with the standard API URL, the request for
|
|
* which is handled in the main script.
|
|
*/
|
|
const { get, set } = Reflect.getOwnPropertyDescriptor(
|
|
HTMLScriptElement.prototype.wrappedJSObject, "src");
|
|
|
|
Reflect.defineProperty(
|
|
HTMLScriptElement.prototype.wrappedJSObject, "src", {
|
|
|
|
configurable: true
|
|
, enumerable: true
|
|
, get
|
|
|
|
, set: exportFunction(function (value) {
|
|
if (CAST_SCRIPT_URLS.includes(value)) {
|
|
return set.call(this, CAST_LOADER_SCRIPT_URL);
|
|
}
|
|
|
|
return set.call(this, value);
|
|
}, window)
|
|
});
|