Last active
August 8, 2024 06:19
-
-
Save penbuvt/d480e3f816e6d8ede47334ab57de369d to your computer and use it in GitHub Desktop.
Patch to fix CSS not being injected by OBS browser sources on YouTube pop-out chat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/browser-client.cpp b/browser-client.cpp | |
| index 1c0ca26..09b6753 100644 | |
| --- a/browser-client.cpp | |
| +++ b/browser-client.cpp | |
| @@ -678,9 +678,11 @@ void BrowserClient::OnLoadEnd(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame> frame, | |
| CefURIEncode(bs->css, false).ToString(); | |
| std::string script; | |
| + script += "const innerHTMLPolicy = window.trustedTypes.createPolicy(" + | |
| + "'innerHTML', { createHTML: (html) => html });"; | |
| script += "const obsCSS = document.createElement('style');"; | |
| - script += "obsCSS.innerHTML = decodeURIComponent(\"" + | |
| - uriEncodedCSS + "\");"; | |
| + script += "obsCSS.innerHTML = innerHTMLPolicy.createHTML(" + | |
| + "decodeURIComponent(\"" + uriEncodedCSS + "\"));"; | |
| script += "document.querySelector('head').appendChild(obsCSS);"; | |
| frame->ExecuteJavaScript(script, "", 0); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This patch is the output of this stream: https://www.youtube.com/watch?v=F29oGpZSGsk
A similar patch has already been submitted to the obsproject/obs-browser repo: obsproject/obs-browser#449