diff --git a/Browser/FormBrowser.Designer.cs b/Browser/FormBrowser.Designer.cs index c98f32b9..5b0ef769 100644 --- a/Browser/FormBrowser.Designer.cs +++ b/Browser/FormBrowser.Designer.cs @@ -27,7 +27,7 @@ private void InitializeComponent() { // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = TweetDuck.Browser.TweetDeckBrowser.BackgroundColor; + this.BackColor = TweetLib.Core.Features.TweetDeck.TweetDeckBrowser.BackgroundColor; this.ClientSize = new System.Drawing.Size(1008, 730); this.Icon = Properties.Resources.icon; this.Location = TweetDuck.Controls.ControlExtensions.InvisibleLocation; diff --git a/Browser/Handling/CustomLifeSpanHandler.cs b/Browser/Handling/CustomLifeSpanHandler.cs index a8b8fb96..2b65410c 100644 --- a/Browser/Handling/CustomLifeSpanHandler.cs +++ b/Browser/Handling/CustomLifeSpanHandler.cs @@ -1,21 +1,15 @@ using CefSharp; using CefSharp.Handler; using TweetLib.Core; -using TweetLib.Utils.Static; +using TweetLib.Core.Features.Twitter; namespace TweetDuck.Browser.Handling { sealed class CustomLifeSpanHandler : LifeSpanHandler { - private static bool IsPopupAllowed(string url) { - return url.StartsWithOrdinal("https://twitter.com/teams/authorize?") || - url.StartsWithOrdinal("https://accounts.google.com/") || - url.StartsWithOrdinal("https://appleid.apple.com/"); - } - public static bool HandleLinkClick(WindowOpenDisposition targetDisposition, string targetUrl) { switch (targetDisposition) { case WindowOpenDisposition.NewBackgroundTab: case WindowOpenDisposition.NewForegroundTab: - case WindowOpenDisposition.NewPopup when !IsPopupAllowed(targetUrl): + case WindowOpenDisposition.NewPopup when !TwitterUrls.IsAllowedPopupUrl(targetUrl): case WindowOpenDisposition.NewWindow: App.SystemHandler.OpenBrowser(targetUrl); return true; diff --git a/Browser/TweetDeckBrowser.cs b/Browser/TweetDeckBrowser.cs index 300d8e2a..69b84ae4 100644 --- a/Browser/TweetDeckBrowser.cs +++ b/Browser/TweetDeckBrowser.cs @@ -17,8 +17,6 @@ namespace TweetDuck.Browser { sealed class TweetDeckBrowser : IDisposable { - public static readonly Color BackgroundColor = Color.FromArgb(28, 99, 153); - public bool Ready => browserComponent.Ready; public bool Enabled { @@ -54,7 +52,7 @@ public TweetDeckBrowser(FormBrowser owner, PluginManager pluginManager, ITweetDe }; // ReSharper disable once PossiblyImpureMethodCallOnReadonlyVariable - this.browser.BrowserSettings.BackgroundColor = (uint) BackgroundColor.ToArgb(); + this.browser.BrowserSettings.BackgroundColor = (uint) TweetDeckBrowserImpl.BackgroundColor.ToArgb(); var extraContext = new TweetDeckExtraContext(); var resourceHandlerRegistry = new CefResourceHandlerRegistry(); diff --git a/lib/TweetLib.Core/Features/TweetDeck/TweetDeckBrowser.cs b/lib/TweetLib.Core/Features/TweetDeck/TweetDeckBrowser.cs index 71c1c838..c8a2f447 100644 --- a/lib/TweetLib.Core/Features/TweetDeck/TweetDeckBrowser.cs +++ b/lib/TweetLib.Core/Features/TweetDeck/TweetDeckBrowser.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using TweetLib.Browser.Base; using TweetLib.Browser.Contexts; using TweetLib.Browser.Events; @@ -16,6 +17,8 @@ namespace TweetLib.Core.Features.TweetDeck { public sealed class TweetDeckBrowser : BaseBrowser<TweetDeckBrowser> { + public static readonly Color BackgroundColor = Color.FromArgb(28, 99, 153); + private const string NamespaceTweetDeck = "tweetdeck"; private const string BackgroundColorOverride = "setTimeout(function f(){let h=document.head;if(!h){setTimeout(f,5);return;}let e=document.createElement('style');e.innerHTML='body,body::before{background:#1c6399!important;margin:0}';h.appendChild(e);},1)"; diff --git a/lib/TweetLib.Core/Features/Twitter/TwitterUrls.cs b/lib/TweetLib.Core/Features/Twitter/TwitterUrls.cs index 35f3cee3..ef1e620c 100644 --- a/lib/TweetLib.Core/Features/Twitter/TwitterUrls.cs +++ b/lib/TweetLib.Core/Features/Twitter/TwitterUrls.cs @@ -22,6 +22,12 @@ public static bool IsTwitterLogin2Factor(string url) { return url.Contains("://twitter.com/account/login_verification") || url.Contains("://mobile.twitter.com/account/login_verification"); } + public static bool IsAllowedPopupUrl(string url) { + return url.StartsWithOrdinal("https://twitter.com/teams/authorize?") || + url.StartsWithOrdinal("https://accounts.google.com/") || + url.StartsWithOrdinal("https://appleid.apple.com/"); + } + public static string? GetFileNameFromUrl(string url) { return StringUtils.NullIfEmpty(Path.GetFileName(new Uri(url).AbsolutePath)); }