Skip to content

Instantly share code, notes, and snippets.

@travisjeffery
Created November 8, 2008 11:48
Show Gist options
  • Save travisjeffery/23061 to your computer and use it in GitHub Desktop.
Save travisjeffery/23061 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "delicious",
icon: "http://delicious.com/favicon.ico",
author: {
name: "Travis Jeffery",
email: "eatsleepgolf@gmail.com"
},
license: "GPL",
description: "Post to Delicious.",
help: "Select the command press space and insert all the tags you want.",
takes: {
"tags": noun_arb_text
},
preview: function(pblock, tags) {
document = context.focusedWindow.document;
pblock.innerHTML = "url: " + document.location + "<br />" +
"description: " + document.title + "<br />" +
"tags: " + tags.text;
},
execute: function(tags) {
var document = context.focusedWindow.document;
var params = {
url: document.location,
description: document.title,
tags: tags.text
};
var url = "https://api.del.icio.us/v1/posts/add?";
var http = new XMLHttpRequest();
for (key in params) {
url += "&" + key + "=" + params[key];
}
http.open("POST", url, true);
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.send(params);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment