| OLD | NEW |
| 1 <p> | 1 <p> |
| 2 Use <code>chrome.devtools.inspectedWindow</code> | 2 Use <code>chrome.devtools.inspectedWindow</code> |
| 3 to interact with the inspected window: | 3 to interact with the inspected window: |
| 4 obtain the tab ID for the inspected page, | 4 obtain the tab ID for the inspected page, |
| 5 evaluate the code in the context of inspected window, | 5 evaluate the code in the context of inspected window, |
| 6 reload the page, | 6 reload the page, |
| 7 or obtain the list of resources within the page. | 7 or obtain the list of resources within the page. |
| 8 </p><p> | 8 </p><p> |
| 9 See <a href="devtools.html">DevTools APIs summary</a> for | 9 See <a href="devtools">DevTools APIs summary</a> for |
| 10 general introduction to using Developer Tools APIs. | 10 general introduction to using Developer Tools APIs. |
| 11 </p> | 11 </p> |
| 12 | 12 |
| 13 <h2 id="overview">Overview</h2> | 13 <h2 id="overview">Overview</h2> |
| 14 <p> | 14 <p> |
| 15 The <code>$(ref:devtools.inspectedWindow.tabId tabId)</code> property | 15 The <code>$(ref:devtools.inspectedWindow.tabId tabId)</code> property |
| 16 provides the tab identifier that you can use with the | 16 provides the tab identifier that you can use with the |
| 17 <a href="tabs.html"><code>chrome.tabs.*</code></a> API calls. | 17 <a href="tabs"><code>chrome.tabs.*</code></a> API calls. |
| 18 However, please note that <code>chrome.tabs.*</code> API is not | 18 However, please note that <code>chrome.tabs.*</code> API is not |
| 19 exposed to the Developer Tools extension pages due to security considerations | 19 exposed to the Developer Tools extension pages due to security considerations |
| 20 — you will need to pass the tab ID to the background page and invoke | 20 — you will need to pass the tab ID to the background page and invoke |
| 21 the <code>chrome.tabs.*</code> API functions from there. | 21 the <code>chrome.tabs.*</code> API functions from there. |
| 22 </p> | 22 </p> |
| 23 <p> | 23 <p> |
| 24 The <code>reload</code> method may be used to reload the inspected page. | 24 The <code>reload</code> method may be used to reload the inspected page. |
| 25 Additionally, the caller can specify an override for the user agent string, | 25 Additionally, the caller can specify an override for the user agent string, |
| 26 a script that will be injected early upon page load, or an option to force | 26 a script that will be injected early upon page load, or an option to force |
| 27 reload of cached resources. | 27 reload of cached resources. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 46 <p>Here are the main differences between the | 46 <p>Here are the main differences between the |
| 47 <code>eval</code> and <code>tabs.executeScript</code> methods: | 47 <code>eval</code> and <code>tabs.executeScript</code> methods: |
| 48 </p><ul> | 48 </p><ul> |
| 49 <li>The <code>eval</code> method does not | 49 <li>The <code>eval</code> method does not |
| 50 use an isolated world for the code being evaluated, so the JavaScript state | 50 use an isolated world for the code being evaluated, so the JavaScript state |
| 51 of the inspected window is accessible to the code. | 51 of the inspected window is accessible to the code. |
| 52 Use this method when access to the JavaScript state of the inspected page | 52 Use this method when access to the JavaScript state of the inspected page |
| 53 is required. | 53 is required. |
| 54 </li><li> | 54 </li><li> |
| 55 The execution context of the code being evaluated includes the | 55 The execution context of the code being evaluated includes the |
| 56 <a href="http://code.google.com/chrome/devtools/docs/console.html">Developer | 56 <a href="http://code.google.com/chrome/devtools/docs/console">Developer |
| 57 Tools console API</a>. | 57 Tools console API</a>. |
| 58 For example, | 58 For example, |
| 59 the code can use <code>inspect</code> and <code>$0</code>. | 59 the code can use <code>inspect</code> and <code>$0</code>. |
| 60 </li><li> | 60 </li><li> |
| 61 The evaluated code may return a value that is passed to the extension callback. | 61 The evaluated code may return a value that is passed to the extension callback. |
| 62 The returned value has to be a valid JSON object (it may contain only | 62 The returned value has to be a valid JSON object (it may contain only |
| 63 primitive JavaScript types and acyclic references to other JSON | 63 primitive JavaScript types and acyclic references to other JSON |
| 64 objects). | 64 objects). |
| 65 | 65 |
| 66 <em>Please observe extra care while processing the data received from the | 66 <em>Please observe extra care while processing the data received from the |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (isException) | 112 if (isException) |
| 113 console.log("the page is not using jQuery"); | 113 console.log("the page is not using jQuery"); |
| 114 else | 114 else |
| 115 console.log("The page is using jQuery v" + result); | 115 console.log("The page is using jQuery v" + result); |
| 116 } | 116 } |
| 117 ); | 117 ); |
| 118 </pre> | 118 </pre> |
| 119 | 119 |
| 120 <p> | 120 <p> |
| 121 You can find more examples that use Developer Tools APIs in | 121 You can find more examples that use Developer Tools APIs in |
| 122 <a href="samples.html#devtools">Samples</a>. | 122 <a href="samples#devtools">Samples</a>. |
| 123 </p> | 123 </p> |
| OLD | NEW |