{
"name": "Delicious plugin", // 1
"version": "0.2", // 2
"background_page": "background.html", // 3
"permissions": [ // 4
"bookmarks",
"tabs"
],
“browser_action”: { // 5
“name”: “Save bookmark to delicious.com”,
“default_title”: “Save bookmark to delicious.com”,
“default_icon”: “delicious.20.gif” // optional
},
“content_scripts”: [ // 6
{
“matches”: [“http:///”, “https:///”],
“js”: [“getDocumentSelection.js”]
}
],
“options_page”: “options.html” // 7
}
<html>
<head>
<script type="text/javascript">
    function saveBookmark() {
        // Send our password to the current tab when clicked.
        chrome.tabs.getSelected(null, function(tab) {
            var port = chrome.tabs.connect(tab.id, {
                name : "deliciousBookmark"
            });
            port.postMessage( {
                action : 'getSelection'
            });
        });
    }
    function addBookmark(id, bookmark) {
        console.log("added bookmark:  " + bookmark);
        saveBookmark();
    }
    chrome.bookmarks.onCreated.addListener(addBookmark);
    console.log("Registered listener");
    function getShareStatus() {
        var markPrivate = localStorage["markPrivate"];
        var share = "yes";
        if (markPrivate == "true") {
            share = "no";
        }
        return share;
    }
    chrome.extension.onConnect.addListener(function(port) {
        console.assert(port.name == "deliciousBookmark");
        port.onMessage.addListener(function(msg) {
            var selection = msg.selection;
            chrome.tabs.getSelected(null, function(tab) {
                var url = encodeURIComponent(tab.url);
                if (!url || url === "") {
                    return;
                }
                var title = encodeURIComponent(tab.title);
                var description = encodeURIComponent(selection);
                var share = getShareStatus();
                var f = ‘http://delicious.com/save?url=' + url + '&title=' + title + '&notes=' + description
                        + ’&share=’ + share + ’&v=5&’;
                window.open(f + ’noui=1&jump=doclose’, ‘deliciousuiv5’,
                        ’location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550’);
            });
        });
    });
    chrome.browserAction.onClicked.addListener(saveBookmark);
</script>
</head>
</html>
var port = chrome.extension.connect( {
name : "deliciousBookmark"
});
// Also listen for new channels from the extension for when the button is
// pressed.
chrome.extension.onConnect.addListener(function(port) {
console.assert(port.name == "deliciousBookmark");
port.onMessage.addListener(function(msg) {
if (msg.action == 'getSelection') {
var responsePort = chrome.extension.connect( {
name : "deliciousBookmark"
});
var description = document.getSelection() ? '' + document.getSelection() : '';
responsePort.postMessage( {
selection : description
});
}
});
});
<html>
<html>
<head>
<title>Delicious Bookmarks Options</title>
</head>
<script type="text/javascript">
    // Saves options to localStorage.
    function saveOptions() {
        var share = document.getElementById("share");
        localStorage["markPrivate"] = share.checked;
    // Update status to let user know options were saved.
    var status = document.getElementById("status");
    status.innerHTML = "Options Saved.";
    setTimeout(function() {
        status.innerHTML = "";
    }, 1500);
}
// Restores select box state to saved value from localStorage.
function restoreOptions() {
    var share = localStorage["markPrivate"];
    if (!share) {
        return;
    }
    var shareCheckbox = document.getElementById("share");
    shareCheckbox.checked = share;
    
}
</script>
<body onload="restoreOptions()">
<label for="share">Mark as Private</label>
<input type="checkbox" class="checkbox" name="share" id="share" />
<br>
<button onclick="saveOptions();">Save</button>
<div id="status"> </div>
</body>
</html>