new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Electron · API · all subjects

web-contents/devtools

19 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

contents.addWorkSpace(path) - add DevTools workspace

Adds the specified path to DevTools workspace. Must be used after DevTools creation. Parameters: path (string).

addWorkSpace() example

const { BrowserWindow } = require('electron') const win = new BrowserWindow() win.webContents.on('devtools-opened', () => { win.webContents.addWorkSpace(__dirname) })

contents.removeWorkSpace(path) - remove DevTools workspace

Removes the specified path from DevTools workspace. Parameters: path (string).

contents.setDevToolsWebContents(devToolsWebContents) - set DevTools target

Uses the devToolsWebContents as the target WebContents to show DevTools. The devToolsWebContents must not have done any navigation, and it should not be used for other purposes after the call. By default, Electron manages the DevTools by creating an internal WebContents with native view. With this method, developers can use any WebContents to show the DevTools, such as BrowserWindow or WebContentsView. Note that closing the DevTools does not destroy the devToolsWebContents; it is the caller's responsibility to destroy it manually. Parameters: devToolsWebContents (WebContents).

setDevToolsWebContents() example

const { app, BrowserWindow } = require('electron') let win = null let devtools = null app.whenReady().then(() => { win = new BrowserWindow() devtools = new BrowserWindow() win.loadURL('https://github.com') win.webContents.setDevToolsWebContents(devtools.webContents) win.webContents.openDevTools({ mode: 'detach' }) })

contents.openDevTools(options) - open DevTools

Opens the DevTools. Parameters: options (Object, optional) with mode (string) - opens the DevTools with specified dock state (can be 'left', 'right', 'bottom', 'undocked', 'detach'; defaults to last used dock state; in 'undocked' mode it's possible to dock back, in 'detach' mode it's not), activate (boolean, optional, defaults to true) - whether to bring the opened DevTools window to the foreground, title (string, optional) - a title for the DevTools window (only in 'undocked' or 'detach' mode). When contents is a webview tag, the mode would be 'detach' by default; explicitly passing an empty mode can force using last used dock state. On Windows, if Window Control Overlay is enabled, DevTools will be opened with mode: 'detach'.

contents.closeDevTools() - close DevTools

Closes the DevTools view.

contents.isDevToolsOpened() - check if DevTools is open

Returns boolean indicating whether the DevTools view is opened.

contents.isDevToolsFocused() - check if DevTools is focused

Returns boolean indicating whether the DevTools view is focused.

contents.getDevToolsTitle() - get DevTools window title

Returns string - the current title of the DevTools window. This will only be visible if DevTools is opened in 'undocked' or 'detach' mode.

contents.setDevToolsTitle(title) - set DevTools window title

Changes the title of the DevTools window. This will only be visible if DevTools is opened in 'undocked' or 'detach' mode. Parameters: title (string).

contents.toggleDevTools() - toggle DevTools

Toggles the developer tools.

contents.inspectElement(x, y) - inspect element

Starts inspecting element at position (x, y). Parameters: x (Integer), y (Integer).

contents.inspectSharedWorker() - inspect shared worker

Opens the developer tools for the shared worker context.

contents.inspectSharedWorkerById(workerId) - inspect shared worker by ID

Inspects the shared worker based on its ID. Parameters: workerId (string).

contents.getAllSharedWorkers() - get all shared workers

Returns SharedWorkerInfo[] - information about all Shared Workers.

contents.inspectServiceWorker() - inspect service worker

Opens the developer tools for the service worker context.

contents.getOrCreateDevToolsTargetId() - get DevTools target ID

Returns string - the Chrome DevTools Protocol TargetID associated with this WebContents. This is the reverse of webContents.fromDevToolsTargetId(). This method creates a new DevTools agent for this WebContents if one does not already exist.

contents.devToolsWebContents property

A WebContents | null property that represents the DevTools WebContents associated with a given WebContents. Users should never store this object because it may become null when the DevTools has been closed.

Give your agent this brain