0

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

manifest.json

{
    "name": "TESTE",
    "version": "0.0.0.1",
    "manifest_version": 2,
    "description": "Description",
    "content_scripts": [
        {       
            "matches": ["http://*/*wss"],// <<---------
            "css": ["style.css"],
            "js":["alert.js"]
        }       
    ],
    "permissions": ["tabs", "<all_urls>","http://*/*"]
}

The js file is working perfectly, but the css just load if i put generic match like

"matches":["http://*/*"]

Why?

Community
  • 1
  • 1
Willian Lopes
  • 173
  • 1
  • 4
  • WHat site do you want to match? – Rob W Oct 02 '12 at 20:42
  • Anyone with suffix "wss"... like "http://www.anyone.com/service.wss" – Willian Lopes Oct 02 '12 at 21:26
  • @But is there anything else after i? A query string/URL fragment. Eg ...service.wss?foo=bar – Rob W Oct 02 '12 at 21:36
  • No, in real the page is exactly like this one "www.anyone.com/service?wss"... Always I have the suffix "wss" or "?wss"... But, the real point is... why this match(["http://*/*wss"]) work to js files but not for css files?? – Willian Lopes Oct 03 '12 at 04:30
  • Thanks Rob W for clarification and I think you are right, this questions is same question but when I searched I not found. Sorry! – Willian Lopes Oct 03 '12 at 14:24

1 Answers1

1

This is a known bug that exists for over an year now.

Temporary solution for this is to inject CSS from content script javascript:

var link=document.createElement("link");
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
link.setAttribute("href", chrome.extension.getURL("main.css"));

document.getElementsByTagName("head")[0].appendChild(link);
Konrad Dzwinel
  • 36,825
  • 12
  • 98
  • 105