public FormNotificationScreenshotable(Action callback, FormBrowser owner, PluginManager pluginManager, string html, int width) : base(owner, false) { this.plugins = pluginManager; int realWidth = BrowserUtils.Scale(width, DpiScale); browser.RegisterJsBridge("$TD_NotificationScreenshot", new ScreenshotBridge(this, SetScreenshotHeight, callback)); browser.LoadingStateChanged += (sender, args) => { if (args.IsLoading) { return; } string script = Program.Resources.LoadSilent("screenshot.js"); if (script == null) { this.InvokeAsyncSafe(callback); return; } using IFrame frame = args.Browser.MainFrame; CefScriptExecutor.RunScript(frame, script.Replace("{width}", realWidth.ToString()).Replace("{frames}", TweetScreenshotManager.WaitFrames.ToString()), "gen:screenshot"); }; SetNotificationSize(realWidth, 1024); LoadTweet(new DesktopNotification(string.Empty, string.Empty, string.Empty, html, 0, string.Empty, string.Empty)); }
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e) { CefScriptExecutor.RunScript(e.Frame, "Array.prototype.forEach.call(document.getElementsByTagName('A'), ele => ele.addEventListener('click', e => { e.preventDefault(); window.open(ele.getAttribute('href')); }))", "gen:links"); }