Haha, yes it does get ugly very fast. I had to add a 1s immunity after taking green jars. It wasn't playable otherwise.
I just checked your game, indeed, same idea (the best one I'd say :p).
I had some trouble caching all jars movements in the implementation.