WebKit2GTK+ Reference Manual: User content

## User content User content — Defines user content types which affect web pages. |

## Functions

WebKitUserStyleSheet * | webkit_user_style_sheet_ref ()
void | webkit_user_style_sheet_unref ()
WebKitUserStyleSheet * | webkit_user_style_sheet_new ()
WebKitUserScript * | webkit_user_script_ref ()
void | webkit_user_script_unref ()
WebKitUserScript * | webkit_user_script_new ()

## Types and Values

| WebKitUserStyleSheet
| WebKitUserScript
enum | WebKitUserContentInjectedFrames
enum | WebKitUserStyleLevel
enum | WebKitUserScriptInjectionTime

## Object Hierarchy

        GBoxed
        ├── WebKitUserScript
        ╰── WebKitUserStyleSheet

## Description

See also: WebKitUserContentManager

## Functions

### webkit_user_style_sheet_ref ()

    WebKitUserStyleSheet *
    webkit_user_style_sheet_ref (WebKitUserStyleSheet *user_style_sheet);

Atomically increments the reference count of `user_style_sheet` by one. This function is MT-safe and may be called from any thread.

#### Parameters

user_style_sheet | a WebKitUserStyleSheet |

#### Returns

The passed WebKitUserStyleSheet

Since 2.6

### webkit_user_style_sheet_unref ()

    void
    webkit_user_style_sheet_unref (WebKitUserStyleSheet *user_style_sheet);

Atomically decrements the reference count of `user_style_sheet` by one. If the reference count drops to 0, all memory allocated by WebKitUserStyleSheet is released. This function is MT-safe and may be called from any thread.

#### Parameters

user_style_sheet | a WebKitUserStyleSheet |

Since 2.6

### webkit_user_style_sheet_new ()

    WebKitUserStyleSheet *
    webkit_user_style_sheet_new (const gchar *source,
                                 WebKitUserContentInjectedFrames injected_frames,
                                 WebKitUserStyleLevel level,
                                 const gchar * const *whitelist,
                                 const gchar * const *blacklist);

Creates a new user style sheet. Style sheets can be applied to some URIs only by passing non-null values for `whitelist` or `blacklist` . Passing a `NULL` whitelist implies that all URIs are on the whitelist. The style sheet is applied if an URI matches the whitelist and not the blacklist. URI patterns must be of the form `[protocol]://[host]/[path]`, where the *host* and *path* components can contain the wildcard character (`*`) to represent zero or more other characters.

#### Parameters

source | Source code of the user style sheet. |
injected_frames | A WebKitUserContentInjectedFrames value |
level | A WebKitUserStyleLevel |
whitelist | A whitelist of URI patterns or `NULL`. | [array zero-terminated=1][allow-none]
blacklist | A blacklist of URI patterns or `NULL`. | [array zero-terminated=1][allow-none]

#### Returns

A new WebKitUserStyleSheet

Since 2.6

### webkit_user_script_ref ()

    WebKitUserScript *
    webkit_user_script_ref (WebKitUserScript *user_script);

Atomically increments the reference count of `user_script` by one. This function is MT-safe and may be called from any thread.

#### Parameters

user_script | a WebKitUserScript |

#### Returns

The passed WebKitUserScript

Since 2.6

### webkit_user_script_unref ()

    void
    webkit_user_script_unref (WebKitUserScript *user_script);

Atomically decrements the reference count of `user_script` by one. If the reference count drops to 0, all memory allocated by WebKitUserScript is released. This function is MT-safe and may be called from any thread.

#### Parameters

user_script | a WebKitUserScript |

Since 2.6

### webkit_user_script_new ()

    WebKitUserScript *
    webkit_user_script_new (const gchar *source,
                            WebKitUserContentInjectedFrames injected_frames,
                            WebKitUserScriptInjectionTime injection_time,
                            const gchar * const *whitelist,
                            const gchar * const *blacklist);

Creates a new user script. Scripts can be applied to some URIs only by passing non-null values for `whitelist` or `blacklist` . Passing a `NULL` whitelist implies that all URIs are on the whitelist. The script is applied if an URI matches the whitelist and not the blacklist. URI patterns must be of the form `[protocol]://[host]/[path]`, where the *host* and *path* components can contain the wildcard character (`*`) to represent zero or more other characters.

#### Parameters

source | Source code of the user script. |
injected_frames | A WebKitUserContentInjectedFrames value |
injection_time | A WebKitUserScriptInjectionTime value |
whitelist | A whitelist of URI patterns or `NULL`. | [array zero-terminated=1][allow-none]
blacklist | A blacklist of URI patterns or `NULL`. | [array zero-terminated=1][allow-none]

#### Returns

A new WebKitScript

Since 2.6

## Types and Values

### WebKitUserStyleSheet

    typedef struct _WebKitUserStyleSheet WebKitUserStyleSheet;

### WebKitUserScript

    typedef struct _WebKitUserScript WebKitUserScript;

### enum WebKitUserContentInjectedFrames

Specifies in which frames user style sheets are to be inserted in.

#### Members

WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES | Insert the user style sheet in all the frames loaded by the web view, including nested frames. This is the default. |
WEBKIT_USER_CONTENT_INJECT_TOP_FRAME | Insert the user style sheet *only* in the top-level frame loaded by the web view, and *not* in the nested frames. |

Since 2.6

### enum WebKitUserStyleLevel

Specifies how to treat an user style sheet.

#### Members

WEBKIT_USER_STYLE_LEVEL_USER | The style sheet is an user style sheet, its contents always override other style sheets. This is the default. |
WEBKIT_USER_STYLE_LEVEL_AUTHOR | The style sheet will be treated as if it was provided by the loaded documents. That means other user style sheets may still override it. |

Since 2.6

### enum WebKitUserScriptInjectionTime

Specifies at which place of documents an user script will be inserted.

#### Members

WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START | Insert the code of the user script at the beginning of loaded documents. This is the default. |
WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END | Insert the code of the user script at the end of the loaded documents. |

Since 2.6