5

When I view my extension with the developer tools, I only see the generated background file, background.js; my content script doesn't appear under the content scripts tab. Any ideas why? The relevant part of the manifest looks like this:

"content_scripts": [{
"run_at": "document_end",
"js": ["postMsg.js"],
"matches": ["https://groups.google.com/forum/*"]
}],

postMsg.js gets injected into the page, but never appears in the developer tool window, so I'm unable to debug it.

FractalBob
  • 3,225
  • 4
  • 29
  • 40

3 Answers3

5

As long as you are on a page that matches the "Match patterns and globs" from your manifest, you will see the content script(s) under the Sources -> Content Scripts pane.
You may need to refresh (F5) the page (and/or your extension, then the page) to see it:

(Click for larger image)
Debug steps


For more information on matching that cryptic number to an extension, see this answer.

Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • 1
    Thanks. I see what I was doing wrong: I needed to reload the developer console AFTER navigating to the Post page. – FractalBob Nov 27 '12 at 16:57
  • Hi, I put down in "matches" so theoretically it would match any valid address. But I am still not seeing my content script under "Content scripts". And I have also tried refreshing(on a mac it's command + r). Any idea??? – nyus2006 Apr 08 '15 at 01:51
  • I did the same thing as FractalBob, but let me paraphrase - you won't initially see anything when you open the inspector. After opening the inspector, then visit the site you want to and the content script will then show up. – Sridhar Sarnobat Aug 03 '16 at 04:55
0

content scripts as a js file are never exposed by pages which are injected.. If your intention is debugging of content scripts it can be possible;

Ex:

mycontentscripts.js

var getStyleofbody = document.getElementsByTagName('body')[0].style;

to debug this i would first run this code in console of page that i am going to inject; After i get expected results i will move code to contentscript js file.

enter image description here

However for any errors after injection you can look at developer's console panel for all errors(they are listed there).

enter image description here

Let me know if you are confused

Sudarshan
  • 18,140
  • 7
  • 53
  • 61
0

In 2018, if for some reason you've missed it:

The file bar in sources

Press the >>. From there select content scripts, and you'll be able to see the content scripts.

hf :)

acenturyandabit
  • 1,188
  • 10
  • 24