The background script of my extension dynamically registers content scripts based on the user settings. When the user’s settings are updated, the background script unregisters the previous content script and registers the new one using the Content Script API. The content script applies a CSS to the page using the CSS property in the content script object.
The issue with this approach is that the CSS changes are not actually applied to open tabs until the user refreshes each tab or navigates to a new page.
Is there a way to modify or remove the CSS that has been applied to an open tab when I unregister the previous content script?
I know I could do this using JavaScript instead to inject a <style>
element onto the page and then just call another script to change the text content of that element. But the issue with that approach is that there’s a delay between when the page is loaded and when the <style>
element is created.