MicrosoftEdge / MicrosoftEdge/WebView2Feedback
Custom Schemes should avoid CSP
@Lakshmisha-KS is already working on this.
Since Feb 12, 2025.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
I would like to add custom script and css files to an existing intRAnet site which I am targeting for my webview2. I am creating something similar to the desktop version of MSTeams just for another internal site. Currently one must either (1) add css/Javascript as text by creating a script element or use (2) AddScriptToExecuteOnDocumentCreatedAsync.
From what I have experienced so far option (1) leads to formating difficulties with the text for example which " '
etc can be used. Option (2) adds the same file to all documents and cannot distinguish which seems like a waste of resources and if one has different js files for different document one must not use similar variable or function names in the different JS files as all of them are loaded.
Describe the solution you'd like and alternatives you've considered
For scripts I know I can use AddScriptToExecuteOnDocumentCreatedAsync, however this is a pretty broad function at the moment, I want to target 1 document but this function adds the script to all documents (ie. all frames as well) it seems to me to be pretty blunt.
One of the main reasons I am making this request is that Chrome Extensions has the ability to add JS files to specific documents, further those files then appear in the DEV window and can be debugged.
Through the use of a short injection of code JS could be added and removed for that matter with pinpoint accuracy.
(function addScript()
{
var scriptEl = document.createElement('script');
scriptEl.type = 'text/javascript';
scriptEl.src = 'mycustomscheme://myapp/resources/script.js';
document.getElementsByTagName("head")[0].appendChild(scriptEl);
})()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.