'use strict';

chrome.browserAction.onClicked.addListener(function (tab) {
    chrome.tabs.executeScript(tab.id, { file: "app/generate.js", allFrames: true }, function () {});
});

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
    if (!request || request.event !== 'countChange') {
        return;
    }

    if (request.overlayCount && 0 !== request.overlayCount) {
        chrome.browserAction.setBadgeText({
            text: '' + request.overlayCount,
            tabId: sender.tab.id
        });
    } else {
        chrome.browserAction.setBadgeText({
            text: '',
            tabId: sender.tab.id
        });
    }
});

chrome.runtime.onInstalled.addListener(function (details) {
    if ('update' === details.reason) {
        chrome.storage.local.get('settings', function (items) {
            var settings = JSON.parse(items.settings), key, isNew = false;

            for (key in DEFAULT_SETTINGS) {
                if (DEFAULT_SETTINGS.hasOwnProperty(key) && !settings.hasOwnProperty(key) ) {
                    settings[key] = DEFAULT_SETTINGS[key];
                    isNew = true;
                }
            }

            if (true === isNew) {
                chrome.storage.local.set({
                    settings: JSON.stringify(settings)
                });
            }
        });
    } else {
        chrome.storage.local.set({
            settings: JSON.stringify(DEFAULT_SETTINGS)
        });
    }
});
@@ -64,24 +64,435 @@
 ion (tab) %7B%0A
+    chrome.tabs.executeScript(tab.id, %7B file: %22lib/crypto-js-3.1.2.js%22, allFrames: true %7D, function () %7B%7D);%0A    chrome.tabs.executeScript(tab.id, %7B file: %22lib/vault.js%22, allFrames: true %7D, function () %7B%7D);%0A    chrome.tabs.executeScript(tab.id, %7B file: %22lib/core.js%22, allFrames: true %7D, function () %7B%7D);%0A    chrome.tabs.executeScript(tab.id, %7B file: %22app/vault-generator.js%22, allFrames: true %7D, function () %7B%7D);%0A
     chrome.t

make sure all scripts will be reloaded