![]() # Extension HTML pagesĪn extension can have different HTML pages depending on the design. See Understanding content scripts for more details. They also have access to a limited number of Chrome APIs. An extension can choose which websites a content script should run on by specifying match patterns.Ĭontent Scripts share access to the same DOM tree as the host page but run in a separate JavaScript environment (the extension's isolated world). Host pages are the websites that a content script interacts with. For example, they can insert a new element on the page, change the style of a website, modify the DOM elements, etc. They allow the extension to interact with and modify pages in the browser. # Content scriptsĮxtensions use content scripts ( content-script.js) to inject code into host pages. See Handling events in the extension service worker for more details. It also runs in its own environment, so it cannot directly modify a web page's content. For example, the service worker can listen for and react to events when the extension is first installed, a new tab is created, a new bookmark is added, the extension toolbar icon is clicked, etc.Ī service worker can access all the Extension APIs, but as a type of Worker it can't use the DOM APIs that a document's global Window object provides. ![]() It is often used to process data, coordinate tasks in different parts of an extension, and as an extension's event manager. ![]() # The extension service workerĪn extension service worker ( service-worker.js) is an event-based script that the browser runs in the background. For ready to use code samples, check out the Manifest examples. The Manifest keys article contains the complete list of default and optional keys.
0 Comments
Leave a Reply. |