Sounds like a great idea using the PHP filters. I’ll check for the correct implementation and post the code.
For the JS solution, I tried adding a condition from the browser inspector which doesn’t seem to work. So, I assume this needs to happen before the initialization.