Cleaned up and simplified JS injection code.