From 7b8e29e346bd55458626bdbd0d23c82a7ed1f0b9 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Thu, 28 Jan 2021 22:01:01 +0100 Subject: [PATCH] Notify's don't occur when loading the mod #495 --- CookieMonster.js | 9 ++++++--- src/Disp.js | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index cfece1b0..901161a3 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -2178,7 +2178,8 @@ CM.Disp.CreateWhiteScreen = function() { * @param {string} config The setting in CM.Options that is checked before creating the flash */ CM.Disp.Flash = function(mode, config) { - if ((CM.Options[config] == 1 && mode == 3) || mode == 1) { + // The arguments check makes the sound not play upon initialization of the mod + if ((CM.Options[config] == 1 && mode == 3 && arguments.callee.caller.caller.caller.caller == null) || mode == 1) { CM.Disp.WhiteScreen.style.opacity = '0.5'; if (mode == 3) { CM.Disp.WhiteScreen.style.display = 'inline'; @@ -2203,7 +2204,8 @@ CM.Disp.Flash = function(mode, config) { * @param {string} volConfig The setting in CM.Options that is checked to determine volume */ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { - if (CM.Options[sndConfig] == 1) { + // The arguments check makes the sound not play upon initialization of the mod + if (CM.Options[sndConfig] == 1 && arguments.callee.caller.caller.caller.caller == null) { var sound = new realAudio(url); sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.play(); @@ -2218,7 +2220,8 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { * @param {string} message The text of the to-be created notifications */ CM.Disp.Notification = function(notifyConfig, title, message) { - if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden') { + // The arguments check makes the sound not play upon initialization of the mod + if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && arguments.callee.caller.caller.caller.caller == null) { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico' notification = new Notification(title, {body: message, badge: CookieIcon}); } diff --git a/src/Disp.js b/src/Disp.js index 2e10ea6d..23e689f6 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -966,7 +966,8 @@ CM.Disp.CreateWhiteScreen = function() { * @param {string} config The setting in CM.Options that is checked before creating the flash */ CM.Disp.Flash = function(mode, config) { - if ((CM.Options[config] == 1 && mode == 3) || mode == 1) { + // The arguments check makes the sound not play upon initialization of the mod + if ((CM.Options[config] == 1 && mode == 3 && arguments.callee.caller.caller.caller.caller == null) || mode == 1) { CM.Disp.WhiteScreen.style.opacity = '0.5'; if (mode == 3) { CM.Disp.WhiteScreen.style.display = 'inline'; @@ -991,7 +992,8 @@ CM.Disp.Flash = function(mode, config) { * @param {string} volConfig The setting in CM.Options that is checked to determine volume */ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { - if (CM.Options[sndConfig] == 1) { + // The arguments check makes the sound not play upon initialization of the mod + if (CM.Options[sndConfig] == 1 && arguments.callee.caller.caller.caller.caller == null) { var sound = new realAudio(url); sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.play(); @@ -1006,7 +1008,8 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { * @param {string} message The text of the to-be created notifications */ CM.Disp.Notification = function(notifyConfig, title, message) { - if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden') { + // The arguments check makes the sound not play upon initialization of the mod + if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && arguments.callee.caller.caller.caller.caller == null) { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico' notification = new Notification(title, {body: message, badge: CookieIcon}); }