var CLIPBOARD_FILE = "clipboard.txt";
var NOTIFICATION_ID = "clipSync_notification";
var STORAGE_KEY = "clipSync_clipboard";

/**
 * Saves given content to file sync
 * @param content String content to publishs
 */
function sendClipboard(content) {
    console.log("Saving clipboard content: " + content);
    chrome.storage.sync.set({STORAGE_KEY: content}, function() {
        if (chrome.runtime.lastError) {
            console.log("Error saving clipboard content: " + chrome.runtime.lastError.message);
            return;
        }
        // Notify that we saved.
        console.log('Saved clipboard content');
    });
}

/**
 * Retrieves clipboard content
 * @param callback Callback function to accept retrieved content
 */
function getClipboardContent(callback) {
    console.log("Retrieving content from clipboard");
    var sandbox = document.getElementById("sandbox");
    var result = '';
    sandbox.select();
    if (document.execCommand("paste")) {
        result = sandbox.value;
        console.log("Retrieved data from clipboard: " + result);
    } else {
        console.log("Error pasting clipboard");
    }
    sandbox.value = '';
    callback(result);
}

chrome.browserAction.onClicked.addListener(function(tab) {
    console.log("Extension activated");
    getClipboardContent(function(content) {
        sendClipboard(content);
    })
});

function showNewContentNotification(content) {
    console.log("Showing new content notification");
    var options = {
        type: "basic",
        title: "New ClipSync content!",
        message: content,
        iconUrl: "icon.png"
    };
    chrome.notifications.clear(NOTIFICATION_ID, function() {
        chrome.notifications.create(NOTIFICATION_ID, options);
    });
}

chrome.storage.onChanged.addListener(function(changes, namespace) {
    console.log("Storage change detected");
    if (changes[STORAGE_KEY]) {
        var change = changes[STORAGE_KEY];
        showNewContentNotification(change.newValue);
    }
});
@@ -1797,16 +1797,15 @@
 es, 
-namespac
+areaNam
 e) %7B
@@ -1857,20 +1857,69 @@
     
-if (
+console.log(changes);%0A    if (areaName === %22sync%22 && 
 changes
-%5B
+.
 STOR
@@ -1925,17 +1925,16 @@
 RAGE_KEY
-%5D
 ) %7B%0A    
@@ -1961,9 +1961,9 @@
 nges
-%5B
+.
 STOR
@@ -1973,9 +1973,8 @@
 _KEY
-%5D
 ;%0A  

Fix storage change listener