An open API service indexing awesome lists of open source software.

https://github.com/electron-utils/electron-quick-inspect

Quickly inspect an element at mouse position via `webContents.inspectElement(x,y)`.
https://github.com/electron-utils/electron-quick-inspect

devtools electron

Last synced: 2 months ago
JSON representation

Quickly inspect an element at mouse position via `webContents.inspectElement(x,y)`.

Awesome Lists containing this project

README

        

# electron-quick-inspect

[![Dependency Status](https://david-dm.org/electron-utils/electron-quick-inspect.svg)](https://david-dm.org/electron-utils/electron-quick-inspect)
[![devDependency Status](https://david-dm.org/electron-utils/electron-quick-inspect/dev-status.svg)](https://david-dm.org/electron-utils/electron-quick-inspect#info=devDependencies)

Quickly inspect an element at mouse position via `webContents.inspectElement(x,y)`.



## Why?

This is similar to Chrome's inspect element tools. You can achieve it by several ways such as:

- open the devtools and click the icon ![devtools icon](https://cloud.githubusercontent.com/assets/174891/21879224/229b8c22-d8d2-11e6-8dbc-4179653e74d5.png)
- open the devtools and press `ctrl/command + shift + c`
- call `win.devToolsWebContents.executeJavaScript('DevToolsAPI.enterInspectElementMode()')` in the main process when devtools opened.

However, all these methods needs you open the devtools first. Sometimes I just want to check the element quickly regardless the devtools,
and that's the reason this module here.

## Install

```bash
npm install --save electron-quick-inspect
```

## Run the example:

```bash
npm start example
```

## Usage

In your main process:

```javascript
const quickInspect = require('electron-quick-inspect');

quickInspect.inspect(browserWindow);
```

Even better, you can add a accelerator to quickly start it by registering a menu item:

```javascript
const {app, BrowserWindow, Menu, MenuItem} = require('electron');
const quickInspect = require('electron-quick-inspect');

let win;

app.on('ready', function () {
// win
win = new BrowserWindow({
center: true,
width: 400,
height: 600,
x: 100,
y: 100,
});
win.loadURL('file://' + __dirname + '/index.html');

let appMenu = Menu.getApplicationMenu();
appMenu.append(new MenuItem({
label: 'Develop',
submenu: Menu.buildFromTemplate([
{
label: 'Inspect Element',
accelerator: 'CmdOrCtrl+Shift+C',
click () {
let focusedWin = BrowserWindow.getFocusedWindow();
quickInspect.inspect(focusedWin);
}
}
])
}));

Menu.setApplicationMenu(appMenu);
});
```

## License

MIT © 2017 Johnny Wu