diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index d134e538..688f11c9 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -79,6 +79,7 @@ public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings) #endif this.browser.LoadingStateChanged += browser_LoadingStateChanged; + this.browser.FrameLoadStart += browser_FrameLoadStart; this.browser.FrameLoadEnd += browser_FrameLoadEnd; this.browser.LoadError += browser_LoadError; this.browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge(this, notification)); @@ -161,6 +162,12 @@ private void browser_LoadingStateChanged(object sender, LoadingStateChangedEvent } } + private void browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e){ + if (e.Frame.IsMain && BrowserUtils.IsTwitterWebsite(e.Frame)){ + ScriptLoader.ExecuteFile(e.Frame, "twitter.js"); + } + } + private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){ if (e.Frame.IsMain && BrowserUtils.IsTweetDeckWebsite(e.Frame)){ e.Frame.ExecuteJavaScriptAsync(BrowserUtils.BackgroundColorFix); diff --git a/Core/Utils/BrowserUtils.cs b/Core/Utils/BrowserUtils.cs index 4227f2d8..09f9a2d9 100644 --- a/Core/Utils/BrowserUtils.cs +++ b/Core/Utils/BrowserUtils.cs @@ -92,6 +92,10 @@ public static bool IsTweetDeckWebsite(IFrame frame){ return frame.Url.Contains("//tweetdeck.twitter.com/"); } + public static bool IsTwitterWebsite(IFrame frame){ + return frame.Url.Contains("//twitter.com/"); + } + #if DEBUG public static void HandleConsoleMessage(object sender, ConsoleMessageEventArgs e){ Debug.WriteLine("[Console] {0} ({1}:{2})", e.Message, e.Source, e.Line); diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 1a15ad50..a0cfabbb 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -684,4 +684,8 @@ window.TD_PLUGINS.onReady(); } }); + + $(document).on("uiLoginFormImpression", function(){ + location.href = $("a.btn", ".js-login-form").first().attr("href"); + }); })($, $TD, $TDX, TD); diff --git a/Resources/Scripts/twitter.js b/Resources/Scripts/twitter.js new file mode 100644 index 00000000..aee88bcc --- /dev/null +++ b/Resources/Scripts/twitter.js @@ -0,0 +1,25 @@ +// +// Block: Inject custom CSS and layout into the page. +// +setTimeout(function(){ + var style = document.createElement("style"); + document.head.appendChild(style); + + style.sheet.insertRule("body { overflow: hidden !important; }", 0); // remove scrollbar + style.sheet.insertRule(".topbar { display: none !important; }", 0); // hide top bar + style.sheet.insertRule(".page-canvas, .buttons, .btn, input { border-radius: 0 !important; }", 0); // sharpen borders + style.sheet.insertRule("input { padding: 5px 8px 4px !important; }", 0); // tweak input padding + + style.sheet.insertRule("#doc { width: 100%; height: 100%; margin: 0; position: absolute; display: table; }", 0); // center everything + style.sheet.insertRule("#page-outer { display: table-cell; vertical-align: middle; }", 0); // center everything + style.sheet.insertRule("#page-container { padding: 0 20px !important; width: 100% !important; box-sizing: border-box !important; }", 0); // center everything + style.sheet.insertRule(".page-canvas { margin: 0 auto !important; }", 0); // center everything + + if (location.pathname === "/logout"){ + style.sheet.insertRule(".page-canvas { width: auto !important; max-width: 888px; }", 0); // fix min width + style.sheet.insertRule(".signout-wrapper { width: auto !important; }", 0); // fix min width + style.sheet.insertRule(".btn { margin: 0 4px !important; }", 0); // add margin around buttons + style.sheet.insertRule(".btn.cancel { border: 1px solid #bbc1c5 !important; }", 0); // add border to cancel button + style.sheet.insertRule(".aside p { display: none; }", 0); // hide text below the logout dialog + } +}, 1); diff --git a/TweetDck.csproj b/TweetDck.csproj index daa5ac91..853651fc 100644 --- a/TweetDck.csproj +++ b/TweetDck.csproj @@ -339,6 +339,7 @@ <Content Include="Resources\Scripts\plugins.browser.js" /> <Content Include="Resources\Scripts\plugins.js" /> <Content Include="Resources\Scripts\plugins.notification.js" /> + <Content Include="Resources\Scripts\twitter.js" /> <Content Include="Resources\Scripts\update.js" /> </ItemGroup> <ItemGroup>