I'm writing a chrome extension that has a web scraper/webdriver built in (using selenium/chromedriver). Ideally, the extension popup asks the user for their location, then launches a webdriver to get the weather in their location and then open Youtube to play a corresponding song (this project is for fun and practice). However, when I try to use selenium as follows, I keep getting an error that "require() is not defined." I've tried using import statements instead with the "type": "module" notation inside my script tag -- that also gave the same error. I've tried importing the scripts in background.js but then I got an error "service worker not registered." I thought to use browserify, but I could not get that properly installed (I spent hours playing around with it to no avail).
const {By,Key,Builder}=require('selenium-webdriver') ;
require('chromedriver');
At this point, I'm questioning -- is it even possible to use selenium or some other webscraper/webdriver inside my chrome extension? If so, what's the best way to import everything so it's acceptable for manifest v3?