electron-debug
Advanced tools
Comparing version 0.2.1 to 0.3.0
40
index.js
@@ -8,3 +8,3 @@ 'use strict'; | ||
function devTools() { | ||
var win = BrowserWindow.getFocusedWindow(); | ||
const win = BrowserWindow.getFocusedWindow(); | ||
@@ -17,3 +17,3 @@ if (win) { | ||
function refresh() { | ||
var win = BrowserWindow.getFocusedWindow(); | ||
const win = BrowserWindow.getFocusedWindow(); | ||
@@ -25,5 +25,29 @@ if (win) { | ||
module.exports = function () { | ||
app.on('ready', function () { | ||
app.on('browser-window-focus', function () { | ||
function activateDebugContextMenu(e) { | ||
const webContents = e.sender; | ||
webContents.executeJavaScript(`require('${__dirname}/context-menu').install();`); | ||
} | ||
function deactivateDebugContextMenu(e) { | ||
const webContents = e.sender; | ||
webContents.executeJavaScript(`require('${__dirname}/context-menu').uninstall();`); | ||
} | ||
function installDebugContextMenu(win) { | ||
win.webContents.on('devtools-opened', activateDebugContextMenu); | ||
win.webContents.on('devtools-closed', deactivateDebugContextMenu); | ||
if (win.webContents.isDevToolsOpened()) { | ||
activateDebugContextMenu({sender: win.webContents}); | ||
} | ||
} | ||
function uninstallDebugContextMenu(win) { | ||
win.webContents.removeListener('devtools-opened', activateDebugContextMenu); | ||
win.webContents.removeListener('devtools-closed', deactivateDebugContextMenu); | ||
} | ||
module.exports = () => { | ||
app.on('ready', () => { | ||
app.on('browser-window-focus', (e, win) => { | ||
globalShortcut.register(isOSX ? 'Cmd+Alt+I' : 'Ctrl+Shift+I', devTools); | ||
@@ -34,5 +58,7 @@ globalShortcut.register('F12', devTools); | ||
globalShortcut.register('F5', refresh); | ||
installDebugContextMenu(win); | ||
}); | ||
app.on('browser-window-blur', function () { | ||
app.on('browser-window-blur', (e, win) => { | ||
globalShortcut.unregister(isOSX ? 'Cmd+Alt+I' : 'Ctrl+Shift+I'); | ||
@@ -43,4 +69,6 @@ globalShortcut.unregister('F12'); | ||
globalShortcut.unregister('F5'); | ||
uninstallDebugContextMenu(win); | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "electron-debug", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Adds useful debug features to your Electron app", | ||
@@ -16,6 +16,8 @@ "license": "MIT", | ||
"scripts": { | ||
"start": "electron test.js", | ||
"test": "xo" | ||
}, | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"context-menu.js" | ||
], | ||
@@ -30,2 +32,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"electron-prebuilt": "^0.34.1", | ||
"xo": "*" | ||
@@ -35,5 +38,6 @@ }, | ||
"globals": [ | ||
"atom" | ||
"atom", | ||
"window" | ||
] | ||
} | ||
} |
@@ -26,3 +26,7 @@ # electron-debug | ||
### Inspect element | ||
Right-click on an HTML element when DevTools is open to inspect it. | ||
## Install | ||
@@ -29,0 +33,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5470
5
83
59
2