Thanks for this update.
However, I thought at first the script was not working. It turned out that I needed to review and accept the terms of use for the layers I wanted to view. (The two layers in question are Maryland iMAP Six-Inch and Virginia Aerial Imagery.) Ironically, the links to both of these site’s T&C pages resulted in 404 errors, but I was able to “accept” the nonexistent terms and view the layers in both cases.
It would be helpful if some kind of alert or error message was displayed when a user tries to activate a layer that requires this acceptance process, so they don’t think the script is broken!