Пример #1
0
        private void Browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e)
        {
            if (!e.Frame.IsMain)
            {
                return;
            }

            lastUrl = e.Url;

            if (_api != null)
            {
                var initScript = @"(async () => {
                    await CefSharp.BindObjectAsync('OverlayPluginApi');
                    OverlayPluginApi.overlayName = " + JsonConvert.SerializeObject(this.overlayName) + @";
                    OverlayPluginApi.overlayUuid = " + JsonConvert.SerializeObject(this.overlayUuid) + @";
                    OverlayPluginApi.ready = true;
                })();";
                e.Frame.ExecuteJavaScriptAsync(initScript, "init");
            }

            foreach (var item in this.scriptQueue)
            {
                e.Frame.ExecuteJavaScriptAsync(item, "injectOnLoad");
            }
            this.scriptQueue.Clear();

            try
            {
                BrowserStartLoading?.Invoke(this, new BrowserLoadEventArgs(0, e.Url));
            } catch (Exception ex)
            {
                BrowserConsoleLog?.Invoke(this, new BrowserConsoleLogEventArgs(ex.ToString(), "", 1));
            }
        }
Пример #2
0
        private void Browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e)
        {
            var initScript = @"(async () => {
                await CefSharp.BindObjectAsync('OverlayPluginApi');
                OverlayPluginApi.overlayName = " + JsonConvert.SerializeObject(this.overlayName) + @";
                OverlayPluginApi.ready = true;
            })();";

            e.Frame.ExecuteJavaScriptAsync(initScript, "init");

            foreach (var item in this.scriptQueue)
            {
                e.Frame.ExecuteJavaScriptAsync(item, "injectOnLoad");
            }
            this.scriptQueue.Clear();

            BrowserStartLoading?.Invoke(this, new BrowserLoadEventArgs(0, e.Url));
        }