Notify's don't occur when loading the mod #495

This commit is contained in:
Daniel van Noord
2021-01-28 22:01:01 +01:00
parent b3757c452a
commit 7b8e29e346
2 changed files with 12 additions and 6 deletions

View File

@@ -2178,7 +2178,8 @@ CM.Disp.CreateWhiteScreen = function() {
* @param {string} config The setting in CM.Options that is checked before creating the flash * @param {string} config The setting in CM.Options that is checked before creating the flash
*/ */
CM.Disp.Flash = function(mode, config) { 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'; CM.Disp.WhiteScreen.style.opacity = '0.5';
if (mode == 3) { if (mode == 3) {
CM.Disp.WhiteScreen.style.display = 'inline'; 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 * @param {string} volConfig The setting in CM.Options that is checked to determine volume
*/ */
CM.Disp.PlaySound = function(url, sndConfig, volConfig) { 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); var sound = new realAudio(url);
sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100);
sound.play(); sound.play();
@@ -2218,7 +2220,8 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) {
* @param {string} message The text of the to-be created notifications * @param {string} message The text of the to-be created notifications
*/ */
CM.Disp.Notification = function(notifyConfig, title, message) { 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' var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'
notification = new Notification(title, {body: message, badge: CookieIcon}); notification = new Notification(title, {body: message, badge: CookieIcon});
} }

View File

@@ -966,7 +966,8 @@ CM.Disp.CreateWhiteScreen = function() {
* @param {string} config The setting in CM.Options that is checked before creating the flash * @param {string} config The setting in CM.Options that is checked before creating the flash
*/ */
CM.Disp.Flash = function(mode, config) { 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'; CM.Disp.WhiteScreen.style.opacity = '0.5';
if (mode == 3) { if (mode == 3) {
CM.Disp.WhiteScreen.style.display = 'inline'; 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 * @param {string} volConfig The setting in CM.Options that is checked to determine volume
*/ */
CM.Disp.PlaySound = function(url, sndConfig, volConfig) { 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); var sound = new realAudio(url);
sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100);
sound.play(); sound.play();
@@ -1006,7 +1008,8 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) {
* @param {string} message The text of the to-be created notifications * @param {string} message The text of the to-be created notifications
*/ */
CM.Disp.Notification = function(notifyConfig, title, message) { 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' var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'
notification = new Notification(title, {body: message, badge: CookieIcon}); notification = new Notification(title, {body: message, badge: CookieIcon});
} }