Refactor chrome extension