aboutsummaryrefslogtreecommitdiffstats
path: root/retweet.js
diff options
context:
space:
mode:
authoranekos2009-10-01 07:51:54 +0000
committeranekos2009-10-01 07:51:54 +0000
commit3a42e6918e5a5f0e0be2892e2d5809d3ebad8984 (patch)
treecde1be6b17ee8e199d34e858a24dfc3688cbb6a6 /retweet.js
parent5f5f4c51e989b0917b33acc4d85216a609258c5c (diff)
downloadvimperator-plugins-3a42e6918e5a5f0e0be2892e2d5809d3ebad8984.tar.bz2
XPath の修正&コメントを付加できるようにした
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@35490 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'retweet.js')
-rw-r--r--retweet.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/retweet.js b/retweet.js
index 3d9bbc9..0f5eb99 100644
--- a/retweet.js
+++ b/retweet.js
@@ -5,7 +5,7 @@ var PLUGIN_INFO =
<description>ReTweet This Page.</description>
<description lang="ja">開いているTweetをReTweetします。</description>
<author mail="from.kyushu.island@gmail.com" homepage="http://iddy.jp/profile/from_kyushu">from_kyushu</author>
- <version>0.2</version>
+ <version>0.3</version>
<license>GPL</license>
<minVersion>1.2</minVersion>
<maxVersion>2.1</maxVersion>
@@ -44,7 +44,7 @@ Usage:
function getUserName()
{
- return $U.getFirstNodeFromXPath("//div[@class='screen-name']/a").innerHTML;
+ return $U.getFirstNodeFromXPath('//a[contains(concat(" ",normalize-space(@class)," "),"screen-name")]').innerHTML;
}
function getShortenUrl(longUrl)
@@ -60,10 +60,11 @@ Usage:
return xhr.responseText;
}
- function sendTwitter(url,name,body)
+ function sendTwitter(url,name,body,comment)
{
var xhr = new XMLHttpRequest();
- var statusText = "RT @" + name + " [" + url +"]: " + body;
+ var statusText = (comment ? comment + " " : "") + "RT @" + name + " [" + url +"]: " + body;
+ return liberator.echo(statusText);
xhr.open("POST", "https://twitter.com/statuses/update.json", false, username, password);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("status=" + encodeURIComponent(statusText) + "&source=Vimperator");
@@ -74,7 +75,7 @@ Usage:
commands.addUserCommand(
['retweet[This]','rtt'],
'ReTweet This.',
- function()
+ function(args)
{
try
{
@@ -86,13 +87,13 @@ Usage:
{
username = logins[0].username;
password = logins[0].password;
- sendTwitter(url,name,body);
+ sendTwitter(url,name,body,args.literalArg);
}
else if(liberator.globalVariables.twitter_username && liberator.globalVariables.twitter_password)
{
username = liberator.globalVariables.twitter_username;
password = liberator.globalVariables.twitter_password;
- sendTwitter(url,name,body);
+ sendTwitter(url,name,body,args.literalArg);
}
else
{
@@ -103,7 +104,11 @@ Usage:
{
liberator.echoerr(e);
}
- }
+ },
+ {
+ literal: 0
+ },
+ true
);
}
)();