Made SquaresDark theme really dark.

Due to that, e-mails with incorrect background/color settings are unreadable.
So a new feature in the settings is there to remove colors from messages.
Not perfect yet, but it works.
This commit is contained in:
djmaze 2021-02-24 00:17:53 +01:00
parent fac36e828b
commit 2982027dd2
22 changed files with 164 additions and 63 deletions

View file

@ -47,7 +47,24 @@ const
findEmailAndLinks = html => html
.replace(url, '$1<a href="$2" target="_blank">$2</a>')
.replace(email, '$1<a href="mailto:$2">$2</a>'),
isChecked = item => item.checked();
isChecked = item => item.checked(),
// Removes background and color
// Many e-mails incorrectly only define one, not both
// And in dark theme mode this kills the readability
removeColors = html => {
let l;
do {
l = html.length;
html = html
.replace(/(<[^>]+);?background(-color)?\s*:[^;"']+/gi, '$1')
.replace(/(<[^>]+[^-]);?color\s*:[^;"']+/gi, '$1')
.replace(/(<[^>]+[^-])\sbgcolor="[^"]+"/gi, '$1')
.replace(/(<[^>]+[^-])\scolor="[^"]+"/gi, '$1');
//.replace(/<\/?font[^>]+>/gmi, '')
} while (l != html.length)
return html;
};
doc.body.append(hcont);
@ -499,12 +516,13 @@ class MessageUserStore {
message.fetchDataFromDom();
messagesDom.append(textBody);
} else {
let isHtml = false;
if (json.Html) {
isHtml = true;
let isHtml = !!json.Html;
if (isHtml) {
resultHtml = json.Html.toString();
if (SettingsStore.removeColors()) {
resultHtml = removeColors(resultHtml);
}
} else if (json.Plain) {
isHtml = false;
resultHtml = plainToHtml(json.Plain.toString());
if ((message.isPgpSigned() || message.isPgpEncrypted()) && PgpStore.capaOpenPGP()) {
@ -534,7 +552,6 @@ class MessageUserStore {
resultHtml = '<pre>' + resultHtml + '</pre>';
}
} else {
isHtml = false;
resultHtml = '<pre>' + resultHtml + '</pre>';
}
@ -552,7 +569,7 @@ class MessageUserStore {
message.body = body;
message.isHtml(!!isHtml);
message.isHtml(isHtml);
message.hasImages(!!json.HasExternals);
messagesDom.append(body);

View file

@ -27,6 +27,7 @@ class SettingsUserStore {
ko.addObservablesTo(this, {
showImages: false,
removeColors: false,
useCheckboxesInList: true,
allowDraftAutosave: true,
useThreads: false,
@ -58,6 +59,7 @@ class SettingsUserStore {
this.messagesPerPage(settingsGet('MPP'));
this.showImages(!!settingsGet('ShowImages'));
this.removeColors(!!settingsGet('RemoveColors'));
this.useCheckboxesInList(!!(ThemeStore.isMobile() || settingsGet('UseCheckboxesInList')));
this.allowDraftAutosave(!!settingsGet('AllowDraftAutosave'));
this.useThreads(!!settingsGet('UseThreads'));