Fix loop protection

Close #702.

This makes the infinite loop detection use 100ms timeout not count loops, and it also stops the protection from messing with HTML and CSS.