diff --git a/js/background_scripts/background.js b/js/background_scripts/background.js index bdb5c73..7b0902d 100755 --- a/js/background_scripts/background.js +++ b/js/background_scripts/background.js @@ -65,6 +65,9 @@ chrome.runtime.onMessage.addListener( case 'setLogging': debugLogsEnabled = request.enable; break; + default: + if (debugLogsEnabled) console.log("Unexpected message received: " + JSON.stringify(request)); + return false; } return true; diff --git a/js/remote.js b/js/remote.js index 50be62e..2dacc0d 100755 --- a/js/remote.js +++ b/js/remote.js @@ -464,7 +464,9 @@ function getEmbeddedVideos(callback) { chrome.tabs.query({active: true,lastFocusedWindow: true}, function (tab) { tab = tab[0]; chrome.tabs.sendMessage(tab.id, {action: 'getEmbeddedVideos'}, function (response) { - if (response && response.length > 0) { + if (chrome.runtime.lastError) { + if (isDebugLogsEnabled()) console.log(`sendMessage failed to tab.id: ${tab.id}, tab.url: ${tab.url}, msg: ${chrome.runtime.lastError}`); + } else if (response && response.length > 0) { callback(response); } }); diff --git a/js/xbmc-helper.js b/js/xbmc-helper.js index e6f8186..778b3ab 100755 --- a/js/xbmc-helper.js +++ b/js/xbmc-helper.js @@ -174,7 +174,9 @@ function validVideoPage(url, callback) { chrome.tabs.query({active: true,lastFocusedWindow: true}, function (tab) { tab = tab[0]; chrome.tabs.sendMessage(tab.id, {action: 'isValid'}, function (response) { - if (response) { + if (chrome.runtime.lastError) { + if (debugLogsEnabled) console.log(`sendMessage failed to tab.id: ${tab.id}, tab.url: ${tab.url}, msg: ${chrome.runtime.lastError}`); + } else if (response) { callback(); } });