forked from travisjeffery/vimperator-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdelicious.js
More file actions
22 lines (19 loc) · 1.17 KB
/
Copy pathdelicious.js
File metadata and controls
22 lines (19 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Vimperator Plugin: 'Delicious'
// Last Change: 22-Apr-2009
// License: MIT
// Maintainer: Travis Jeffery <[email protected]>
// Usage: Use :delicious <tags delimited by spaces> command
// Usage: if successfully posted you will see "done" echoed
commands.addUserCommand(['delicious'], "Save page as a bookmark on Delicious",
function(args) {
var url = "https://api.del.icio.us/v1/posts/add?";
url += "&url=" + encodeURIComponent(buffer.URL);
url += "&description=" + encodeURIComponent(buffer.title);
url += "&tags=" + encodeURIComponent(args.string);
var xhr = new XMLHttpRequest();
xhr.open("POST", url, false);
xhr.send(null);
var xml = (new DOMParser()).parseFromString(xhr.responseText, "text/xml");
var status = xml.getElementsByTagName('result')[0].getAttribute('code');
liberator.echo(status);
});