From 3150c95536d66ac2a208c725899248a42666fb40 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 1 Apr 2016 10:19:32 -0700 Subject: [PATCH] Determine proper background color for dialogs if 4chan is using a special stylesheet. --- src/General/Main.coffee | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index fe171ac48..a1076ad7c 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -185,6 +185,7 @@ Main = $.addClass doc, $.engine if $.engine $.onExists doc, '.ad-cnt', (ad) -> $.onExists ad, 'img', -> $.addClass doc, 'ads-loaded' $.addStyle Main.css, 'fourchanx-css' + Main.bgColorStyle = $.el 'style', id: 'fourchanx-bgcolor-css' keyboard = false $.on d, 'mousedown', -> keyboard = false @@ -210,6 +211,21 @@ Main = break if style $.addClass doc, style + $.rm Main.bgColorStyle + else + # Determine proper background color for dialogs if 4chan is using a special stylesheet. + div = $.el 'div', + className: 'reply' + style: 'position: absolute; visibility: hidden;' + $.add d.body, div + bgColor = window.getComputedStyle(div).backgroundColor + $.rm div + Main.bgColorStyle.textContent = """ + .dialog, .suboption-list > div:last-of-type { + background-color: #{bgColor}; + } + """ + $.after $.id('fourchanx-css'), Main.bgColorStyle setStyle() return unless mainStyleSheet new MutationObserver(setStyle).observe mainStyleSheet,