44

I'm looking for different Chrome apps to make my pages darker/inverted to reduce eye strain, I found some apps that work but the only thing left, which these apps doesn't seem to override, is the White Blank page.

When a new page is loaded, Chrome first displays a White Blank page, while the page is loading then displays the website's content. Is there a way to override this While page to say Black? At the moment, everytime I click on a link or open a new webpage, the screen goes from darkcoloured (through inverted/darkening page apps) to the White Blank screen for a brief second then the new page loads in a dark colour again. This acts like a "White Flash" by the screen everytime a new page is loaded and causes further eye strain. This is why I want to know if there is a way to override this White colour to Black.

Ps. If this post is in the wrong forum, I apologise, Google Chrome Developers page had a link to Forums which brought me here :)

Thanks.

Bill Agee
  • 3,606
  • 20
  • 17
KickAss
  • 4,210
  • 8
  • 33
  • 41

1 Answers1

27

manifest.json

{
    "name": "Background",
    "permissions" : ["http://*/*", "https://*/*"],
    "version": "1.0",
    "content_scripts": [{
        "matches": ["http://*/*", "https://*/*"],
        "js": ["script.js"],
        "all_frames": false,
        "run_at": "document_start"
    }],
    "manifest_version": 2
}

script.js

var color = document.documentElement.style.backgroundColor;
document.documentElement.style.backgroundColor = "black";
var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
        if (mutation.target.nodeName == "BODY") {
            observer.disconnect();
            document.documentElement.style.backgroundColor = color || "";
        }
    });
});
observer.observe(document, { childList: true, subtree: true });

Put all of the files in a folder. In chrome, go to Settings -> Extensions -> turn on Developer Mode -> Load unpacked extension -> Choose the folder you just created.

Red John
  • 582
  • 6
  • 17
  • I have edited the code to ensure it will revert back to original color (if there was any). There might be flickering in webpages until it fully loads, but that's the best I came up with. – Red John Apr 26 '13 at 23:29
  • 3
    It works partially for me. At the first milliseconds, Chrome starts in white background color and then it changes to black background color. It could be because I tested it in a PC with 1GB of RAM. – Julian Moreno Mar 05 '14 at 14:13
  • 19
    The solution didn't work today in 2015, i can see white screens between every page, they may last less long i dont know. – bandybabboon Apr 05 '15 at 07:51
  • 4
    I ended up using FF as browser, problem is gone. I love Google Chrome, but these white flashes makes me crazy – tigrou Oct 20 '15 at 17:10
  • 9
    this does not work in newer version of Chrome. – Jay Blanchard Mar 16 '16 at 13:08
  • Still does not work in November 2016, @RedJohn it would be sweet if you could update your answer (: – Jezor Nov 20 '16 at 01:26
  • 2
    @Jezor I realize this answer is outdated, but I haven't touched the chrome api since then. I'll try to take a look soon as time allows. – Red John Nov 23 '16 at 13:47
  • another hack forking chromium and overwriting the background color https://github.com/hbtlabs/chromium-white-flash-fix – hbt Dec 29 '16 at 18:55
  • There's some useful things here: https://forum.userstyles.org/discussion/54781/need-help-to-disable-white-flash-on-chrome Easiest one is the chrome extension to not autofocus new tabs, a bit clunky if you use a lot of tabs, but a no brainer to install and it works though there is a millisecond or two flicker, but no painful flash! – lacostenycoder Oct 15 '17 at 08:34