mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-30 23:34:09 +02:00
Rewrite login/logout page CSS handling to fix broken 2FA styles
Closes #218
This commit is contained in:
parent
a9c140c0fc
commit
442126a11a
Core
Resources/Scripts
@ -20,6 +20,7 @@ sealed class TweetDeckBrowser : IDisposable{
|
|||||||
private static UserConfig Config => Program.Config.User;
|
private static UserConfig Config => Program.Config.User;
|
||||||
|
|
||||||
private const string ErrorUrl = "http://td/error";
|
private const string ErrorUrl = "http://td/error";
|
||||||
|
private const string TwitterStyleUrl = "https://abs.twimg.com/tduck/css";
|
||||||
|
|
||||||
public bool Ready { get; private set; }
|
public bool Ready { get; private set; }
|
||||||
|
|
||||||
@ -121,10 +122,15 @@ private void browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e){
|
|||||||
|
|
||||||
if (frame.IsMain){
|
if (frame.IsMain){
|
||||||
if (TwitterUtils.IsTwitterWebsite(frame)){
|
if (TwitterUtils.IsTwitterWebsite(frame)){
|
||||||
|
string css = ScriptLoader.LoadResource("styles/twitter.css", browser);
|
||||||
|
resourceHandlerFactory.RegisterHandler(TwitterStyleUrl, ResourceHandler.FromString(css, mimeType: "text/css"));
|
||||||
|
|
||||||
ScriptLoader.ExecuteFile(frame, "twitter.js", browser);
|
ScriptLoader.ExecuteFile(frame, "twitter.js", browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.ExecuteJavaScriptAsync(TwitterUtils.BackgroundColorOverride);
|
if (!TwitterUtils.IsTwitterLogin2FactorWebsite(frame)){
|
||||||
|
frame.ExecuteJavaScriptAsync(TwitterUtils.BackgroundColorOverride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,10 @@ public static bool IsTwitterWebsite(IFrame frame){
|
|||||||
return frame.Url.Contains("//twitter.com/");
|
return frame.Url.Contains("//twitter.com/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsTwitterLogin2FactorWebsite(IFrame frame){
|
||||||
|
return frame.Url.Contains("//twitter.com/account/login_verification");
|
||||||
|
}
|
||||||
|
|
||||||
private static string ExtractMediaBaseLink(string url){
|
private static string ExtractMediaBaseLink(string url){
|
||||||
int slash = url.LastIndexOf('/');
|
int slash = url.LastIndexOf('/');
|
||||||
return slash == -1 ? url : StringUtils.ExtractBefore(url, ':', slash);
|
return slash == -1 ? url : StringUtils.ExtractBefore(url, ':', slash);
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*****************************/
|
|
||||||
/* Fix min width and margins */
|
|
||||||
/*****************************/
|
|
||||||
|
|
||||||
.page-canvas {
|
|
||||||
width: auto !important;
|
|
||||||
max-width: 888px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.signout-wrapper {
|
|
||||||
width: auto !important;
|
|
||||||
margin: 0 auto !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.signout {
|
|
||||||
margin: 60px 0 54px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.buttons {
|
|
||||||
padding-bottom: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************/
|
|
||||||
/* General styling */
|
|
||||||
/*******************/
|
|
||||||
|
|
||||||
.aside {
|
|
||||||
/* hide elements around dialog */
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.buttons button, .buttons a {
|
|
||||||
/* style buttons */
|
|
||||||
display: inline-block;
|
|
||||||
margin: 0 4px !important;
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.3) !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
/*********************/
|
/*********************/
|
||||||
/* Center everything */
|
/* Center everything */
|
||||||
/*********************/
|
/*********************/
|
||||||
|
|
||||||
#doc {
|
#doc {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -25,6 +25,17 @@
|
|||||||
margin: 0 auto !important;
|
margin: 0 auto !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ResponsiveLayout {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Section {
|
||||||
|
padding: 36px !important;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************/
|
/*******************/
|
||||||
/* General styling */
|
/* General styling */
|
||||||
/*******************/
|
/*******************/
|
||||||
@ -39,7 +50,7 @@ body {
|
|||||||
box-shadow: 0 0 150px rgba(255, 255, 255, 0.3) !important;
|
box-shadow: 0 0 150px rgba(255, 255, 255, 0.3) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.topbar {
|
.topbar, .TopNav {
|
||||||
/* hide top bar */
|
/* hide top bar */
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
@ -65,3 +76,42 @@ button[type='submit'] {
|
|||||||
margin-top: 15px !important;
|
margin-top: 15px !important;
|
||||||
font-weight: bold !important;
|
font-weight: bold !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************************/
|
||||||
|
/* Fix min width and margins on logout page */
|
||||||
|
/********************************************/
|
||||||
|
|
||||||
|
html[logout] .page-canvas {
|
||||||
|
width: auto !important;
|
||||||
|
max-width: 888px;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[logout] .signout-wrapper {
|
||||||
|
width: auto !important;
|
||||||
|
margin: 0 auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[logout] .signout {
|
||||||
|
margin: 60px 0 54px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[logout] .buttons {
|
||||||
|
padding-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************/
|
||||||
|
/* General logout page styling */
|
||||||
|
/*******************************/
|
||||||
|
|
||||||
|
html[logout] .aside {
|
||||||
|
/* hide elements around dialog */
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[logout] .buttons button, html[logout] .buttons a {
|
||||||
|
/* style buttons */
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 4px !important;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.3) !important;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
}
|
@ -8,15 +8,15 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let style = document.createElement("style");
|
let link = document.createElement("link");
|
||||||
|
link.rel = "stylesheet";
|
||||||
|
link.href = "https://abs.twimg.com/tduck/css";
|
||||||
|
|
||||||
style.innerText = `#import "styles/twitter.base.css"`;
|
document.head.appendChild(link);
|
||||||
|
|
||||||
if (location.pathname === "/logout"){
|
if (location.pathname === "/logout"){
|
||||||
style.innerText += `#import "styles/twitter.logout.css"`;
|
document.documentElement.setAttribute("logout", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
document.head.appendChild(style);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
setTimeout(injectCSS, 1);
|
setTimeout(injectCSS, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user