I need to modify a JavaScript that runs on a webpage. The procedure described here Override Javascript file in chrome works fine if I set it up manually, however, I would like to set up the override programatically using Selenium (either Geckodriver or Chromedriver) and Python. Is that at all possible? I have the modified JavaScript on my local computer.
2 Answers
I suggest using the extension Resource Override, as stated in answer.
To load the extension setting, I tried to
options = Options()
options.add_argument("--user-data-dir=C:/Users/USERNAME/AppData/Local/Google/Chrome/User Data")
driver = webdriver.Chrome(options=options)
I am not sure whether there is more elegant way to load the setting of the extension.
FYI: If you want to change the setting of the extensions programmatically, you can refer to this anwser
execute_cdp_cmd)?