Converted some of content.js to actual TypeScript