Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are content scripts in chrome inspector

While this could be a very basic thing, I can't seem to find an answer to this one. I see a lot of discussion about content scripts. When I open web inspector in chrome, and select sources, I see a tab called content scripts. I see a couple of random numbers and a number of scripts and I can't seem to figure out what these are. How are these being shown? where are these coming from? I can't see my server serving any of these.

like image 832
Kiran Avatar asked Aug 11 '12 04:08

Kiran


People also ask

What is content script?

A content script is a part of your extension that runs in the context of a particular web page (as opposed to background scripts which are part of the extension, or scripts which are part of the website itself, such as those loaded using the <script> element).

What is background script and content script?

Background Script - Provides persistence and handles background events. Content Script - Scripts that run in isolation in the context of the web page. Injected Script - Scripts that are programmatically injected into the web page.

How do I run a script in Chrome?

Press F12 to open the chrome developer tool and then click on the console tab. Logging in Script Area example: try writing console. log('Your message') and click Execute button or alternative you can use the log method directly like log('My Message'). Try executing this script on any page.


1 Answers

In Google Chrome, content scripts are JavaScript files that are part of browser extensions. They operate on the web page much like regular javascript does, but from a protected scope (Google calls it an "Isolated World").

Content scripts have a few more privileges than ordinary javascript and, for that reason, content-script JS and page JS cannot ordinarily interact with each other.

When looking at that Content Scripts tab, you will see both the scripts added by any extensions (or by userscripts which are compiled into extensions in Chrome), and also content scripts that are built-in parts of the browser, specifically the API that extensions can use.

Content script listing


You can match extensions to those "random numbers" by opening the extensions tab (chrome://chrome/extensions), and activating Developer mode:

Matching extensions

like image 167
Brock Adams Avatar answered Oct 22 '22 18:10

Brock Adams