So, I would like to create an offscreen CefSharp scraper that would be difficult to detect with fingerprints. However, when I use it to open https://amiunique.org/fp and click "View more details", my screen resolution is displayed as "1366x768x0", which means that my browser's colorDepth property is set to zero.
My guess would be that I need to either enable some kind of graphic option in the settings, or override the window.screen property with something like
window.screen = new function() { this.colorDepth = 24, this.pixelDepth = 24};
But none of that seems to work. Is there some way to fix that, or maybe some kind of workaround?
Code sample:
public static bool SiteReady;
static void Main(string[] args)
{
Cef.Initialize();
Task.Run(async () => await Scrape()).Wait();
Helper.Log("Done!");
Console.ReadLine();
}
public static async Task Scrape()
{
using (var browser = new ChromiumWebBrowser("https://amiunique.org/fp"))
{
SiteReady = false;
// create the loading handler
EventHandler<LoadingStateChangedEventArgs> handler = null;
handler = async (sender, args) =>
{
if (args.IsLoading) return;
var view = (ChromiumWebBrowser)sender;
view.LoadingStateChanged -= handler;
// wait for the page to load completely
await Task.Delay(20000);
// change the window size to fit all displayed data
view.Size = new Size(2000, 2500);
// click the "view more details" button and wait for the next page to load
await view.EvaluateScriptAsync("document.getElementById('detBut').click();");
await Task.Delay(1000);
while (view.IsLoading)
{
await Task.Delay(10);
}
// save the screenshot
using (var task = await view.ScreenshotAsync())
{
task.Save("C:/Screens/screenshot.png");
}
// indicate that we are done with the page
SiteReady = true;
};
browser.LoadingStateChanged += handler;
while (SiteReady != true)
{
await Task.Delay(10);
}
}
}