7

I am trying to add a content script to my chrome extension but for some reason the content script is not getting executed

Content script code:

console.log("In content script");

File name is content.js

My manifest file:

{
    "name": "Getting Started Example",
    "description": "Build an Extension!",
    "version": "1.0",
    "manifest_version": 3,
    "background": {
        "service_worker": "background.js"
    },
    "permissions": [
        "storage",
        "activeTab",
        "scripting",
        "tabs"
    ],
    "action": {
        "default_popup": "popup.html"
    },
    "content_scripts": [
        {
            "all_frames": true,
            "matches": [
                "<all_urls>"
            ],
            "js": [
                "content.js"
            ]
        }
    ],
    "options_page": "options.html"
}
1
  • 1
    1) Make sure to reload the extension on chrome://extensions page and then reload the web page. 2) Content scripts run only in web pages/iframes, not in the UI pages of the browser like the start tab or settings etc.
    – wOxxOm
    Jan 4, 2022 at 16:30

1 Answer 1

20

I am really sorry content script's answers appear in the browser console and not the extension's console and I was only checking the extensions console until now

Everything is working as it should.

1
  • 1
    I EXACTLY faced what you encountered. Thank you so much!
    – kodfire
    Aug 20, 2022 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.