* 実行タイミング

[11] [[ブラウザー拡張]]の仕様は [[Webブラウザー]]により異なりますが、
次のタイミングで[[内容スクリプト]]を実行させることができるかもしれません。
[FIG(short list)[
- [[navigate]] により[[文書]]が作られた直後
- [[文書要素]]の挿入直後
- [[文書]]の [CODE(DOMe)@en[[[DOMContentLoaded]]]]
- [[文書]]の [CODE(DOMe)@en[[[load]]]]
- [[文書]]の [CODE(DOMe)@en[[[DOMContentLoaded]]]] より後で [CODE(DOMe)@en[[[load]]]]
より前の都合の良い時点
]FIG]

* 実装

[1] [CITE[Content Scripts - Google Chrome]]
( ([TIME[2014-04-02 10:39:43 +09:00]] 版))
<https://developer.chrome.com/extensions/content_scripts>

[2] [CITE[User Scripts - The Chromium Projects]]
( ([TIME[2014-04-02 07:32:33 +09:00]] 版))
<http://www.chromium.org/developers/design-documents/user-scripts/>

[7] [[内容スクリプト]]は [[isolated world]] と呼ばれる特別な環境で実行されます。

[3] [CITE@en-US[Content Scripts - Mozilla | MDN]]
([TIME[2015-05-06 08:47:31 +09:00]] 版)
<https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts>

[4] [CITE@en-US[Content Processes - Mozilla | MDN]] ([TIME[2014-12-21 23:51:46 +09:00]] 版) <https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Contributor_s_Guide/Content_Processes>

[5] [[内容スクリプト]]からの[[文書]]の [[DOM]] や[[大域オブジェクト]]へのアクセスは、
それ自体ではなく、特別なラッパーオブジェクトを介して行うようになっています [SRC[>>4]]。

;; [[Xray]] も参照。

[6] [CITE@en-US[Communicating With Other Scripts - Mozilla | MDN]]
([TIME[2014-06-05 02:42:35 +09:00]] 版)
<https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/Communicating_With_Other_Scripts>

[8] [[Chrome]] の [CODE@en["run_at": "document_start"]] は[[文書]]が作成された後で、
構文解析が始まる前 ([[子供]]がまだない時点) のようです。

[9] [CITE[Content scripts - Opera 15+ extensions documentation]]
([TIME[2015-03-14 01:51:40 +09:00]] 版)
<https://dev.opera.com/extensions/tut_content_scripts.html>

* 関連

[10] 趣旨としては [[Greasemonkey]] と同じものかもしれません。


[FIG(quote)[
[FIGCAPTION[
[12] [CITE@en-US[Chrome incompatibilities - Mozilla | MDN]]
( ([TIME[2016-06-14 10:15:04 +09:00]]))
<https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities>
]FIGCAPTION]

> content_scripts
> Firefox does not support:
> match_about_blank
> include_globs
> exclude_globs

]FIG]


[13] [CITE@en-US[Content scripts - Mozilla | MDN]]
( ([TIME[2016-04-03 13:40:20 +09:00]]))
<https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts>

[14] [CITE@en[1422951 - Add a CSS-parsing WebExtensions API]]
([TIME[2017-12-21 00:56:32 +09:00]])
<https://bugzilla.mozilla.org/show_bug.cgi?id=1422951>