From 54f06b0ba95fed5726396ac28471972e07b426e1 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Fri, 1 Jul 2016 23:12:06 +1200 Subject: [PATCH] Override the Notification API constructor to create silent notifications when the webContents is muted --- lib/renderer/override.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/renderer/override.js b/lib/renderer/override.js index c568388..fb81c24 100644 --- a/lib/renderer/override.js +++ b/lib/renderer/override.js @@ -248,3 +248,14 @@ Object.defineProperty(document, 'visibilityState', { return cachedVisibilityState } }) + +// Make notifications silent if the the current webContents is muted +const NativeNotification = window.Notification +class Notification extends NativeNotification { + constructor (title, opts) { + super(title, Object.assign({ + silent: remote.getCurrentWebContents().isAudioMuted() + }, opts)) + } +} +window.Notification = Notification -- 2.7.4