-
-
Save xbourn/76744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.CreateCommand({ | |
name: "r-douban", | |
homepage: "http://www.douban.com/people/aka/", | |
author: { name: "Yu Peng", email: "pengyu.py@gmail.com"}, | |
contributors: ["Yu Peng"], | |
license: "MPL", | |
description: "Recommend the current site to douban", | |
help: "posts the current tab url to douban with the comment input by the user.", | |
_params: function(comment,mods) { | |
var document = context.focusedWindow.document; | |
var params = { | |
uid: document.location, | |
title: (mods.entitled.text || document.title), | |
type: 'I', | |
comment: comment.text, | |
}; | |
return params; | |
}, | |
takes: {"comment": noun_arb_text}, | |
modifiers: {entitled: noun_arb_text}, | |
preview: function(pblock, comment, mods) { | |
var document = context.focusedWindow.document; | |
html = "title: " + (mods.entitled.text || document.title) + "<br />"; | |
html += "comment: " + comment.text; | |
pblock.innerHTML = html; | |
}, | |
execute: function(comment, mods) { | |
jQuery.ajax({ | |
type: "POST", | |
dataType: "xml", | |
url: "http://www.douban.com/recommend/", | |
data: this._params(comment, mods), | |
}); | |
} | |
}) | |
CmdUtils.CreateCommand({ | |
name: "s-douban", | |
homepage: "http://www.douban.com/people/aka/", | |
author: { name: "Yu Peng", email: "pengyu.py@gmail.com"}, | |
contributors: ["Yu Peng"], | |
license: "MPL", | |
description: "I say to douban", | |
help: "posts saying to douban", | |
takes: {"say": noun_arb_text}, | |
preview: function(pblock, say) { | |
html = "saying: " + say.text; | |
pblock.innerHTML = html; | |
}, | |
execute: function(say) { | |
jQuery.ajax({ | |
type: "POST", | |
dataType: "xml", | |
url: "http://www.douban.com/contacts/", | |
data: {'mb_text':say.text}, | |
}); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment