Questions tagged [content-script]

Content scripts are JavaScript files, used by browser extensions or add-ons. They are the part of an extension that can interact with the document context of the current web page. This mainly applies to Firefox or Chrome extensions.

Content scripts are JavaScript files, used by browser extensions or add-ons. They are the part of an extension that can interact with the document context of the current web page. This mainly applies to Firefox or Chrome extensions.

Content scripts interact with a webpage via the DOM API, and they frequently have enhanced privileges and access to privileged browser-API functions compared to ordinary webpage javascript.

For this reason, content scripts are isolated from a target-page's javascript by scoping, and/or sandboxing, and/or anonymous function wrapping. Content-script javascript cannot (normally) directly interact with a page's javascript objects, and vice versa.

Content scripts are very similar to userscripts and Greasemonkey scripts, but as part of full-fledged extensions (add-ons), content scripts can have both more powerful options and more involved coding requirements.

References:


Related tags:

719 questions
5
votes
1 answer

Is Chrome violating Content Security Policy?

I have made a browser extension for both chrome and firefox. The firefox one is developed using Web Extension APIs and so there are minimal code differences in these two extensions. As an important feature in the extension, some HTML elements…
5
votes
1 answer

Chrome Extension: Difference between "permissions" and "matches" (match patterns)

I am trying to understand, what is the difference between: "permissions": [ "*.google.com" ], and "content_scripts": [ { "matches": ["*.google.com"] } ]
5
votes
1 answer

Chrome extension inject html to specific div

Im trying to make an extension for chrome that injects html code to specific div on a specific page. This is the example page I want to inject some…
5
votes
1 answer

AJAX Blocked from chrome extension content_script

i'm writing a chrome extension that use a content_script. the content script use XMLHttpRequest to send information about the page to my server, and base on that information the server respond with somethings that has to be done. everything works…
5
votes
2 answers

Chrome content script does not load in about:blank page

I am developing a Chrome extension which will load content script according to the following manifest: "content_scripts" : [ { "matches" : [ "" ], "js" : [ "scripts/namespace/namespace.js", …
Leslie Wu
  • 760
  • 3
  • 13
  • 29
5
votes
3 answers

Unable to view content script references in the developer tools window

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…
5
votes
2 answers

Selecting