You should definitely remove all "Trigger once" from the function, don't use them.
I am pretty sure that the second "While" loop is infinite and that's why the browser freezes.
If you look at the very first screenshot in your post, it has While loop in event #9. It checks if LengthOfPattern2<NonChangeableLenghtOfPattern, but these two values are not changed inside the loop. So the loop just never ends.