fysh711426 / UndetectedChromeDriver

GNU General Public License v3.0
166 stars 61 forks source link

I want to customize more parameters, is it possible? #11

Open vudonblog opened 2 years ago

vudonblog commented 2 years ago

Hello I want to edit more Screen, Timezone,Language,Geo Location is it possible and where to replace the parameters hope you help

fysh711426 commented 2 years ago

I released a alpha package, you can try it.

PM> Install-Package Selenium.UndetectedChromeDriver -Version 1.0.6-alpha
// Set screen.
options.AddArguments("--window-size=1920,1080");
options.AddArguments("--start-maximized");

// Set language.
options.AddArguments("--lang=en");

// Set enable geolocation.
var prefs = new Dictionary<string, object>
{
    ["profile.default_content_setting_values.geolocation"] = 1
};

// using keyword is required to dispose the chrome driver
using var driver = UndetectedChromeDriver.Create(
    options: options,
    driverExecutablePath: driverExecutablePath,
    prefs: prefs);

// Set timezone.
driver.ExecuteCdpCommand(
    "Emulation.setTimezoneOverride",
    new Dictionary<string, object>
    {
        ["timezoneId"] = "America/New_York"
    });

// Set geolocation.
driver.ExecuteCdpCommand(
    "Emulation.setGeolocationOverride",
    new Dictionary<string, object>
    {
        ["latitude"] = 42.1408845,
        ["longitude"] = -72.5033907,
        ["accuracy"] = 100
    });

driver.GoToUrl("https://nowsecure.nl");
vudonblog commented 2 years ago

thank you. Overly supportive

vudonblog commented 2 years ago

i tried and got error setGeolocationOverride 2 values of latitude and longitude are not correct, checkiphey it is taken by ip

if possible can you please tell me how to edit WebGL WebRTC, City and zipcode on Location thank you very much

fysh711426 commented 2 years ago

Is the site not supporting setGeolocationOverride?
If you want to prevent ip detection, it may not be possible.

1656454933781

fysh711426 commented 2 years ago
// Disable WebGL.
options.AddArgument("--disable-gpu");
options.AddArgument("--disable-software-rasterizer");
// Test
driver.GoToUrl("https://bot.sannysoft.com/");
// Disable WebRTC.
var prefs = new Dictionary<string, object>
{
    ["webrtc.ip_handling_policy"] = "disable_non_proxied_udp",
    ["webrtc.multiple_routes_enabled"] = false,
    ["webrtc.nonproxied_udp_enabled"] = false
};
using var driver = UndetectedChromeDriverCreate(
    ...
    prefs: prefs);
// Test
driver.GoToUrl("https://browserleaks.com/ip");

City and zipcode I didn't find a way to change.