I tried to use a MutationObserver
in a user script to get a "script added" event and simply removed the script and src attributes. I also tried to put the mutation observer into the webpage as explained here. Script elements in the body are still executed, despite removing the attributes. I tested this on Firefox.
Asked
Active
Viewed 95 times
0

Cubimon
- 150
- 3
- 11
-
1MutationObserver is asynchronous so it runs after the script has already executed. In Firefox you can use onbeforescriptexecute and call preventDefault inside, [example](/a/23943740). – wOxxOm Nov 25 '19 at 08:54
-
Just tested it and it works flawlessly, thank you @wOxxOm – Cubimon Nov 27 '19 at 20:13
1 Answers
0
onbeforescriptexecute
makes things easier as @wOxxOm said. I didn't have to care when if head/body exists to listen for muration changes.

Cubimon
- 150
- 3
- 11