Article

About Content Script and Style Sheet Keys

Learn about controlling style sheet and script injection with information property list keys.

Overview

Content scripts and style sheets have similar functionality. Content scripts (as .js files) and style sheets (as .css files) are injected into webpages to customize web content. Injected scripts and styles have the same access privileges as the scripts and styles executed from the webpage’s host. The scripts can also send messages to, and receive messages from, the extension.

The following table describes the SFSafariContentScript subkeys:

Subkey

Type

Description

Script

String

Required. A string that specifies the path to the content script relative to the Resources folder in the extension's bundle; for example, script.js.

Allowed URL Patterns

Array

Optional. An array of URL patterns that describe which pages the script should be injected into.

Excluded URL Patterns

Array

Optional. An array of URL patterns that describe which pages the script can't be injected into.

The following table describes the SFSafariStyleSheet subkeys:

Subkey

Type

Description

Style Sheet

String

Required. A string that specifies the path to the style sheet relative to the Resources folder in the extension's bundle.

Allowed URL Patterns

Array

Optional. An array of URL patterns that describe which pages the style sheet should be injected into.

Excluded URL Patterns

Array

Optional. An array of URL patterns that describe which pages the style sheet can't be injected into.

To adjust permissions for scripts and style sheets, see About Permissions for Scripts and Style Sheets.