mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-13 02:49:58 +00:00
Add partial YouTube compatibility shim
This commit is contained in:
10
ext/src/compat/youtube.js
Normal file
10
ext/src/compat/youtube.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Insert script before first script is run
|
||||||
|
document.addEventListener("beforescriptexecute", function onBeforeScriptExecute () {
|
||||||
|
document.removeEventListener("beforescriptexecute", onBeforeScriptExecute);
|
||||||
|
|
||||||
|
const scriptElement = document.createElement("script");
|
||||||
|
scriptElement.src = browser.runtime.getURL("vendor/webcomponents-lite.min.js");
|
||||||
|
document.head.prepend(scriptElement);
|
||||||
|
});
|
||||||
@@ -17,6 +17,13 @@
|
|||||||
, "background": {
|
, "background": {
|
||||||
"scripts": [ "main.js" ]
|
"scripts": [ "main.js" ]
|
||||||
}
|
}
|
||||||
|
, "content_scripts": [
|
||||||
|
{
|
||||||
|
"matches": [ "https://www.youtube.com/*" ]
|
||||||
|
, "js": [ "compat/youtube.js" ]
|
||||||
|
, "run_at": "document_start"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
, "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
|
, "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
|
||||||
, "default_locale": "en"
|
, "default_locale": "en"
|
||||||
@@ -38,6 +45,6 @@
|
|||||||
|
|
||||||
, "web_accessible_resources": [
|
, "web_accessible_resources": [
|
||||||
"shim/bundle.js"
|
"shim/bundle.js"
|
||||||
, "dm.js"
|
, "vendor/webcomponents-lite.min.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
12
ext/src/vendor/webcomponents-lite.min.js
vendored
Normal file
12
ext/src/vendor/webcomponents-lite.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -18,6 +18,7 @@ module.exports = (env) => ({
|
|||||||
, "mediaCast" : `${includePath}/mediaCast.js`
|
, "mediaCast" : `${includePath}/mediaCast.js`
|
||||||
, "mirroringCast" : `${includePath}/mirroringCast.js`
|
, "mirroringCast" : `${includePath}/mirroringCast.js`
|
||||||
, "messageRouter" : `${includePath}/messageRouter.js`
|
, "messageRouter" : `${includePath}/messageRouter.js`
|
||||||
|
, "compat/youtube" : `${includePath}/compat/youtube.js`
|
||||||
}
|
}
|
||||||
, output: {
|
, output: {
|
||||||
filename: "[name].js"
|
filename: "[name].js"
|
||||||
@@ -34,25 +35,32 @@ module.exports = (env) => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Copy static assets
|
// Copy static assets
|
||||||
, new CopyWebpackPlugin([{
|
, new CopyWebpackPlugin([
|
||||||
from: includePath
|
{
|
||||||
, to: env.outputPath
|
from: includePath
|
||||||
, ignore: [ "*.js", "*.jsx" ]
|
, to: env.outputPath
|
||||||
, transform (content, path) {
|
, ignore: [ "*.js", "*.jsx" ]
|
||||||
// Access to variables in static files
|
, transform (content, path) {
|
||||||
if (path.endsWith(".json")) {
|
// Access to variables in static files
|
||||||
return Buffer.from(content.toString()
|
if (path.endsWith(".json")) {
|
||||||
.replace("EXTENSION_NAME", env.extensionName)
|
return Buffer.from(content.toString()
|
||||||
.replace("EXTENSION_ID", env.extensionId)
|
.replace("EXTENSION_NAME", env.extensionName)
|
||||||
.replace("EXTENSION_VERSION", env.extensionVersion)
|
.replace("EXTENSION_ID", env.extensionId)
|
||||||
.replace("MIRRORING_APP_ID", env.mirroringAppId)
|
.replace("EXTENSION_VERSION", env.extensionVersion)
|
||||||
.replace("APPLICATION_NAME", env.applicationName)
|
.replace("MIRRORING_APP_ID", env.mirroringAppId)
|
||||||
.replace("APPLICATION_VERSION", env.applicationVersion));
|
.replace("APPLICATION_NAME", env.applicationName)
|
||||||
}
|
.replace("APPLICATION_VERSION", env.applicationVersion));
|
||||||
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}])
|
, {
|
||||||
|
// Copy vendor dir
|
||||||
|
from: path.join(includePath, "vendor")
|
||||||
|
, to: path.join(env.outputPath, "vendor")
|
||||||
|
}
|
||||||
|
])
|
||||||
]
|
]
|
||||||
, mode: "development"
|
, mode: "development"
|
||||||
, module: {
|
, module: {
|
||||||
|
|||||||
Reference in New Issue
Block a user