Make sure thread watcher icon is visible on sites with dark backgrounds.

This commit is contained in:
ccd0 2019-07-08 19:59:23 -07:00
parent e891f69bca
commit 667495e641
3 changed files with 12 additions and 2 deletions

View File

@ -33,7 +33,7 @@ IDColor =
]
# Weight color luminance values, assign a font color that should be readable.
rgb.push if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125
rgb.push if $.luma(rgb) > 125
'#000'
else
'#fff'

View File

@ -273,7 +273,7 @@ Main =
unless /^rgb\(/.test(bgColor)
s = window.getComputedStyle(d.body)
bgColor = "#{s.backgroundColor} #{s.backgroundImage} #{s.backgroundRepeat} #{s.backgroundPosition}"
Main.bgColorStyle.textContent = """
css = """
.dialog, .suboption-list > div:last-of-type, :root.catalog-hover-expand .catalog-container:hover > .post {
background: #{bgColor};
}
@ -281,6 +281,13 @@ Main =
background-color: rgba(#{rgb[...3].join(', ')}, #{0.5*(rgb[3] || 1)});
}
"""
if $.luma(rgb) < 100
css += """
.watch-thread-link {
background-image: url("data:image/svg+xml,<svg viewBox='0 0 26 26' preserveAspectRatio='true' xmlns='http://www.w3.org/2000/svg'><path fill='rgb(200,200,200)' d='M24.132,7.971c-2.203-2.205-5.916-2.098-8.25,0.235L15.5,8.588l-0.382-0.382c-2.334-2.333-6.047-2.44-8.25-0.235c-2.204,2.203-2.098,5.916,0.235,8.249l8.396,8.396l8.396-8.396C26.229,13.887,26.336,10.174,24.132,7.971z'/></svg>");
}
"""
Main.bgColorStyle.textContent = css
$.after $.id('fourchanx-css'), Main.bgColorStyle
$.onExists d.head, Site.selectors.styleSheet, (el) ->

View File

@ -460,6 +460,9 @@ $.minmax = (value, min, max) ->
$.hasAudio = (video) ->
video.mozHasAudio or !!video.webkitAudioDecodedByteCount
$.luma = (rgb) ->
rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114
$.engine = do ->
return 'edge' if /Edge\//.test navigator.userAgent
return 'blink' if /Chrome\//.test navigator.userAgent