15

I installed theme for Developers Tools and want also make my 'view-source' is dark too.

Vitaly Zdanevich
  • 8,667
  • 5
  • 38
  • 64

3 Answers3

25

Create bookmark with code below:

javascript:(function(){ var h=document.getElementsByTagName('head')[0],s=document.createElement('style');s.setAttribute('type','text/css'); s.appendChild(document.createTextNode('html{-webkit-filter:invert(100%) hue-rotate(180deg) contrast(70%) !important; background: #fff;} .line-content {background-color: #fefefe;}'));h.appendChild(s); })()

And click on this bookmark on any page you want to be dark

Andrey Izman
  • 1,477
  • 1
  • 21
  • 24
  • This is the _only_ thing that worked! Even the _userstyles.org_ was deceitful/misleading. It said "install this with Stylish!" then didn't even install it with the only button that was there. Then, when you go back, it says: "This can't be used on Chrome!" Are you serious? A web-developer-type site that can't even check what browser you're using? – Mark C Jun 05 '18 at 06:19
  • @Gauthier your code will not work on every page, my code will work on every website across the internet, not only view-source page – Andrey Izman Nov 30 '18 at 00:54
  • Lol, you are correct. I was only after view-source . Yours is way better in that respected – Gauthier Nov 30 '18 at 01:01
  • Total epic fail on my part. I prolly would have found that in the next few weeks. I was using it to print_r($var) in php. Im just going to delete out my comment, until i work though my epic fail. Thanks for pointing that out. – Gauthier Nov 30 '18 at 01:09
  • Very useful, thanks! Now I just wish javascript injection from tampermonkey would work with this. – AlienDrew Jan 01 '20 at 11:31
  • You are a magician! – Mojtaba Dec 05 '20 at 16:09
3

The only real way to do this is I found is the #enable-force-dark experimental flag. The downside is that it sets a dark theme on every single page you browser like Dark Reader or Deluminate.

  1. Enable the #enable-force-dark experimental flag at chrome://flags/#enable-force-dark. Screenshot
  2. Done. Now the view-source pages are automatically dark.
0

There're some syntax highlighter extensions available for chrome. Such as: Sight and Syntaxtic!.

But to be honest the result isn't always as expected because those apps relying on the url having an extension (.js, .php and so on) to load the proper highlighter. This days most websites are using url rewriting so there is not extension at all so the apps doesen't load the highlighter. Maybe this could be tweaked in the app manifests but I haven't touched this yet.

Hexodus
  • 9,856
  • 5
  • 42
  • 61
  • Yes, I also use this nice theme, but I need to see dark background of `view-source:http://stackoverflow.com/questions/25546055/can-i-set-up-theme-for-view-source-in-chrome/35996658` – Vitaly Zdanevich Mar 15 '16 at 08:52
  • @VitalyZdanevich Sorry my mistake. I just modified my answer to adapt it to your true needs. – Hexodus Mar 30 '16 at 14:20