Refactored index.js in content scripts