From e8c5a3ba7ed45b1a92b677ba6abe47a0b8382e8e Mon Sep 17 00:00:00 2001 From: trapezoid Date: Sun, 14 Sep 2008 09:16:24 +0000 Subject: browser_object.js: タブにpin操作ができるようにした git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19285 d0d07461-0603-4401-acd4-de1884942a52 --- twitter.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'twitter.js') diff --git a/twitter.js b/twitter.js index 7dfbf03..4cb165f 100644 --- a/twitter.js +++ b/twitter.js @@ -1,5 +1,5 @@ // Vimperator plugin: "Update Twitter" -// Last Change: 20-Jun-2008. Jan 2008 +// Last Change: 29-Aug-2008. Jan 2008 // License: Creative Commons // Maintainer: Trapezoid - http://unsigned.g.hatena.ne.jp/Trapezoid // @@ -137,6 +137,55 @@ .replace(/(?:\r?\n|\r)[ \t]*/g, " "); liberator.echo(html, true); } + var services = { + 'twitter': { + description:'Twitter', + account:['https://www.hatena.ne.jp', 'https://www.hatena.ne.jp', null], + loginPrompt:{ user:'', password:'', description:'Enter username and password.' }, + entryPage:'http://b.hatena.ne.jp/entry/%URL%', + poster:function(user,password,url,title,comment,tags){ + var tagString = tags.length > 0 ? '[' + tags.join('][') + ']' : ""; + var request = + + dummy + + {tagString + comment} + ; + var wsse = new WSSEUtils(user,password); + + return Deferred.http({ + method: "post", + url: "http://b.hatena.ne.jp/atom/post", + data: request.toString(), + headers: { + "X-WSSE": wsse.getWSSEHeader(), + "Content-Type": "application/atom+xml", + }, + }).next(function(xhr){ + if(xhr.status != 201) throw "Hatena Bookmark: faild"; + }); + }, + tags:function(user,password){ + var xhr = new XMLHttpRequest(); + var hatena_tags = []; + + xhr.open("GET","http://b.hatena.ne.jp/my",false); + xhr.send(null); + + var mypage_html = parseHTML(xhr.responseText, ['img', 'script']); + var tags = getElementsByXPath("//ul[@id=\"taglist\"]/li/a",mypage_html); + + tags.forEach(function(tag){ + hatena_tags.push(tag.innerHTML); + }); + liberator.echo("Hatena Bookmark: Tag parsing is finished. Taglist length: " + tags.length); + return hatena_tags; + }, + icon:function(url){ + return ''; + }, + } + }; liberator.commands.addUserCommand(["twitter"], "Change Twitter status", function(arg, special){ var password; -- cgit v1.2.3