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.

1 Answer 1

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.

9
  • 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. Commented Mar 5, 2014 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. Commented Apr 5, 2015 at 7:51
  • 4
    I ended up using FF as browser, problem is gone. I love Google Chrome, but these white flashes makes me crazy
    – tigrou
    Commented Oct 20, 2015 at 17:10
  • 9
    this does not work in newer version of Chrome. Commented Mar 16, 2016 at 13:08
  • 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
    Commented Nov 23, 2016 at 13:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.