Replace function does not replace all occurences

Replace function did not replace all classes, script failed on clicking dom items with more then 2 classes.
This adds replace with a regex replace with a global flag to replace all occurrences, as well as trimming it so cases lik class="   btn" won't break the code