views:

56

answers:

2

I have a chrome extension that very simply injects CSS before a page loads. (I know this could be done by javascript once the page has loaded, but this causes the page to flash as it changes/renders the new CSS.)

The CSS is injected as a content script using code like:

  "css": ["mystyles.css"],
  "run_at": "document_start",

I would like to be able to remove all the CSS if the page action is clicked, but this doesn't seem to be possible. Could I make a page action extension that disables the extension that injects the CSS?

Thanks for your help!

A: 

You can't disable one extension from another one. This would be a major security risk. Imagine a malicious extension that disables the Norton SafeWeb or McAfee SiteAdvisor toolbar (if they existed for Chrome, of course).

It would be much easier to just remove style and link tags (that reference CSS). However, there is no efficient way to strip inline styles (i.e. <a style='font-size: 12px;'></a>).

SimpleCoder
only under the experimental API
Mohamed Mansour
For what reason could Google possibly have added this feature for?
SimpleCoder
For allowing Extension Management extensions. For example, controlling when an extension gets updated, deleted, change of permissions, extension activity. Lots of stuff. The extension team is trying to expose everything in Chrome externally for extensions safely, and securely.
Mohamed Mansour
I understand that, but why should extensions be able to uninstall or disable each other? Couldn't that be used maliciously?
SimpleCoder
An extension is a just a "program" within the browser. If you install a malicious program in your computer, you will be affected. Safe thing with an extension. You can create a very simple content script that reads your bank account number when inputed in the website and send that to a third party. It is up to the user to be careful which one to download. Google Chrome helps use that judgement by helping the user pick the right decision by annoying infobars, confirmations, limitations, etc. For example, a good extension to have, and I might do it, is to disable all extensions.
Mohamed Mansour
@Mohamed Mansour- My problem there is that most users (outside of here, of course) are not tech-savvy enough to actually read these notifications. I think this "feature" is just waiting to be exploited through social engineering and other tricks.
SimpleCoder
+1  A: 

Actually it is possible to disable another extension, but only in experimental API for now. See chrome.experimental.management module.

serg