Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Regarding disabling content scripts dynamically

43 views
Skip to first unread message

Suhas ML

unread,
Nov 25, 2024, 2:22:40 PM11/25/24
to Chromium Extensions
Hi, I am building an extension that can be toggled on and off where the content script is injected or removed dynamically. 
I am able to inject that at runtime based on the toggle button but unable to remove that when turned off. 
Can somebody suggest a solution for this please?!

woxxom

unread,
Nov 25, 2024, 5:32:55 PM11/25/24
to Chromium Extensions, Suhas ML
Once the code is injected it cannot be de-injected, but you can send a message to the tab that tells the running code to stop doing what it's currently doing e.g. unregister its listeners, remove DOM elements, and so on. See https://stackoverflow.com/a/75283704
Reply all
Reply to author
Forward
0 new messages