Skip to content

Commit

Permalink
Fix CSS injection for sites with strict CSP
Browse files Browse the repository at this point in the history
This fix addresses an issue occurring on some pages where the response header includes
`content-security-policy: require-trusted-types-for 'script'`.
  • Loading branch information
vvto33 committed Aug 1, 2024
1 parent d18fc7a commit 0607d8e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions browser-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ void BrowserClient::OnLoadEnd(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame> frame,

std::string script;
script += "const obsCSS = document.createElement('style');";
script += "obsCSS.innerHTML = decodeURIComponent(\"" +
uriEncodedCSS + "\");";
script += "obsCSS.appendChild(document.createTextNode(decodeURIComponent(\"" +
uriEncodedCSS + "\")));";
script += "document.querySelector('head').appendChild(obsCSS);";

frame->ExecuteJavaScript(script, "", 0);
Expand Down

0 comments on commit 0607d8e

Please sign in to comment.