ManagedCode.Playwright.Stealth 0.0.1

Prefix Reserved
dotnet add package ManagedCode.Playwright.Stealth --version 0.0.1
                    
NuGet\Install-Package ManagedCode.Playwright.Stealth -Version 0.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ManagedCode.Playwright.Stealth" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ManagedCode.Playwright.Stealth" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ManagedCode.Playwright.Stealth" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ManagedCode.Playwright.Stealth --version 0.0.1
                    
#r "nuget: ManagedCode.Playwright.Stealth, 0.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ManagedCode.Playwright.Stealth@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ManagedCode.Playwright.Stealth&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ManagedCode.Playwright.Stealth&version=0.0.1
                    
Install as a Cake Tool

ManagedCode.Playwright.Stealth (.NET)

ManagedCode.Playwright.Stealth applies a curated set of init scripts to Microsoft.Playwright contexts to reduce common bot-detection signals. It adapts the original playwright_stealth scripts for .NET with ManagedCode conventions.

Install

dotnet add package ManagedCode.Playwright.Stealth

Quick Start

using Microsoft.Playwright;
using ManagedCode.Playwright.Stealth;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
{
    Headless = true
});

var context = await browser.NewContextAsync();

// Apply ManagedCode.Playwright.Stealth before creating pages.
await context.ApplyStealthAsync();

var page = await context.NewPageAsync();
await page.GotoAsync("https://www.browserscan.net/bot-detection");

Configuration

var config = new StealthConfig
{
    NavigatorHardwareConcurrency = 8,
    NavigatorLanguages = true,
    NavigatorUserAgentValue = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    WebglVendor = true
};

// Apply ManagedCode.Playwright.Stealth with a custom config.
await context.ApplyStealthAsync(config);

Usage Variants (C#/.NET)

Apply stealth on a page (if you already have a page instance):

var page = await context.NewPageAsync();

// Apply ManagedCode.Playwright.Stealth to an existing page.
await page.ApplyStealthAsync();

await page.GotoAsync("https://www.browserscan.net/bot-detection");

Disable individual patches:

var config = new StealthConfig
{
    WebDriver = false,
    WebglVendor = false,
    NavigatorLanguages = false,
    NavigatorPlugins = false,
    ChromeRuntime = false
};

// Apply ManagedCode.Playwright.Stealth with selective patches disabled.
await context.ApplyStealthAsync(config);

Customize platform, vendor, and WebGL identity:

var config = new StealthConfig
{
    NavigatorPlatformValue = "Win32",
    NavigatorVendorValue = "Google Inc.",
    NavigatorUserAgentValue = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    Vendor = "Intel Inc.",
    Renderer = "Intel Iris OpenGL Engine",
    Languages = new[] { "en-US", "en" },
    NavigatorHardwareConcurrency = 8
};

// Apply ManagedCode.Playwright.Stealth with explicit platform and WebGL identity.
await context.ApplyStealthAsync(config);

Run on insecure origins (affects chrome.runtime behavior):

var config = new StealthConfig
{
    RunOnInsecureOrigins = true
};

// Apply ManagedCode.Playwright.Stealth on insecure origins.
await context.ApplyStealthAsync(config);

Patched Signals

The default configuration applies patches for:

  • navigator.webdriver
  • navigator.plugins and navigator.mimeTypes
  • navigator.languages
  • navigator.userAgent
  • navigator.vendor
  • navigator.platform
  • navigator.hardwareConcurrency
  • window.chrome / chrome.runtime / related Chrome APIs
  • WebGL vendor/renderer
  • window.outerWidth / window.outerHeight
  • media codecs and hairline fixes
  • iframe contentWindow quirks

Configuration Reference

Common options in StealthConfig:

  • WebDriver, WebglVendor, ChromeApp, ChromeCsi, ChromeLoadTimes, ChromeRuntime
  • IframeContentWindow, MediaCodecs, Hairline, OuterDimensions
  • NavigatorLanguages, NavigatorPermissions, NavigatorPlatform, NavigatorPlugins, NavigatorUserAgent, NavigatorVendor
  • NavigatorHardwareConcurrency, NavigatorUserAgentValue, NavigatorPlatformValue, NavigatorVendorValue
  • Vendor, Renderer, Languages, RunOnInsecureOrigins

Testing

Integration tests target these bot-detection sites:

These sites can change at any time. If a site changes, update the corresponding test assertions.

Run tests (Playwright browsers install automatically on first run):

dotnet test --solution ManagedCode.Playwright.Stealth.slnx -c Release

On Linux CI runners, set PLAYWRIGHT_INSTALL_DEPS=1 to install system dependencies (playwright install --with-deps) when tests start.

Google search verification is optional (Google may block automated traffic). Enable it with:

RUN_GOOGLE_SEARCH_TESTS=1 dotnet test --solution ManagedCode.Playwright.Stealth.slnx -c Release

Attribution

This project uses code from the original playwright_stealth repository and adapts it for .NET: https://github.com/AtuboDad/playwright_stealth

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.1 77 2/4/2026