-
Notifications
You must be signed in to change notification settings - Fork 0
/
hatena-twitter-bookmark.js
executable file
·37 lines (37 loc) · 1.25 KB
/
hatena-twitter-bookmark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// A gateway to twitter.js for hatena twitter bookmark feature
//
// USAGE:
// :hatwib bookmark-comment
// execute :twitter bookmark-comment B! %URL%
// :hatwib [vimp<TAB>
// list completions starts with "vimp" from your tags
//
// INSTALL:
// 1. Install Hatena Bookmark Addon for Firefox.
// https://addons.mozilla.org/ja/firefox/addon/11285
//
// 2. Install twitter.js
// http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/trunk/twitter.js
//
// 3. Copy following codes to your .vimperatorrc
// http://vimperator.g.hatena.ne.jp/teramako/20091117/1258474425
js <<EOM
liberator.modules.hateb_tags = (function(){
let self = {
get tags() hBookmark.model("Tag").findDistinctTags(),
completer: function hatenaBookmarkTagsCompleter(context, args){
let arg = context.filter;
let matches = arg.match(/\[([^\]]*)$/);
if (matches){
context.offset += matches.index;
context.filter = matches[0];
context.title = ["Tag","Tag(count)"];
context.completions = self.tags.map(function(tag) ["["+tag.name+"]", tag.name + "("+tag.count+")"]);
}
}
};
return self;
})();
EOM
command hatwib -nargs=* -complete=custom,liberator.modules.hateb_tags.completer twitter <args> B! %URL%