0

Possible Duplicate:
My CSS is not getting injected through my content script

I've been trying to make a Chrome Extension to change the background color of google to black every time it's loaded in a tab.

I have the following in my manifest.json:

{
  "name": "Background to black",
  "manifest_version": 2,
  "version": "1.0",
  "description": "Google black",
  "permissions": ["tabs", "http://www.google.com/*"],
  "browser_action": {
    "default_icon": "icon.png"
  },
  "content_scripts": [
    {
      "matches": ["http://www.google.com/*"],
      "css": ["backgroundtoblack.css"],
      "run_at": "document_start",
      "all_frames": true
    }
  ]
}

and this in my backgroundtoblack.css:

body{
background: #000000;
}

However it doesn't work for me and I don't understand what I'm doing wrong.

Community
  • 1
  • 1
r.h
  • 27
  • 2
  • 5
  • Just a side-note: there are already extensions that do that and more (like [this one](https://chrome.google.com/webstore/detail/fjnbnpbmkenffdnngjfgmeleoegfcffe)). – Chris Sep 15 '12 at 14:16
  • 1
    Well I'm interested in learning how to do it myself. But thanks for the link anyway. – r.h Sep 15 '12 at 15:31
  • "background color of google" — did you mean [google.com](http://google.com) page? – Pavlo Sep 15 '12 at 15:51
  • This **might** be about the fact that Chrome might utilize HTTPS by default, so your rule `"http://www.google.com/*"` won't match it. Can you check that? – Chris Sep 15 '12 at 15:58

1 Answers1

0

This isn't about the manifest file, it's about your CSS file. Replacing your CSS with this,

html, body {
    background: #000000 !important;
}

The extension should work now. (Works when testing locally).

Note: I had to change your matches a bit, because I use HTTPS Everywhere. You might have to change it if Chrome is loading using HTTPS by default.

Chris
  • 26,544
  • 5
  • 58
  • 71
  • Changing the css alone made it work, thanks. Is it the !important that makes the difference or the html, body; or is it a combination of both? – r.h Sep 15 '12 at 16:23