From c7cc79f61893e765e15cd673c5133ccb736a8009 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 27 May 2008 10:01:08 +0000 Subject: * :bicon で被bookmark数アイコン表示(iconでなくcountの方がよかったか?) git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@12543 d0d07461-0603-4401-acd4-de1884942a52 --- direct_bookmark.js | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'direct_bookmark.js') diff --git a/direct_bookmark.js b/direct_bookmark.js index f1f8df3..a98276c 100644 --- a/direct_bookmark.js +++ b/direct_bookmark.js @@ -1,6 +1,6 @@ // Vimperator plugin: 'Direct Post to Social Bookmarks' -// Version: 0.06 -// Last Change: 18-May-2008. Jan 2008 +// Version: 0.07 +// Last Change: 27-May-2008. Jan 2008 // License: Creative Commons // Maintainer: Trapezoid - http://unsigned.g.hatena.ne.jp/Trapezoid // Parts: @@ -43,6 +43,8 @@ // Specify target SBM services to post // ':bentry' // Goto Bookmark Entry Page +// ':bicon' +// Show Bookmark Count as Icon (function(){ var useServicesByPost = liberator.globalVariables.direct_sbm_use_services_by_post || 'hdl'; var useServicesByTag = liberator.globalVariables.direct_sbm_use_services_by_tag || 'hdl'; @@ -348,6 +350,9 @@ liberator.echo("Hatena Bookmark: Tag parsing is finished. Taglist length: " + tags.length); return hatena_tags; }, + icon:function(url){ + return ''; + }, }, 'd': { description:'del.icio.us', @@ -381,6 +386,22 @@ liberator.echo("del.icio.us: Tag parsing is finished. Taglist length: " + returnValue.length); return returnValue; }, + icon:function(url){ + var url = liberator.buffer.URL; + var cryptoHash = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash); + cryptoHash.init(Ci.nsICryptoHash.MD5); + var inputStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream); + inputStream.setData(url, url.length); + cryptoHash.updateFromStream(inputStream, -1); + var hash = cryptoHash.finish(false), ascii = []; + const hexchars = '0123456789ABCDEF'; + var hexrep = new Array(hash.length * 2); + for(var i = 0; i < hash.length; i++) { + ascii[i * 2] = hexchars.charAt((hash.charCodeAt(i) >> 4) & 0xF); + ascii[i * 2 + 1] = hexchars.charAt(hash.charCodeAt(i) & 0xF); + } + return ''; + }, }, 'l': { description:'livedoor clip', @@ -417,6 +438,9 @@ liberator.echo("livedoor clip: Tag parsing is finished. Taglist length: " + tags.length); return ldc_tags; }, + icon:function(url){ + return ''; + }, }, 'g': { description:'Google Bookmarks', @@ -511,6 +535,16 @@ [0, useServicesByPost.split(/\s*/).map(function(p) [p, services[p].description])] } ); + liberator.commands.addUserCommand(['bicon'],"Show Bookmark Count as Icon", + function(arg){ + var url = getNormalizedPermalink(liberator.buffer.URL); + var html = useServicesByTag.split(/\s*/).map(function(service){ + var currentService = services[service] || null; + return (currentService && typeof currentService.icon === 'function') ? + (currentService.description + ': ' + currentService.icon(url)) : null; + }).join('
'); + liberator.echo(html, true); + }, {}); liberator.commands.addUserCommand(['sbm'],"Post to Social Bookmark", function(arg){ var res = liberator.commands.parseArgs(arg, this.args); -- cgit v1.2.3