I am using Selenium 3.141.0 with Python, for Firefox 88.0 with geckodriver 0.29.1.
Previously, I was able to run the below JavaScript execution to remove unwanted characters (in this case ®) from web pages, as demonstrated in this answer:
driver.execute_script("var replaced = $('body').html().replace(/(®)/g,''); $('body').html(replaced);")
However, at some point recently this no longer works, giving the following error:
JavascriptException: Message: SecurityError: The operation is insecure.
Presumably, when updating Selenium, Firefox, or geckodriver, this function broke – unless there is something on the web page that I crawl (which is not mine) that has changed, that is making the script impossible to execute (I don't know what on the web page possibly would cause this).
What could be the reason behind this issue, and is it possible to "override" the SecurityError and execute the script?