Skip to content

Commit

Permalink
Update preload-theme.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rimonhanna committed May 18, 2021
1 parent 944c0ac commit 060f70c
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/main/preload-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,43 @@ const enableLight = () => {
// document contexts provided by preload.js.
const setOSTheme = async (toThemeStyle) => {
DarkReader.auto();
var setColors = function () {
var fixDarkMode = function () {
document.querySelectorAll("iframe").forEach(frame => {
frame.contentWindow.document.querySelectorAll('.t5F5nf').forEach(span => {
frame.contentWindow.document.querySelectorAll('span[role="presentation"]').forEach(span => {
span.setAttribute('style', 'color:#acacac !important');
});
// if (frame.title == "Chat content") {
// frame.contentWindow.addEventListener("DOMContentLoaded", () => {
// frame.contentWindow.document.querySelectorAll(".Bl2pUd, .McQwEc, .nF6pT, .oGsu4").forEach(item => {
// item.setAttribute('style', 'background-color:#181A1B !important');
// });
// frame.contentWindow.document.querySelectorAll(".Zc1Emd, .njhDLd ").forEach(item => {
// item.setAttribute('style', 'color:#acacac !important');
// });
// });


// // frame.contentWindow.document.querySelectorAll(".oGsu4").forEach(item => {
// // item.setAttribute('style', 'background-color:#181A1B !important');
// // });
// // frame.contentWindow.document.querySelectorAll(".cZICLc").forEach(item => {
// // item.setAttribute('style', 'background-color:#202223 !important');
// // });
// }

});
}
if (nativeTheme.shouldUseDarkColors) {
setColors();
fixDarkMode();
window.addEventListener("load", () => {
setColors();
fixDarkMode();
});
window.addEventListener("DOMSubtreeModified", () => {
fixDarkMode();
});
} else {
document.querySelectorAll("iframe").forEach(frame => {
frame.contentWindow.document.querySelectorAll('.t5F5nf').forEach(span => {
frame.contentWindow.document.querySelectorAll('span[role="presentation"]').forEach(span => {
span.removeAttribute('style');
});
});
Expand Down

0 comments on commit 060f70c

Please sign in to comment.