I’m using Dark Reader extension but still I’m whiteflashed when loading pages.

  • Rimu
    link
    fedilink
    English
    72 days ago

    Are you using Firefox 144 or later? That’s when they added support for CSS view-transition which might reduce this (on websites that use view-transition).

  • jutty
    link
    5
    edit-2
    2 days ago

    Some websites are really cursed in how hard they make overriding their styles.

    Some things I usually do to handle these are using Stylus with Instant inject mode and some !important rules for a global dark theme.

    If that also fails, I have an anti-Flash-of-Unstyled-Content userscript ready to toggle per-website as needed:

    ;(function() {
    
      const css = `
        html, body {
          background: #222 !important;
          min-height: 100vh !important;
        }
    
        body > * {
          visibility: hidden !important;
        }
      `
    
      const style = document.createElement('style')
      style.id = 'antiFOUC-block'
      style.textContent = css
    
      const container = document.head || document.documentElement
      container.prepend(style)
    
      window.addEventListener('DOMContentLoaded', () => {
        const block = document.getElementById('antiFOUC-block')
        if (block) block.remove()
    
        document.body.childNodes.forEach(n => {
          if (n.nodeType === 1) {
            n.style.visibility = ''
          }
        })
      })
    })()
    

    It works by preventing display of content before it’s fully loaded. This won’t make websites dark on its own, just prevent the flash.

    (I have tested this with Violentmonkey on boardgamegeek.com plus a Stylus dark theme and it did solve it. With Dark Reader though it will still flash)

    If even that fails I have a second one that will strip all inline and !important styles, but it rarely ever comes to that.

    I hope this is helpful because being flashed with a fully white page makes me want to cry and punch my computer.

    • Victor
      link
      fedilink
      22 days ago

      By the way,

      const block = document.getElementById('antiFOUC-block')
      

      Is this necessary? Isn’t there a reference to this node already via the style identifier?

      • jutty
        link
        12 days ago

        I guess, but:

        1. my JS skills are horrific
        2. I have a habit of avoiding all outer and/or global state like the plague
        • Victor
          link
          fedilink
          12 days ago
          1. Fair enough 😁
          2. IMO it’s more of a closure than global state, since this is an isolated function/IIFE. 👍 But it’s up to you! 😊
    • Victor
      link
      fedilink
      22 days ago

      Wow, a Flash of Unstyled Content Killer. Nice.

  • @JubilantJaguar@lemmy.world
    link
    fedilink
    32 days ago

    Easy. Preferences > Contrast control > Manage colors and set the background color to black or whatever.

    You will never be whiteflashed again. Some websites will be ugly, a few will be unusable (you’ll have to unset it temporarily for them, or use a different profile). But many will be just as good as with Dark Reader.

    In any case, this is literally the only way to banish whiteflash definitively. It also has no speed penalty because it’s native.