-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarification Needed on Using Func with ScriptInjection #178
Comments
The script injection feature might not be suitable to be executed from dotnet because dotnet is not available in the injected window. I haven't tested it personally yet, but it looks like it would be better to separate the injection into another JS file and use the Files property to inject the scripts. |
Also, evaluating JS in string is completely blocked by manifest v3, so your code that returns JS string will just be a string and will not be executed. |
I’ve encountered difficulties using the Func property from ScriptInjection and haven’t been able to get it working. Any guidance or examples would be greatly appreciated.
` string InjectScriptAction()
{
return "function colorRed2(){console.log("colorRed3"); document.body.style.backgroundColor = 'red'; }";
}
var scriptInjection = new ScriptInjection
{
Target = new InjectionTarget
};
var result = await WebExtensions.Scripting.ExecuteScript(scriptInjection);`
manifest.json:
{
"manifest_version": 3,
"name": "Browser Extension With Blazor Extension",
"description": "My browser extension built with Blazor WebAssembly",
"version": "0.1",
"permissions": [
"activeTab",
"tabs",
"storage",
"webRequest",
"bookmarks",
"cookies",
"downloads",
"notifications",
"webNavigation",
"contextMenus",
"scripting"
],
"optional_permissions": [
"topSites"
],
"optional_host_permissions": [
"https:///",
"http:///"
],
"host_permissions": [
"http:///",
"https:///"
],
"background": {
"service_worker": "content/BackgroundWorker.js",
"type": "module"
},
"action": {
"default_popup": "popup.html"
},
"options_ui": {
"page": "options.html",
"open_in_tab": true
},
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'"
},
"content_scripts": [
{
"matches": ["<all_urls>"]
}
],
"web_accessible_resources": [
{
"resources": [
"framework/",
"content/",
"js/*.js"
],
"matches": [ "<all_urls>" ]
}
]
}
The text was updated successfully, but these errors were encountered: