private void FinishLoading(object sender, BrowserLoadEventArgs e) { if (Config.ActwsCompatibility) { var charName = JsonConvert.SerializeObject(FFXIVRepository.GetPlayerName() ?? "YOU"); var charID = JsonConvert.SerializeObject(FFXIVRepository.GetPlayerID()); ExecuteScript("__OverlayPlugin_ws_faker({ type: 'broadcast', msgtype: 'SendCharName', msg: { charName: " + charName + ", charID: " + charID + " }});"); } }
private void FinishLoading(object sender, BrowserLoadEventArgs e) { if (Config.ActwsCompatibility) { var charName = JsonConvert.SerializeObject(repository.GetPlayerName() ?? "YOU"); var charID = JsonConvert.SerializeObject(repository.GetPlayerID()); ExecuteScript(@"var msg = { charName: " + charName + ", charID: " + charID + @" }; if (window.__OverlayPlugin_ws_faker) { __OverlayPlugin_ws_faker({ type: 'broadcast', msgtype: 'SendCharName', msg }); } else { window.__OverlayPlugin_char_msg = msg; }"); } if (Preview) { try { var pluginPath = container.Resolve<PluginMain>().PluginDirectory; #if DEBUG var previewPath = Path.Combine(pluginPath, "libs", "resources", "preview.json"); #else var previewPath = Path.Combine(pluginPath, "resources", "preview.json"); #endif var eventData = JObject.Parse(File.ReadAllText(previewPath)); // Since we can't be sure when the overlay is ready to receive events, we'll just send one // per second (which is the same rate the real events are sent at). previewTimer = new System.Threading.Timer((state) => { HandleEvent(eventData); ExecuteScript("document.dispatchEvent(new CustomEvent('onExampleShowcase', null));"); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(1)); } catch (Exception ex) { logger.Log(LogLevel.Error, $"{Name}: Failed to load preview data: {ex}"); } } if (e.Url.StartsWith("about:blank") && e.Url != Config.Url) { base.Navigate(Config.Url); } }