No problem at all. Trying to figure out an approach to create the script.
I can get the AM code from the script listener for the layer group visibility toggle.
Make a function with the AM code, declare a variable for the layer group,
use an if statement to check the visibility of the layer group.
If visibility is true then do the opposite.