OLD | NEW |
1 <h1>Content Scripts</h1> | 1 <h1>Content Scripts</h1> |
2 | 2 |
3 | 3 |
4 <p> | 4 <p> |
5 Content scripts are JavaScript files that run in the context of web pages. | 5 Content scripts are JavaScript files that run in the context of web pages. |
6 By using the standard | 6 By using the standard |
7 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/">Document | 7 <a href="http://www.w3.org/TR/DOM-Level-2-HTML/">Document |
8 Object Model</a> (DOM), | 8 Object Model</a> (DOM), |
9 they can read details of the web pages the browser visits, | 9 they can read details of the web pages the browser visits, |
10 or make changes to them. | 10 or make changes to them. |
11 </p> | 11 </p> |
12 | 12 |
13 <p> | 13 <p> |
14 Here are some examples of what content scripts can do: | 14 Here are some examples of what content scripts can do: |
15 </p> | 15 </p> |
16 | 16 |
17 <ul> | 17 <ul> |
18 <li>Find unlinked URLs in web pages and convert them into hyperlinks | 18 <li>Find unlinked URLs in web pages and convert them into hyperlinks |
19 <li>Increase the font size to make text more legible | 19 <li>Increase the font size to make text more legible |
20 <li>Find and process <a href="http://microformats.org/">microformat</a> data i
n the DOM | 20 <li>Find and process <a href="http://microformats.org/">microformat</a> data i
n the DOM |
21 </ul> | 21 </ul> |
22 | 22 |
23 <p> | 23 <p> |
24 However, content scripts have some limitations. | 24 However, content scripts have some limitations. |
25 They <b>cannot</b>: | 25 They <b>cannot</b>: |
26 </p> | 26 </p> |
27 | 27 |
28 <ul> | 28 <ul> |
29 <li> | 29 <li> |
30 Use chrome.* APIs | 30 Use chrome.* APIs, with the exception of: |
31 (except for parts of | 31 <ul id="content_script_supported_nodes"> |
32 <a href="extension"><code>chrome.extension</code></a>) | 32 {{#api:content_scripts}} |
| 33 <li> |
| 34 $(ref:{{api.name}}) |
| 35 {{?api.restrictedTo}} |
| 36 ({{#n:api.restrictedTo}} |
| 37 $(ref:{{api.name}}.{{n.node}} {{n.node}}) |
| 38 {{^n.last}},{{/n.last}} |
| 39 {{/api.restrictedTo}}) |
| 40 {{/api.restrictedTo}} |
| 41 </li> |
| 42 {{/content_scripts}} |
| 43 </ul> |
33 </li> | 44 </li> |
34 <li> | 45 <li> |
35 Use variables or functions defined by their extension's pages | 46 Use variables or functions defined by their extension's pages |
36 </li> | 47 </li> |
37 <li> | 48 <li> |
38 Use variables or functions defined by web pages or by other content scripts | 49 Use variables or functions defined by web pages or by other content scripts |
39 </li> | 50 </li> |
40 </ul> | 51 </ul> |
41 | 52 |
42 <p> | 53 <p> |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 477 |
467 <p> | 478 <p> |
468 The next video describes message passing, | 479 The next video describes message passing, |
469 featuring an example of a content script | 480 featuring an example of a content script |
470 sending a request to its parent extension. | 481 sending a request to its parent extension. |
471 </p> | 482 </p> |
472 | 483 |
473 <div class="video-container"> | 484 <div class="video-container"> |
474 <iframe title="YouTube video player" width="640" height="390" src="//www.youtu
be.com/embed/B4M_a7xejYI?rel=0" frameborder="0" allowfullscreen></iframe> | 485 <iframe title="YouTube video player" width="640" height="390" src="//www.youtu
be.com/embed/B4M_a7xejYI?rel=0" frameborder="0" allowfullscreen></iframe> |
475 </div> | 486 </div> |
OLD | NEW |