1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-13 17:34:08 +02:00

Fix plugin code running in blank notifications from previous commit

This commit is contained in:
chylex 2020-06-04 04:33:50 +02:00
parent 8a0a215443
commit 63de08c635
3 changed files with 7 additions and 4 deletions

View File

@ -12,6 +12,7 @@
using TweetLib.Core.Features.Notifications;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Features.Plugins.Enums;
using TweetLib.Core.Features.Twitter;
namespace TweetDuck.Browser.Notification{
abstract partial class FormNotificationMain : FormNotificationBase{
@ -77,7 +78,7 @@ protected FormNotificationMain(FormBrowser owner, PluginManager pluginManager, b
browser.LoadingStateChanged += Browser_LoadingStateChanged;
browser.FrameLoadEnd += Browser_FrameLoadEnd;
plugins.Register(PluginEnvironment.Notification, new PluginDispatcher(browser));
plugins.Register(PluginEnvironment.Notification, new PluginDispatcher(browser, url => TwitterUrls.IsTweetDeck(url) && url != BlankURL));
mouseHookDelegate = MouseHookProc;
Disposed += (sender, args) => StopMouseHook(true);

View File

@ -79,7 +79,7 @@ public TweetDeckBrowser(FormBrowser owner, PluginManager plugins, TweetDeckBridg
this.browser.SetupZoomEvents();
owner.Controls.Add(browser);
plugins.Register(PluginEnvironment.Browser, new PluginDispatcher(browser));
plugins.Register(PluginEnvironment.Browser, new PluginDispatcher(browser, TwitterUrls.IsTweetDeck));
Config.MuteToggled += Config_MuteToggled;
Config.SoundNotificationChanged += Config_SoundNotificationInfoChanged;

View File

@ -12,8 +12,10 @@ sealed class PluginDispatcher : IPluginDispatcher{
private readonly IWebBrowser browser;
private readonly IScriptExecutor executor;
private readonly Func<string, bool> executeOnUrl;
public PluginDispatcher(IWebBrowser browser){
public PluginDispatcher(IWebBrowser browser, Func<string, bool> executeOnUrl){
this.executeOnUrl = executeOnUrl;
this.browser = browser;
this.browser.FrameLoadEnd += browser_FrameLoadEnd;
this.executor = new CefScriptExecutor(browser);
@ -26,7 +28,7 @@ void IPluginDispatcher.AttachBridge(string name, object bridge){
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
IFrame frame = e.Frame;
if (frame.IsMain && TwitterUrls.IsTweetDeck(frame.Url)){
if (frame.IsMain && executeOnUrl(frame.Url)){
Ready?.Invoke(this, new PluginDispatchEventArgs(executor));
}
}