return name.replace(/[\W_]+/g, '-').toLowerCase()
}
+const isWindowOrWebView = function (webContents) {
+ const type = webContents.getType()
+ return type === 'window' || type === 'webview'
+}
+
// Create or get manifest object from |srcDirectory|.
const getManifestFromPath = function (srcDirectory) {
let manifest
}
app.on('web-contents-created', function (event, webContents) {
- if (webContents.getType() === 'remote') return
+ if (!isWindowOrWebView(webContents)) return
hookWebContentsForTabEvents(webContents)
webContents.on('devtools-opened', function () {
const manifest = getManifestFromPath(srcDirectory)
if (manifest) {
for (const webContents of getAllWebContents()) {
- if (webContents.getType() !== 'remote') {
+ if (isWindowOrWebView(webContents)) {
loadDevToolsExtensions(webContents, [manifest])
}
}