CefSharp Offscreen的window.screen.colorDepth属性

时间:2017-12-13 06:50:52

标签: cefsharp cefsharp.offscreen

所以,我想创建一个难以用指纹检测到的屏幕外CefSharp刮刀。但是,当我使用它打开https://amiunique.org/fp并点击"查看更多详细信息"时,我的屏幕分辨率显示为" 1366x768x0",这意味着我的浏览器colorDepth属性设置为零。

Like this

我的猜测是我需要在设置中启用某种图形选项,或者使用类似

的覆盖window.screen属性
window.screen = new function() { this.colorDepth = 24, this.pixelDepth = 24};

但这似乎都不起作用。有没有办法解决这个问题,或者某种解决方法?

代码示例:

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);
        }
    }
}

0 个答案:

没有答案