Skip to content

Instantly share code, notes, and snippets.

@cwhsu1984
Created January 3, 2020 12:00
Show Gist options
  • Save cwhsu1984/c15507c4f26433fecca2482fa51aa5a4 to your computer and use it in GitHub Desktop.
Save cwhsu1984/c15507c4f26433fecca2482fa51aa5a4 to your computer and use it in GitHub Desktop.
try to use selenium with mod-header
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/");
}
}
}
@yotsubakoiwai
Copy link

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? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment