Update popup.js

classified the popup and removed some legacy code