1

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?

mlw
  • 9
  • 1
  • You can't use it in the browser. There's no premade solution. You'll need to implement your workflow using standard JS and possibly a few `chrome` API like `chrome.tabs.update` for URL change. – wOxxOm Jun 16 '22 at 04:57

0 Answers0