diff --git a/source/background.js b/source/background.js deleted file mode 100644 index f7b838a..0000000 --- a/source/background.js +++ /dev/null @@ -1,275 +0,0 @@ -chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) -{ - // We only react on a complete load of a http(s) page, - // only then we're sure the content.js is loaded. - if (changeInfo.status !== "complete" || tab.url.indexOf("http") !== 0) - { - return; - } - - // Prep some variables - var ideKey = "XDEBUG_ECLIPSE", - match = true, - traceTrigger = ideKey, - profileTrigger = ideKey, - domain; - - // Check if localStorage is available and get the settings out of it - if (localStorage) - { - if (localStorage["xdebugIdeKey"]) - { - ideKey = localStorage["xdebugIdeKey"]; - } - - if (localStorage["xdebugTraceTrigger"]) - { - traceTrigger = localStorage["xdebugTraceTrigger"]; - } - - if (localStorage["xdebugProfileTrigger"]) - { - profileTrigger = localStorage["xdebugProfileTrigger"]; - } - } - - // Request the current status and update the icon accordingly - chrome.tabs.sendMessage( - tabId, - { - cmd: "getStatus", - idekey: ideKey, - traceTrigger: traceTrigger, - profileTrigger: profileTrigger - }, - function(response) - { - if (chrome.runtime.lastError) { - console.log("Error: ", chrome.runtime.lastError); - return; - } - - // Update the icon - updateIcon(response.status, tabId); - } - ); -}); - -chrome.commands.onCommand.addListener(function(command) -{ - if ('toggle_debug_action' == command) - { - var ideKey = "XDEBUG_ECLIPSE"; - var traceTrigger = ideKey; - var profileTrigger = ideKey; - - // Check if localStorage is available and get the settings out of it - if (localStorage) - { - if (localStorage["xdebugIdeKey"]) - { - ideKey = localStorage["xdebugIdeKey"]; - } - - if (localStorage["xdebugTraceTrigger"]) - { - traceTrigger = localStorage["xdebugTraceTrigger"]; - } - - if (localStorage["xdebugProfileTrigger"]) - { - profileTrigger = localStorage["xdebugProfileTrigger"]; - } - } - - // Fetch the active tab - chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs) - { - // Do nothing when there is no active tab atm - if (tabs.length == 0) { - return; - } - - // Get the current state - chrome.tabs.sendMessage( - tabs[0].id, - { - cmd: "getStatus", - idekey: ideKey, - traceTrigger: traceTrigger, - profileTrigger: profileTrigger - }, - function(response) - { - // Get new status by current status - const newStatus = getNewStatus(response.status); - - chrome.tabs.sendMessage( - tabs[0].id, - { - cmd: "setStatus", - status: newStatus, - idekey: ideKey, - traceTrigger: traceTrigger, - profileTrigger: profileTrigger - }, - function(response) - { - // Update the icon - updateIcon(response.status, tabs[0].id); - } - ); - } - ); - }); - } -}); - -// Will not be called, if popup is disabled, so not needed to wrap this in a if statement -chrome.browserAction.onClicked.addListener((tab) => { - var ideKey = "XDEBUG_ECLIPSE"; - var traceTrigger = ideKey; - var profileTrigger = ideKey; - - // Check if localStorage is available and get the settings out of it - if (localStorage) - { - if (localStorage["xdebugIdeKey"]) - { - ideKey = localStorage["xdebugIdeKey"]; - } - - if (localStorage["xdebugTraceTrigger"]) - { - traceTrigger = localStorage["xdebugTraceTrigger"]; - } - - if (localStorage["xdebugProfileTrigger"]) - { - profileTrigger = localStorage["xdebugProfileTrigger"]; - } - } - - // Get the current state - chrome.tabs.sendMessage( - tab.id, - { - cmd: "getStatus", - idekey: ideKey, - traceTrigger: traceTrigger, - profileTrigger: profileTrigger - }, - function(response) - { - // Get new status by current status - const newStatus = getNewStatus(response.status); - - chrome.tabs.sendMessage( - tab.id, - { - cmd: "setStatus", - status: newStatus, - idekey: ideKey, - traceTrigger: traceTrigger, - profileTrigger: profileTrigger - }, - function(response) - { - // Update the icon - updateIcon(response.status, tab.id); - } - ); - } - ); -}); - -/** - * Get new status by current status. - * - * @param {number} status - Current status from sendMessage() cmd: 'getStatus'. - * - * @returns {number} - */ -function getNewStatus(status) { - // Reset status, when trace or profile is selected and popup is disabled - if ((localStorage.xdebugDisablePopup === '1') - && ((status === 2) || (status === 3)) - ) { - return 0; - } - - // If state is debugging (1) toggle to disabled (0), else toggle to debugging - return (status === 1) ? 0 : 1; -} - -function updateIcon(status, tabId) -{ - // Reset status, when trace or profile is selected and popup is disabled - if ((localStorage.xdebugDisablePopup === '1') - && ((status === 2) || (status === 3)) - ) { - status = 0; - } - - // Figure the correct title / image by the given state - let image = "images/bug-gray.png"; - let title = (localStorage.xdebugDisablePopup === '1') - ? 'Debugging disabled' : 'Debugging, profiling & tracing disabled'; - - if (status == 1) - { - title = "Debugging enabled"; - image = "images/bug.png"; - } - else if (status == 2) - { - title = "Profiling enabled"; - image = "images/clock.png"; - } - else if (status == 3) - { - title = "Tracing enabled"; - image = "images/script.png"; - } - - // Update title - chrome.browserAction.setTitle({ - tabId: tabId, - title: title - }); - - // Update image - chrome.browserAction.setIcon({ - tabId: tabId, - path: image - }); -} - -/** - * @deprecated - * @todo to remove silver - */ -function isValueInArray(arr, val) -{ - for (i = 0; i < arr.length; i++) - { - var re = new RegExp(arr[i], "gi"); - if (re.test(val)) - { - return true; - } - } - - return false; -} - -// Disable / Enable Popup by localStorage -if (localStorage.xdebugDisablePopup === '1') { - chrome.browserAction.setPopup({ - popup: '', - }); -} else { - chrome.browserAction.setPopup({ - popup: 'popup.html', - }); -} diff --git a/source/manifest.json b/source/manifest.json index 5bad042..b1fd04f 100644 --- a/source/manifest.json +++ b/source/manifest.json @@ -1,52 +1,54 @@ { - "name": "Xdebug helper", - "description": "Easy debugging, profiling and tracing extension for Xdebug", - "version": "1.6.1", - "author": "Mathijs Kadijk", - - "manifest_version": 2, - "minimum_chrome_version": "20", - "permissions": [ "tabs", "*://*/*" ], - "icons": { - "16": "images/icon--16.png", - "48": "images/icon--48.png", - "128": "images/icon--128.png", - "256": "images/icon--256.png", - "512": "images/icon--256.png" - }, - - "options_page": "options.html", - - "browser_action": { - "default_icon": "images/bug-gray.png", - "default_title": "Debugging, profiling & tracing disabled", - "default_popup" : "popup.html" - }, - "content_scripts": [ { - "js": [ "content.js" ], - "matches": [ "*://*/*" ] - } ], - "background": { - "scripts": [ "background.js" ], - "persistent": false - }, - - "commands": { - "_execute_browser_action": { - "suggested_key": { - "default": "Ctrl+Shift+X", - "windows": "Ctrl+Shift+X", - "mac": "Command+Shift+X" - }, - "description": "Open popup to toggle state" - }, - "toggle_debug_action": { - "suggested_key": { - "default": "Alt+Shift+X", - "windows": "Alt+Shift+X", - "mac": "Alt+Shift+X" - }, - "description": "Toggle between the debug states" - } - } + "name": "Xdebug helper", + "description": "Easy debugging, profiling and tracing extension for Xdebug", + "version": "1.6.1", + "author": "Mathijs Kadijk (and Wikando)", + "manifest_version": 3, + "minimum_chrome_version": "20", + "permissions": [ + "tabs", + "storage" + ], + "icons": { + "16": "images/icon--16.png", + "48": "images/icon--48.png", + "128": "images/icon--128.png", + "256": "images/icon--256.png", + "512": "images/icon--256.png" + }, + "options_page": "options.html", + "content_scripts": [ + { + "js": [ + "content.js" + ], + "matches": [ + "*://*/*" + ] + } + ], + "background": { + "service_worker": "service_worker.js" + }, + "commands": { + "toggle_debug_action": { + "suggested_key": { + "default": "Alt+Shift+X", + "windows": "Alt+Shift+X", + "mac": "Alt+Shift+X" + }, + "description": "Toggle between the debug states" + } + }, + "action": { + "default_icon": "images/bug-gray.png", + "default_title": "Debugging, profiling & tracing disabled", + "default_popup": "popup.html" + }, + "content_security_policy": { + "extension_pages": "script-src 'self'; object-src 'self'" + }, + "host_permissions": [ + "*://*/*" + ] } diff --git a/source/options.js b/source/options.js index 25258dd..fc68761 100644 --- a/source/options.js +++ b/source/options.js @@ -1,103 +1,90 @@ (function () { - // setTimeout() return value - let disablePopupTimeout; - - function save_options() - { - localStorage["xdebugIdeKey"] = document.getElementById("idekey").value; - localStorage["xdebugTraceTrigger"] = document.getElementById("tracetrigger").value; - localStorage["xdebugProfileTrigger"] = document.getElementById("profiletrigger").value; - localStorage.xdebugDisablePopup = document.getElementById('disable-popup').checked ? '1' : '0'; - } - - function restore_options() - { - // Restore IDE Key - idekey = localStorage["xdebugIdeKey"]; - - if (!idekey) - { - idekey = "XDEBUG_ECLIPSE"; - } - - if (idekey == "XDEBUG_ECLIPSE" || idekey == "netbeans-xdebug" || idekey == "macgdbp" || idekey == "PHPSTORM") - { - $("#ide").val(idekey); - $("#idekey").prop('disabled', true); - } - else - { - $("#ide").val("null"); - $("#idekey").prop('disabled', false); - } - $('#idekey').val(idekey); - - // Restore Trace Triggers - var traceTrigger = localStorage["xdebugTraceTrigger"]; - if (traceTrigger !== null) { - $("#tracetrigger").val(traceTrigger); - } else { - $("#tracetrigger").val(null); - } - - // Restore Profile Triggers - var profileTrigger = localStorage["xdebugProfileTrigger"]; - if (profileTrigger !== null) { - $("#profiletrigger").val(profileTrigger); - } else { - $("#profiletrigger").val(null); - } - - // Restore Disable Popup - document.getElementById('disable-popup').checked = (localStorage.xdebugDisablePopup === '1') ? true : false; - } - - $(function() - { - $("#ide").change(function () - { - if ($("#ide").val() != "null") - { - $("#idekey").prop('disabled', true); - $("#idekey").val($("#ide").val()); - - save_options(); - } - else - { - $("#idekey").prop('disabled', false); - } - }); - - $("#idekey").change(save_options); - - // Persist Disable Popup on onChange event - $('#disable-popup').change(disablePopupChanged); - - $('.save-button').click(save_options); - - restore_options(); - }); - - /** - * Disable Popup checkbox changed, persist it. - */ - function disablePopupChanged() { - const $disablePopupSaved = $('.disable-popup-saved'); - - $disablePopupSaved.addClass('show'); - - // First clear interval - clearInterval(disablePopupTimeout); - // Hide after 2 seconds - disablePopupTimeout = setTimeout(() => $disablePopupSaved.removeClass('show'), 2000); - - // Persist - save_options(); - - // We need to reload the extension, because to hide the popup - chrome.extension.getBackgroundPage().window.location.reload(true); - } + // Timeout value for disable-popup message. + let disablePopupTimeout; + + function save_options() { + // Build the settings object from the current form values. + var options = { + xdebugIdeKey: document.getElementById("idekey").value, + xdebugTraceTrigger: document.getElementById("tracetrigger").value, + xdebugProfileTrigger: document.getElementById("profiletrigger").value, + xdebugDisablePopup: document.getElementById('disable-popup').checked ? '1' : '0' + }; + // Save settings using chrome.storage.local.set. + chrome.storage.local.set(options, function() { + console.log("Options saved."); + }); + } + + function restore_options() { + // Retrieve stored settings. + chrome.storage.local.get( + ["xdebugIdeKey", "xdebugTraceTrigger", "xdebugProfileTrigger", "xdebugDisablePopup"], + function(data) { + var idekey = data.xdebugIdeKey || "XDEBUG_ECLIPSE"; + + if (idekey === "XDEBUG_ECLIPSE" || idekey === "netbeans-xdebug" || + idekey === "macgdbp" || idekey === "PHPSTORM") { + $("#ide").val(idekey); + $("#idekey").prop('disabled', true); + } else { + $("#ide").val("null"); + $("#idekey").prop('disabled', false); + } + $('#idekey').val(idekey); + + // Restore Trace Trigger. + var traceTrigger = data.xdebugTraceTrigger; + $("#tracetrigger").val((traceTrigger !== undefined && traceTrigger !== null) ? traceTrigger : ""); + + // Restore Profile Trigger. + var profileTrigger = data.xdebugProfileTrigger; + $("#profiletrigger").val((profileTrigger !== undefined && profileTrigger !== null) ? profileTrigger : ""); + + // Restore Disable Popup checkbox state. + document.getElementById('disable-popup').checked = (data.xdebugDisablePopup === '1'); + } + ); + } + + $(function() { + // Handler for the IDE selection. + $("#ide").change(function () { + if ($("#ide").val() != "null") { + $("#idekey").prop('disabled', true); + $("#idekey").val($("#ide").val()); + save_options(); + } else { + $("#idekey").prop('disabled', false); + } + }); + + $("#idekey").change(save_options); + + // Persist Disable Popup on change event. + $('#disable-popup').change(disablePopupChanged); + + $('.save-button').click(save_options); + + restore_options(); + }); + + /** + * Handler for when the Disable Popup checkbox changes. + */ + function disablePopupChanged() { + const $disablePopupSaved = $('.disable-popup-saved'); + $disablePopupSaved.addClass('show'); + + clearTimeout(disablePopupTimeout); + disablePopupTimeout = setTimeout(() => $disablePopupSaved.removeClass('show'), 2000); + + // Persist the new setting. + save_options(); + + // Reload the extension; in MV3, background pages are service workers. + chrome.runtime.reload(); + } })(); diff --git a/source/popup.js b/source/popup.js index 13d247a..d2b28a9 100644 --- a/source/popup.js +++ b/source/popup.js @@ -1,109 +1,83 @@ $(function() { - var ideKey = "XDEBUG_ECLIPSE"; - var traceTrigger = ideKey; - var profileTrigger = ideKey; + // Retrieve settings from chrome.storage.local + chrome.storage.local.get(["xdebugIdeKey", "xdebugTraceTrigger", "xdebugProfileTrigger"], function(data) { + var ideKey = data.xdebugIdeKey || "XDEBUG_ECLIPSE"; + var traceTrigger = data.xdebugTraceTrigger || ideKey; + var profileTrigger = data.xdebugProfileTrigger || ideKey; - // Check if localStorage is available and get the ideKey out of it if any - if (localStorage) - { - if (localStorage["xdebugIdeKey"]) - { - ideKey = localStorage["xdebugIdeKey"]; - } + // Request the current state from the active tab + chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs) { + chrome.tabs.sendMessage( + tabs[0].id, + { + cmd: "getStatus", + idekey: ideKey, + traceTrigger: traceTrigger, + profileTrigger: profileTrigger + }, + function(response) { + // Highlight the correct option based on the received status + $('a[data-status="' + response.status + '"]').addClass("active"); + } + ); + }); - if (localStorage["xdebugTraceTrigger"]) - { - traceTrigger = localStorage["xdebugTraceTrigger"]; - } + // Attach click handler for each option + $("a").on("click", function(eventObject) { + var newStatus = $(this).data("status"); - if (localStorage["xdebugProfileTrigger"]) - { - profileTrigger = localStorage["xdebugProfileTrigger"]; - } - } + // Set the new state on the active tab + chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs) { + chrome.tabs.sendMessage( + tabs[0].id, + { + cmd: "setStatus", + status: newStatus, + idekey: ideKey, + traceTrigger: traceTrigger, + profileTrigger: profileTrigger + }, + function(response) { + // Instead of using getBackgroundPage (not available in MV3), + // send a message to the background service worker to update the icon. + chrome.runtime.sendMessage( + { cmd: "updateIcon", status: response.status, tabId: tabs[0].id }, + function() { + window.close(); + } + ); + } + ); + }); + }); + }); - // Request the current state from the active tab - chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs) - { - chrome.tabs.sendMessage( - tabs[0].id, - { - cmd: "getStatus", - idekey: ideKey, - traceTrigger: traceTrigger, - profileTrigger: profileTrigger - }, - function(response) - { - // Highlight the correct option - $('a[data-status="' + response.status + '"]').addClass("active"); - } - ); - }); + // Shortcuts + key("d", function() { $("#action-debug").click(); }); + key("p", function() { $("#action-profile").click(); }); + key("t", function() { $("#action-trace").click(); }); + key("s", function() { $("#action-disable").click(); }); + key("space,enter", function() { $("a:focus").click(); }); + key("down,right", function() { + var current = $(".action:focus"); + if (current.length === 0) { + $(".action:first").focus(); + } else { + current.parent().next().find("a").focus(); + } + }); + key("up,left", function() { + var current = $(".action:focus"); + if (current.length === 0) { + $(".action:last").focus(); + } else { + current.parent().prev().find("a").focus(); + } + }); - // Attach handler when user clicks on - $("a").on("click", function(eventObject) { - var newStatus = $(this).data("status"); - - // Set the new state on the active tab - chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs) - { - chrome.tabs.sendMessage( - tabs[0].id, - { - cmd: "setStatus", - status: newStatus, - idekey: ideKey, - traceTrigger : traceTrigger, - profileTrigger : profileTrigger - }, - function(response) - { - // Make the backgroundpage update the icon and close the popup - chrome.runtime.getBackgroundPage(function(backgroundPage) { - backgroundPage.updateIcon(response.status, tabs[0].id); - window.close(); - }); - } - ); - }); - }); - - // Shortcuts - key("d", function() { $("#action-debug").click(); }); - key("p", function() { $("#action-profile").click(); }); - key("t", function() { $("#action-trace").click(); }); - key("s", function() { $("#action-disable").click(); }); - key("space,enter", function() { $("a:focus").click(); }); - key("down,right", function() - { - var current = $(".action:focus"); - if (current.length === 0) - { - $(".action:first").focus(); - } - else - { - current.parent().next().find("a").focus(); - } - }); - key("up,left", function() - { - var current = $(".action:focus"); - if (current.length === 0) - { - $(".action:last").focus(); - } - else - { - current.parent().prev().find("a").focus(); - } - }); - - // Bit of a hack to prevent Chrome from focussing the first option automaticly - $("a").on("focus", function() - { - $(this).blur(); - $("a").off("focus"); - }); + // Prevent Chrome from automatically focusing the first option + $("a").on("focus", function() { + $(this).blur(); + $("a").off("focus"); + }); }); diff --git a/source/service_worker.js b/source/service_worker.js new file mode 100644 index 0000000..1c0b56a --- /dev/null +++ b/source/service_worker.js @@ -0,0 +1,215 @@ +function getSettings(callback) { + chrome.storage.local.get( + ["xdebugIdeKey", "xdebugTraceTrigger", "xdebugProfileTrigger", "xdebugDisablePopup"], + function(data) { + callback({ + ideKey: data.xdebugIdeKey || "XDEBUG_ECLIPSE", + traceTrigger: data.xdebugTraceTrigger || "XDEBUG_ECLIPSE", + profileTrigger: data.xdebugProfileTrigger || "XDEBUG_ECLIPSE", + disablePopup: data.xdebugDisablePopup || "0" + }); + } + ); +} + +chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) +{ + // We only react on a complete load of a http(s) page, + // only then we're sure the content.js is loaded. + if (changeInfo.status !== "complete" || tab.url.indexOf("http") !== 0) + { + return; + } + + // Asynchronously retrieve settings from chrome.storage.local + getSettings(function(settings) { + var ideKey = settings.ideKey, + traceTrigger = settings.traceTrigger, + profileTrigger = settings.profileTrigger; + + chrome.tabs.sendMessage( + tabId, + { + cmd: "getStatus", + idekey: ideKey, + traceTrigger: traceTrigger, + profileTrigger: profileTrigger + }, + function(response) { + if (chrome.runtime.lastError) { + console.log("Error: ", chrome.runtime.lastError); + return; + } + updateIcon(response.status, tabId); + } + ); + }); +}); + +chrome.commands.onCommand.addListener(function(command) { + if (command === "toggle_debug_action") { + // Use getSettings to retrieve stored values. + getSettings(function(settings) { + chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function(tabs) { + if (tabs.length === 0) { + return; + } + chrome.tabs.sendMessage( + tabs[0].id, + { + cmd: "getStatus", + idekey: settings.ideKey, + traceTrigger: settings.traceTrigger, + profileTrigger: settings.profileTrigger + }, + function(response) { + if (chrome.runtime.lastError) { + console.log("Error: ", chrome.runtime.lastError); + return; + } + // Pass disablePopup to getNewStatus. + const newStatus = getNewStatus(response.status, settings.disablePopup); + chrome.tabs.sendMessage( + tabs[0].id, + { + cmd: "setStatus", + status: newStatus, + idekey: settings.ideKey, + traceTrigger: settings.traceTrigger, + profileTrigger: settings.profileTrigger + }, + function(response) { + if (chrome.runtime.lastError) { + console.log("Error: ", chrome.runtime.lastError); + return; + } + updateIcon(response.status, tabs[0].id); + } + ); + } + ); + }); + }); + } +}); + +// Will not be called, if popup is disabled, so not needed to wrap this in a if statement +chrome.action.onClicked.addListener((tab) => { + getSettings(function(settings) { + chrome.tabs.sendMessage( + tab.id, + { + cmd: "getStatus", + idekey: settings.ideKey, + traceTrigger: settings.traceTrigger, + profileTrigger: settings.profileTrigger + }, + function(response) { + if (chrome.runtime.lastError) { + console.log("Error: ", chrome.runtime.lastError); + return; + } + const newStatus = getNewStatus(response.status, settings.disablePopup); + chrome.tabs.sendMessage( + tab.id, + { + cmd: "setStatus", + status: newStatus, + idekey: settings.ideKey, + traceTrigger: settings.traceTrigger, + profileTrigger: settings.profileTrigger + }, + function(response) { + if (chrome.runtime.lastError) { + console.log("Error: ", chrome.runtime.lastError); + return; + } + updateIcon(response.status, tab.id); + } + ); + } + ); + }); +}); + +chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { + if (message.cmd === "updateIcon") { + updateIcon(message.status, message.tabId); + } +}); + +/** + * Get new status by current status. + * + * @param {number} status - Current status from sendMessage() cmd: 'getStatus'. + * @param {string} disablePopup - The disablePopup flag from settings. + * @returns {number} + */ +function getNewStatus(status, disablePopup) { + // Reset status when popup is disabled and trace or profile is selected. + if (disablePopup === '1' && ((status === 2) || (status === 3))) { + return 0; + } + return (status === 1) ? 0 : 1; +} + +function updateIcon(status, tabId) { + // Retrieve settings before updating the icon. + getSettings(function(settings) { + if (settings.disablePopup === '1' && ((status === 2) || (status === 3))) { + status = 0; + } + + let image = "images/bug-gray.png"; + let title = (settings.disablePopup === '1') + ? 'Debugging disabled' + : 'Debugging, profiling & tracing disabled'; + + if (status === 1) { + title = "Debugging enabled"; + image = "images/bug.png"; + } else if (status === 2) { + title = "Profiling enabled"; + image = "images/clock.png"; + } else if (status === 3) { + title = "Tracing enabled"; + image = "images/script.png"; + } + + // Update title and icon using chrome.action instead of chrome.browserAction. + chrome.action.setTitle({ + tabId: tabId, + title: title + }); + chrome.action.setIcon({ + tabId: tabId, + path: image + }); + }); +} + +/** + * @deprecated + * @todo to remove silver + */ +function isValueInArray(arr, val) { + for (let i = 0; i < arr.length; i++) { + var re = new RegExp(arr[i], "gi"); + if (re.test(val)) { + return true; + } + } + return false; +} + +getSettings(function(settings) { + if (settings.disablePopup === '1') { + chrome.action.setPopup({ + popup: '' + }); + } else { + chrome.action.setPopup({ + popup: 'popup.html' + }); + } +});