Run Content scripts on pages.

Declare the content script

Extensions can run scripts that read and modify the content of a page. These are called content scripts. They live in an isolated world, meaning they can make changes to their JavaScript environment without conflicting with their host page or other extensions’ content scripts.

Register a content script called content.js.

matches: Allow the browser to identify which sites to inject the content scripts into. Match patterns consist of three parts: <scheme>://<host><path>. They can contain ‘*’ characters.

Link: Match Patterns

1
2
3
4
5
6
7
8
{
"content_scripts": [
{
"js": ["scripts/content.js"],
"matches": ["https://*/*"]
}
]
}

Content scripts

Content scripts can use the standard Document Object Model (DOM) to read and change the content of a page.

Other Notes