Using a custom JS script to handle a large number of rules on a condition?