A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.chrome.com/docs/extensions/reference/api/devtools/inspectedWindow below:

chrome.devtools.inspectedWindow | API | Chrome for Developers

Skip to main content chrome.devtools.inspectedWindow

Stay organized with collections Save and categorize content based on your preferences.

Description

Use the chrome.devtools.inspectedWindow API to interact with the inspected window: obtain the tab ID for the inspected page, evaluate the code in the context of the inspected window, reload the page, or obtain the list of resources within the page.

See DevTools APIs summary for general introduction to using Developer Tools APIs.

The tabId property provides the tab identifier that you can use with the chrome.tabs.* API calls. However, please note that chrome.tabs.* API is not exposed to the Developer Tools extension pages due to security considerations—you will need to pass the tab ID to the background page and invoke the chrome.tabs.* API functions from there.

The reload method may be used to reload the inspected page. Additionally, the caller can specify an override for the user agent string, a script that will be injected early upon page load, or an option to force reload of cached resources.

Use the getResources call and the onResourceContent event to obtain the list of resources (documents, stylesheets, scripts, images etc) within the inspected page. The getContent and setContent methods of the Resource class along with the onResourceContentCommitted event may be used to support modification of the resource content, for example, by an external editor.

Manifest

The following keys must be declared in the manifest to use this API.

"devtools_page"
Execute code in the inspected window

The eval method provides the ability for extensions to execute JavaScript code in the context of the inspected page. This method is powerful when used in the right context and dangerous when used inappropriately. Use the tabs.executeScript method unless you need the specific functionality that the eval method provides.

Here are the main differences between the eval and tabs.executeScript methods:

Caution: Due to the security considerations explained above, the scripting.executeScript method is the preferred way for an extension to access DOM data of the inspected page in cases where the access to JavaScript state of the inspected page is not required.

Note that a page can include multiple different JavaScript execution contexts. Each frame has its own context, plus an additional context for each extension that has content scripts running in that frame.

By default, the eval method executes in the context of the main frame of the inspected page.

The eval method takes an optional second argument that you can use to specify the context in which the code is evaluated. This options object can contain one or more of the following keys:

frameURL
Use to specify a frame other than the inspected page's main frame.
contextSecurityOrigin
Use to select a context within the specified frame according to its web origin.
useContentScriptContext
If true, execute the script in the same context as the extensions's content scripts. (Equivalent to specifying the extensions's own web orgin as the context security origin.) This can be used to exchange data with the content script.
Examples

The following code checks for the version of jQuery used by the inspected page:

chrome.devtools.inspectedWindow.eval(
  "jQuery.fn.jquery",
  function(result, isException) {
    if (isException) {
      console.log("the page is not using jQuery");
    } else {
      console.log("The page is using jQuery v" + result);
    }
  }
);

To try this API, install the devtools API examples from the chrome-extension-samples repository.

Types

Resource

A resource within the inspected page, such as a document, a script, or an image.

Properties Properties

tabId

The ID of the tab being inspected. This ID may be used with chrome.tabs.* API.

Methods

eval()

chrome.devtools.inspectedWindow.eval(
  expression: string,
  options?: object,
  callback?: function,
)
: void

Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown. The eval function can report either a DevTools-side error or a JavaScript exception that occurs during evaluation. In either case, the result parameter of the callback is undefined. In the case of a DevTools-side error, the isException parameter is non-null and has isError set to true and code set to an error code. In the case of a JavaScript error, isException is set to true and value is set to the string value of thrown object.

Parameters

getResources()

chrome.devtools.inspectedWindow.getResources(
  callback: function,
)
: void

Retrieves the list of resources from the inspected page.

Parameters

reload()

chrome.devtools.inspectedWindow.reload(
  reloadOptions?: object,
)
: void

Reloads the inspected page.

Parameters Events

onResourceAdded

chrome.devtools.inspectedWindow.onResourceAdded.addListener(
  callback: function,
)

Fired when a new resource is added to the inspected page.

Parameters

onResourceContentCommitted

chrome.devtools.inspectedWindow.onResourceContentCommitted.addListener(
  callback: function,
)

Fired when a new revision of the resource is committed (e.g. user saves an edited version of the resource in the Developer Tools).

Parameters

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-11 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-11 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4