Userscript 中 @run-at 键的定义

Defines the moment the script is injected. In opposition to other script handlers, @run-at defines the first possible moment a script wants to run. This means it may happen, that a script that uses the @require tag may be executed after the document is already loaded, cause fetching the required script took that long. Anyhow, all DOMNodeInserted and DOMContentLoaded events that happended after the given injection moment are cached and delivered to the script when it is injected.

Code:
// @run-at document-start

The script will be injected as fast as possible.

Code:
// @run-at document-body

The script will be injected if the body element exists.

Code:
// @run-at document-end

The script will be injected when or after the DOMContentLoaded event was dispatched.

Code:
// @run-at document-idle

The script will be injected after the DOMContentLoaded event was dispatched.

Code:
// @run-at context-menu

The script will be injected if it is clicked at the browser context menu (desktop Chrome-based browsers only).
Note: all @include and @exclude statements will be ignored if this value is used, but this may change in the future.

发布者

胡中元

《中原驿站》站长

《Userscript 中 @run-at 键的定义》上有1条评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注