0

I am working with a chrome extension . I want to inject js script in all tab. I am using this manifest.json :

{
    "name": "ABC",
    "version": "0.0.1",
    "manifest_version": 2,
    "background": {
        "scripts": [
            "src/background/background.min.js"
        ],
        "persistent": true
    },
    "browser_action": {
        "default_icon": "icons/128.png",
        "default_title": "ABC",
        "default_popup": "src/browser_action/index.html"
    },
    "permissions": [
        "tabs",
        "http://*/*",
        "https://*/*",
        "<all_urls>"
    ],
    "content_scripts": [{
        "matches": ["<all_urls>"],
        "js": ["./src/inject/inject.min.js"],
        "css": ["./css/inject.min.css"],
        "all_frames": true
    }]
}

And my inject.js is like this :

(function() {
   console.log("Hello");
});

I am getting all log from all tab except the tab of the chrome setting (eg : chrome://extensions/:id , chrome://history etc). Am I missing something in manifest.json or chrome disables the feature of injection in settings page ?

Thanks in advance.

Sourav Mondal
  • 405
  • 2
  • 12

1 Answers1

2

Indeed, you can't inject code into chrome:// pages. They contain control elements / code that can modify the browser in ways that an extension is not allowed to.

Chrome resolves this by simply not allowing permissions to be set for chrome:// URLs, and <all_urls> does not include it.

However, you could use Override Pages to replace some of them (well, History page at least) completely.

Xan
  • 74,770
  • 16
  • 179
  • 206
  • Thanks for your answer. I have an another queries , can you help me ? This injection is not also working in this page https://chrome.google.com/webstore/category/extensions?hl=en-US . But this should matches with "https://*/*" pattern . – Sourav Mondal Mar 24 '16 at 09:09
  • See http://stackoverflow.com/questions/30259634/chrome-extension-open-new-tab-on-new-tab/30261291 – Xan Mar 24 '16 at 09:15