5

I would like to apply custom CSS to pages in Chrome, but before the extensions are loaded.

I'm already familiar with this solution: Applying custom style to internal Chrome pages

But I need to apply the styles while the page is still being loaded, before extensions kick in. Chrome's Custom.css used to work for that, but now it was removed. I'm looking for a hack to do this.

(The reason I want this so much is that my custom styles invert the page, showing white-on-black rather than black-on-white, but every time there's a page load it blasts my eyes with a screen full of white until the extension kicks in. I want to prevent this and maintain my eyesight.)

Bonus points if you can show me how to style the new tab page, and pages loaded from the computer itself (like local HTML files), so I could invert those as well.

Ram Rachum
  • 4,450

2 Answers2

3

Temporary workaround

A short-term workaround could be to downgrade Chrome to an earlier version. Be aware that:

  • Google only supports the most current stable channel release.
  • Chrome will try to update itself automatically, and you need to prevent that.
  • You will miss any security updates, bug fixes, or new features.

In the long run, you will be stuck with an old, outdated browser. The single feature you're missing might have been brought back in the meanwhile, or not. As a backup plan, playing with a different browser is worth the effort, even if you don't plan to switch right away.

File information

Considering Google won't endorse old Chrome versions, you have to rely on third parties who can provide a standalone, offline installer. Any web installer would automatically retrieve the most updated version, thus making it totally useless.

The latest stable version released in the 31.x branch is 31.0.1650.63. Here are the basic details and hashes of the official installer:

File:    31.0.1650.63_chrome_installer.exe
Size:    33.7 MiB (35337056 bytes)
Version: 31.0.1650.63
---
CRC32:   14b5a4cf
MD5:     8d8e67e5a438e9906cc90c5ed4aa1ad7
SHA1:    a022ceeb5523145efbcf50c30426b8f2cec33716
SHA256:  2aaee6f9da598b483833e541ed8cc1671e3f034624834ad9c5ed1decedafa5a4

Additionally, the file is digitally signed by Google Inc, and countersigned by Symantec Time Stamping Services Signer - G4. Both signatures must be valid. You can check them by opening the file properties dialog.

For newer or older Chrome versions, here's a reliable (albeit unofficial) page containing the details about each installer: Chrome Installer Information.

Download links

You can use any of the link below, or find an alternate source yourself. While the actual file name could be different, the other details provided above must match exactly.

Make sure to scan the files using your antivirus, and upload a copy to VirusTotal to feel confident enough. If possible, test the program in a safe environment first. When you're done, make a backup of the setup executable.

Prevent updates

  1. Make sure all Chrome-related processes are completely closed, then open an elevated command prompt. Type or paste the following commands to disable the auto-update features via the registry:

    reg add "HKLM\SOFTWARE\Policies\Google\Update" /v "UpdateDefault" /t REG_DWORD /d 0 /f
    reg add "HKLM\SOFTWARE\Policies\Google\Update" /v "AutoUpdateCheckPeriodMinutes" /t REG_DWORD /d 0 /f
    reg add "HKLM\SOFTWARE\Policies\Google\Update" /v "DisableAutoUpdateChecksCheckboxValue" /t REG_DWORD /d 1 /f
    reg add "HKLM\SOFTWARE\Policies\Google\Update" /v "Update{8A69D345-D564-463C-AFF1-A69D9E530F96}" /t REG_DWORD /d 0 /f
    
  2. Disable (but not delete) all Google Update scheduled tasks and services:

    for /r "%windir%\System32\Tasks" %A in ("GoogleUpdate*") do @schtasks /change /tn "%~nA" /disable
    for /f "delims=" %A in ('"reg query "HKLM\SYSTEM\CurrentControlSet\Services" | findstr /i /c:"gupdate" "') do @sc stop "%~nA" & @sc config "%~nA" start= disabled
    

    As pointed out by @Synetech, you should avoid deleting the Google Update tasks "because Chrome will simply re-create them the next time you run it; it will not re-enable them if they already exist but are disabled." I wouldn't recommend deleting them anyway, should you want to enable them in the future.

  3. Prevent the GoogleUpdate.exe application from running:

    reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\GoogleUpdate.exe" /v "Debugger" /t REG_SZ /d "systray.exe" /f
    

    If you're interested in how that works exactly, check this question: How to block programs from running (Windows 7).

  4. Type chrome:plugins in the Chrome address bar, and disable the Google Update plug-in.

Reverting back

In case you want to enable updates again, follow the steps below.

  1. Make sure all Chrome-related processes are completely closed, then open a command prompt as administrator. Type or paste the following commands:

    reg delete "HKLM\SOFTWARE\Policies\Google\Update" /f
    reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\GoogleUpdate.exe" /f
    for /r "%windir%\System32\Tasks" %A in ("GoogleUpdate*") do @schtasks /change /tn "%~nA" /enable
    for /f "delims=" %A in ('"reg query "HKLM\SYSTEM\CurrentControlSet\Services" | findstr /i /c:"gupdate" "') do @sc config "%~nA" start= demand
    
  2. Type chrome:plugins in the Chrome address bar, and enable the Google Update plug-in.

and31415
  • 14,901
0

This is a known bug :
Issue 1373: Navigating dark background websites results in blinding white flashes between pages,
is a very very long thread starting on Sep 4, 2008 !

The bug was "fixed" several times, but the fixes were either not effective or had to be pulled because they caused other problems or inefficiencies. Numerous other bug issues were merged into this one bug, many users have declared abandoning Chrome because of it, but the bug is not closed yet.

The analysis of the bug seems to be that if the displayed page does not start with an <body> HTML tag that contains a background color, and if rendering the page takes more than a few hundreds of a second, the page will be displayed with a white background. This can happen, for example, if the source website is too slow or the page is very large or is written inefficiently (for example with large images that take a long time to download).

The last two messages in the issue say :

On May 23, 2013 :

OK, looks like that stuck. This should be solved in a canary soon, and in the 29 release. If you still see it happening, file new bugs.

And on Jun 5, 2013 :

Issue 247003 has been merged into this issue.

The bug seems to have been forgotten since then - no new entries.

So it seems that in spite of the optimistic before-last message, the bug is still alive and kicking. After so many people have searched in vain for a solution or a workaround, I believe that the only solution is for the bug to be fixed in Chrome.

The only advice I can give is to keep on pushing on the Chrome developers to fix the bug. But after more than five years, it seems that for some reason its solution is very difficult to achieve.

harrymc
  • 498,455