| 1 | // PLUGIN_INFO//{{{ |
|---|
| 2 | var PLUGIN_INFO = |
|---|
| 3 | <VimperatorPlugin> |
|---|
| 4 | <name>{NAME}</name> |
|---|
| 5 | <description>atodeyomu</description> |
|---|
| 6 | <author mail="konbu.komuro@gmail.com" homepage="http://d.hatena.ne.jp/hogelog/">hogelog</author> |
|---|
| 7 | <version>0.0.1</version> |
|---|
| 8 | <minVersion>2.2</minVersion> |
|---|
| 9 | <maxVersion>2.3</maxVersion> |
|---|
| 10 | <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/atodeyomu.js</updateURL> |
|---|
| 11 | <license>public domain</license> |
|---|
| 12 | <detail><![CDATA[ |
|---|
| 13 | ]]></detail> |
|---|
| 14 | </VimperatorPlugin>; |
|---|
| 15 | //}}} |
|---|
| 16 | |
|---|
| 17 | (function(){ |
|---|
| 18 | var yomudata = storage.newMap("atodeyomu", {store: true}); |
|---|
| 19 | if(!yomudata.get("yomulist")) |
|---|
| 20 | yomudata.set("yomulist", {}); |
|---|
| 21 | var yomulist = yomudata.get("yomulist"); |
|---|
| 22 | |
|---|
| 23 | __context__.funcs = { |
|---|
| 24 | yomulist: function() yomulist, |
|---|
| 25 | onload: function() |
|---|
| 26 | { |
|---|
| 27 | let url = content.location.href; |
|---|
| 28 | if (yomulist[url]) { |
|---|
| 29 | delete yomulist[url]; |
|---|
| 30 | } |
|---|
| 31 | }, |
|---|
| 32 | install: function() gBrowser.addEventListener("load", __context__.funcs.onload, true), |
|---|
| 33 | uninstall: function() gBrowser.removeEventListener("load", __context__.funcs.onload, true), |
|---|
| 34 | }; |
|---|
| 35 | |
|---|
| 36 | __context__.funcs.install(); |
|---|
| 37 | |
|---|
| 38 | commands.addUserCommand(["atode"], "atode yomu", |
|---|
| 39 | function(args){ |
|---|
| 40 | yomulist[content.location.href] = args.literalArg || content.document.title; |
|---|
| 41 | }, { |
|---|
| 42 | literal: 0 |
|---|
| 43 | }, true); |
|---|
| 44 | commands.addUserCommand(["yomu"], "ima yomu", |
|---|
| 45 | function(args){ |
|---|
| 46 | let url = args.literalArg; |
|---|
| 47 | let where = options.get("activate").has("tabopen") ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB; |
|---|
| 48 | liberator.open(url, where); |
|---|
| 49 | }, { |
|---|
| 50 | literal: 0, |
|---|
| 51 | completer: function(context, args){ |
|---|
| 52 | context.title = ["yomu"]; |
|---|
| 53 | context.completions = [[url, yomulist[url]] for(url in yomulist)]; |
|---|
| 54 | }, |
|---|
| 55 | }, true); |
|---|
| 56 | })(); |
|---|
| 57 | // vim: fdm=marker sw=4 ts=4 et: |
|---|