diff --git a/proxy/init-badge.js b/proxy/init-badge.js index 30c0218..09579e6 100644 --- a/proxy/init-badge.js +++ b/proxy/init-badge.js @@ -63,14 +63,18 @@ var snowflake, query, debug, silenceNotifications, log, dbg, init; // Notification of closing tab with active proxy. window.onbeforeunload = function() { - if (!silenceNotifications && Snowflake.MODE.WEBRTC_READY === snowflake.state) { + if ( + !silenceNotifications && + snowflake !== null && + Snowflake.MODE.WEBRTC_READY === snowflake.state + ) { return Snowflake.MESSAGE.CONFIRMATION; } return null; }; window.onunload = function() { - snowflake.disable(); + if (snowflake !== null) { snowflake.disable(); } return null; }; diff --git a/proxy/init-webext.js b/proxy/init-webext.js index 3a2b120..ee755c6 100644 --- a/proxy/init-webext.js +++ b/proxy/init-webext.js @@ -61,14 +61,18 @@ var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotific // Notification of closing tab with active proxy. window.onbeforeunload = function() { - if (!silenceNotifications && Snowflake.MODE.WEBRTC_READY === snowflake.state) { + if ( + !silenceNotifications && + snowflake !== null && + Snowflake.MODE.WEBRTC_READY === snowflake.state + ) { return Snowflake.MESSAGE.CONFIRMATION; } return null; }; window.onunload = function() { - snowflake.disable(); + if (snowflake !== null) { snowflake.disable(); } return null; };