I am building a web scraper using node js and selenium. Apparently selenium is not in the ability to modify the header of the get request. From what I read on stack overflow, this can be solved using the chrome extension ModHeader. However, when I try to use one of the predefined test headers, the extension loads but the predefined header is not present. I guess something is wrong with the driver.executscript() but not sure, since no error is thrown:
var driver = new Builder().forBrowser('chrome').setChromeOptions(new chrome.Options().addExtensions('ModHeader.crx')/*.headless()*/).build()
driver.executeScript(function () {
localStorage.setItem('profiles', JSON.stringify(
[{"appendMode":false,"backgroundColor":"#6a83a1","filters":[],"headers":[{"comment":"","enabled":true,"name":"","value":""},{"comment":"","enabled":true,"name":"User-Agent","value":"'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'"}],"hideComment":true,"respHeaders":[],"shortTitle":"1","textColor":"#ffffff","title":"Profile 1","urlReplacements":[],"alwaysOn":true}]
)//end of stringify
)//end of setItem
})//end of executescript
driver.get("http://stackoverflow.com/")