Created
January 3, 2020 12:00
-
-
Save cwhsu1984/c15507c4f26433fecca2482fa51aa5a4 to your computer and use it in GitHub Desktop.
try to use selenium with mod-header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using OpenQA.Selenium.Chrome; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var options = new ChromeOptions(); | |
options.AddExtension(Path.GetFullPath(@"D:\workspaces\local\chromedriver_win32\modHeader.crx")); | |
var driver = new ChromeDriver("D:\\workspaces\\local\\chromedriver_win32\\", options); | |
driver.Navigate().GoToUrl("chrome-extension://idgpnmonknjnojddfkpgkljpfnnfcklj/icon.png"); | |
driver.ExecuteScript( | |
"localStorage.setItem('profiles', JSON.stringify([{ " + | |
" title: 'Selenium', hideComment: true, appendMode: '', " + | |
" headers: [ " + | |
" {enabled: true, name: 'X-Forwarded-For', value: '223.24.189.66', comment: ''}, " + | |
" ], " + | |
" respHeaders: [], " + | |
" filters: [] " + | |
"}]));" | |
); | |
driver.Navigate().GoToUrl("https://example.com/"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello. i've tried this one out but can't get past the Access denied I'm getting when changing the localStorage.
do you know how to get past that? :)