fix(controller): isMainContentDark too aggressive
This commit is contained in:
@@ -138,15 +138,18 @@ function isTextColorLight() {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
function isMainContentDark() {
|
function isMainContentDark() {
|
||||||
|
const { innerWidth: vw, innerHeight: vh } = window
|
||||||
|
const minArea = vw * vh * 0.5
|
||||||
|
|
||||||
const selectors = ['main', '#app', '#root', '#__next', '[role="main"]']
|
const selectors = ['main', '#app', '#root', '#__next', '[role="main"]']
|
||||||
for (const selector of selectors) {
|
for (const selector of selectors) {
|
||||||
const el = document.querySelector(selector)
|
const el = document.querySelector(selector)
|
||||||
if (!el) continue
|
if (!el) continue
|
||||||
|
|
||||||
const style = window.getComputedStyle(el)
|
const rect = el.getBoundingClientRect()
|
||||||
if (isColorDark(style.backgroundColor)) {
|
if (rect.width * rect.height < minArea) continue
|
||||||
return true
|
|
||||||
}
|
if (isColorDark(window.getComputedStyle(el).backgroundColor)) return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user