Refactoring JS/XUL