Extract script for state detection.