Sourav Mondal
Sourav Mondal

Reputation: 415

Content script doesn't support chrome settings page (url : chrome://history/ etc. )

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.

Upvotes: 1

Views: 760

Answers (1)

Xan
Xan

Reputation: 77492

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.

Upvotes: 2

Related Questions