mirror of https://github.com/nkoehring/configs.git
added vimperator config
parent
b4e4657cac
commit
bca8cf8af4
@ -0,0 +1,65 @@
|
||||
" ==Vimperator_Color_Scheme==
|
||||
" name: myzenburn
|
||||
" ==MyZenburn_Colorscheme_Settings==
|
||||
hi Bell border: 0 none; background-color: black;
|
||||
hi Boolean color: #CC9393;
|
||||
hi CmdLine font-family: monospace; padding: 1px; font-size: 10pt; font-family: monospace; font-weight: normal; padding: 0px 3px;
|
||||
|
||||
hi CmdOutput white-space: pre;
|
||||
hi CompDesc color: #d0d0d0; width: 50%;font-size: 10pt;
|
||||
hi CompGroup:not(:first-of-type) margin-top: .5em;
|
||||
hi CompIcon width: 16px; min-width: 16px; display: inline-block; margin-right: .5ex;
|
||||
hi CompIcon>img max-width: 16px; max-height: 16px; vertical-align: middle;
|
||||
hi CompItem font-size: 11px;
|
||||
hi CompItem>* padding: 0 .5ex;
|
||||
hi CompItem[selected] color: #ffffd7; background: #444444;
|
||||
" hi CompLess text-align: center; height: 0; line-height: .5ex; padding-top: 1ex;
|
||||
" hi CompLess::after content: "\2303" /* Unicode up arrowhead */
|
||||
" hi CompMore text-align: center; height: .5ex; line-height: .5ex; margin-bottom: -.5ex;
|
||||
" hi CompMore::after content: "\2304" /* Unicode down arrowhead */
|
||||
hi CompMsg font-style: italic; margin-left: 16px;
|
||||
hi CompResult width: 45%; overflow: hidden;font-size: 10pt; font-family: monospace; font-weight: normal;
|
||||
hi CompTitle color: #87af87; background: #242421; font-weight: bold;
|
||||
hi CompTitle>* padding: 0 .5ex;
|
||||
hi ErrorMsg color: #242421; background: #CC9393; font-weight: bold;
|
||||
hi Filter color: #ffffd7; background: #444444;
|
||||
hi FrameIndicator background-color: #CC9393; opacity: 0.5; z-index: 999; position: fixed; top: 0; bottom: 0; left: 0; right: 0;
|
||||
hi Function color: navy;
|
||||
" hi Gradient height: 1px; margin-bottom: -1px; margin-top: -1px;
|
||||
" hi GradientLeft background-color: #87af87;
|
||||
" hi GradientRight background-color: #242421;
|
||||
hi Hint font-family: monospace; font-size: 20px; color: #385F38; background-color: #F8F893; border-color: #F8F893; border-width: 2px; border-style: solid; padding 0px 1px 0px 1px;
|
||||
hi Hint::after content: attr(number);
|
||||
hi HintActive background: #F18C96; color: #333333;
|
||||
hi HintElem background-color: #8FAF9F; color: #000D18;
|
||||
hi HintImage opacity: .5;
|
||||
hi Indicator color: #94BFF3;
|
||||
hi InfoMsg color: #DCDCCD; background: #242421;
|
||||
hi LineNr color: orange; background: #242421;
|
||||
hi Message white-space: normal; min-width: 100%; padding-left: 2em; text-indent: -2em; display: block;
|
||||
hi ModeMsg color: #DCDCCD; background: #242421;
|
||||
hi MoreMsg color: #9ECE9E; background: #242421;
|
||||
hi NonText color: #94BFF3; min-height: 16px; padding-left: 2px;
|
||||
hi Normal color: #d7d7d7; background: #242421;
|
||||
hi Null color: #94BFF3;
|
||||
hi Number color: #94BFF3;
|
||||
hi Object color: maroon;
|
||||
hi Preview color: gray;
|
||||
hi Question color: #9ECE9E; background: #242421; font-weight: bold;
|
||||
" hi Search font-size: inherit; padding: 0; color: #385F38; background-color: #F8F893; padding: 0;
|
||||
hi StatusLine color: #afaf87; background: #3a3a3a; font-size: 10pt; font-family: monospace; font-weight: bold; padding: 0px 3px;
|
||||
" hi StatusLineBroken color: #af8787; background: #3a3a3a;
|
||||
" hi StatusLineSecure color: #87af87; background: #3a3a3a;
|
||||
hi String color: #9ECE9E;
|
||||
" hi TabIconNumber font-weight: normal; color: #DCDCCD; text-align: center; text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px;
|
||||
hi TabNumber font-weight: bold; margin: 0; padding-right: .3ex;
|
||||
hi Tag color: #94BFF3;
|
||||
hi Title color: #87af87; background: #242421; font-weight: bold;
|
||||
hi URL text-decoration: none; color: #9ECE9E; background: inherit;
|
||||
hi URL:hover text-decoration: underline; cursor: pointer;
|
||||
hi WarningMsg color: #CC9393; background: #242421;
|
||||
|
||||
style -name statusbar chrome://* <<EOM
|
||||
#status-bar statusbarpanel { padding: 0 1px !important; }
|
||||
statusbarpanel > * { margin: 0 !important; padding: 0 2px 0 0 !important; }
|
||||
EOM
|
@ -0,0 +1,115 @@
|
||||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>appendAnchor</name>
|
||||
<description>append anchors to texts look like url.</description>
|
||||
<description lang="ja">リンク中の URL っぽいテキストにアンカーをつける。</description>
|
||||
<version>0.4.7</version>
|
||||
<author>SAKAI, Kazuaki</author>
|
||||
<minVersion>2.0pre</minVersion>
|
||||
<maxVersion>2.4</maxVersion>
|
||||
<detail><![CDATA[
|
||||
== Commands ==
|
||||
:anc:
|
||||
Append anchors.
|
||||
== GlobalVariables ==
|
||||
g:auto_append_anchor:
|
||||
Execute ":anc" automatically when Vimperator shows the hints.
|
||||
g:auto_append_anchor_once:
|
||||
Just first once.
|
||||
]]></detail>
|
||||
<detail lang="ja"><![CDATA[
|
||||
== Commands ==
|
||||
:anc:
|
||||
アンカーを付加する。
|
||||
== GlobalVariables ==
|
||||
g:auto_append_anchor:
|
||||
Vimperator がヒントを表示するときに自動的に ":anc" する。
|
||||
g:auto_append_anchor_once:
|
||||
最初の一回だけ。
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
|
||||
(function(){
|
||||
|
||||
// settings ---
|
||||
// "ACEILMPRSTXY" is result of below code.
|
||||
// Array.prototype.uniq = function() this.reduceRight( function (a, b) (a[0] === b || a.unshift(b), a), []);
|
||||
// [ 'TITLE', 'STYLE', 'SCRIPT', 'TEXTAREA', 'XMP', 'A', ].join('').split('').sort().uniq().join('');
|
||||
const xpathQueryPlainText = '/descendant::*[not(contains(" TITLE STYLE SCRIPT TEXTAREA XMP A ", concat(" ", translate(local-name(), "aceilmprstxy", "ACEILMPRSTXY"), " ")))]/child::text()';
|
||||
const regexpLikeURL = new RegExp("(h?ttps?|ftp):/+([a-zA-Z0-9][-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+[-_~*(a-zA-Z0-9;/?@&=+$%#])");
|
||||
|
||||
// process global variable
|
||||
if (stringToBoolean(liberator.globalVariables.auto_append_anchor, false)) {
|
||||
let originalHintsShow = liberator.modules.hints.show;
|
||||
let once = stringToBoolean(liberator.globalVariables.auto_append_anchor_once, true);
|
||||
hints.show = function () {
|
||||
if (!(once && content.document.anchor_appended)) {
|
||||
content.document.anchor_appended = true;
|
||||
liberator.execute('anc');
|
||||
}
|
||||
originalHintsShow.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// register command
|
||||
liberator.modules.commands.addUserCommand(['anc'], 'append anchors to texts look like url',
|
||||
function(arg) {
|
||||
function append() {
|
||||
let result = 0;
|
||||
const doc = window.content.document;
|
||||
const range = doc.createRange();
|
||||
|
||||
let nodes = util.evaluateXPath(xpathQueryPlainText);
|
||||
for (let node in nodes) {
|
||||
while (node) {
|
||||
range.selectNode(node)
|
||||
|
||||
// search string like URL
|
||||
let start = range.toString().search(regexpLikeURL);
|
||||
// go to next node when there is nothing look like URL in current node
|
||||
if (!(start > -1)) break;
|
||||
|
||||
result++;
|
||||
|
||||
// build URL
|
||||
let scheme = RegExp.$1, host = RegExp.$2, lastMatch = RegExp.lastMatch;
|
||||
if (/^ttps?$/.test(scheme)) scheme = 'h' + scheme;
|
||||
let href = scheme + '://' + host;
|
||||
|
||||
// reset range
|
||||
range.setStart(node, start);
|
||||
range.setEnd(node, start + lastMatch.length);
|
||||
|
||||
// build anchor element
|
||||
let anchor = doc.createElement('a');
|
||||
anchor.setAttribute('href', href);
|
||||
range.surroundContents(anchor);
|
||||
|
||||
// insert
|
||||
range.insertNode(anchor);
|
||||
|
||||
// iterate
|
||||
node = node.nextSibling.nextSibling.nextSibling;
|
||||
}
|
||||
}
|
||||
range.detach();
|
||||
return result;
|
||||
}
|
||||
for (let i = 0; i < 20 && append(); i++)
|
||||
;
|
||||
},
|
||||
{},
|
||||
true
|
||||
);
|
||||
|
||||
// stuff function
|
||||
function stringToBoolean(str, defaultValue) {
|
||||
if (typeof str === 'number')
|
||||
str = str.toString();
|
||||
return !str ? (defaultValue ? true : false)
|
||||
: str.toLowerCase() === 'false' ? false
|
||||
: /^\d+$/.test(str) ? (parseInt(str) ? true : false)
|
||||
: true;
|
||||
}
|
||||
|
||||
})();
|
@ -0,0 +1,177 @@
|
||||
/* NEW BSD LICENSE {{{
|
||||
Copyright (c) 2008-2010, anekos.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. The names of the authors may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
###################################################################################
|
||||
# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license #
|
||||
# に参考になる日本語訳がありますが、有効なのは上記英文となります。 #
|
||||
###################################################################################
|
||||
|
||||
}}} */
|
||||
|
||||
// PLUGIN_INFO {{{
|
||||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>bit.ly</name>
|
||||
<description>Get short alias by bit.ly and j.mp</description>
|
||||
<description lang="ja">bit.ly や j.mp で短縮URLを得る</description>
|
||||
<version>2.1.2</version>
|
||||
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
|
||||
<license>new BSD License (Please read the source code comments of this plugin)</license>
|
||||
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/bitly.js</updateURL>
|
||||
<minVersion>2.0pre</minVersion>
|
||||
<detail><![CDATA[
|
||||
== Commands ==
|
||||
:bitly [<URL>]
|
||||
Copy to clipboard.
|
||||
:jmp [<URL>]
|
||||
Copy to clipboard.
|
||||
== Require ==
|
||||
bit.ly API Key
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
// }}}
|
||||
|
||||
|
||||
(function () {
|
||||
|
||||
const Realm = 'API Key for bit.ly (bitly.js)';
|
||||
const HostName = 'http://api.bit.ly';
|
||||
const ApiUrl = 'http://api.bit.ly/v3';
|
||||
const PasswordManager = Cc['@mozilla.org/login-manager;1'].getService(Ci.nsILoginManager);
|
||||
const LoginInfo =
|
||||
new Components.Constructor(
|
||||
'@mozilla.org/login-manager/loginInfo;1',
|
||||
Ci.nsILoginInfo,
|
||||
'init'
|
||||
);
|
||||
|
||||
function getAuth () {
|
||||
let count = {};
|
||||
let logins = PasswordManager.findLogins(count, HostName, null, Realm);
|
||||
if (logins.length)
|
||||
return logins[0];
|
||||
}
|
||||
|
||||
function setupAuth (callback) {
|
||||
liberator.open('http://bit.ly/a/your_api_key', liberator.NEW_TAB);
|
||||
commandline.input(
|
||||
'Login name for bit.ly: ',
|
||||
function (username) {
|
||||
commandline.input(
|
||||
'API Key: ',
|
||||
function (apiKey) {
|
||||
let login = LoginInfo(HostName, null, Realm, username, apiKey, '', '');
|
||||
PasswordManager.addLogin(login);
|
||||
callback();
|
||||
},
|
||||
{
|
||||
default: let (e = content.document.querySelector('#bitly_api_key')) (e ? e.value : '')
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function shorten (url, domain, command, callback) {
|
||||
function fixResponseText (s)
|
||||
s.trim();
|
||||
|
||||
liberator.log(arguments);
|
||||
function get () {
|
||||
let req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function () {
|
||||
if (req.readyState != 4)
|
||||
return;
|
||||
if (req.status == 200)
|
||||
return callback && callback(fixResponseText(req.responseText), req);
|
||||
else
|
||||
return liberator.echoerr(req.statusText);
|
||||
};
|
||||
let requestUri =
|
||||
ApiUrl + '/' + (command || 'shorten') + '?' +
|
||||
'apiKey=' + auth.password + '&' +
|
||||
'login=' + auth.username + '&' +
|
||||
(command !== 'expand' ? 'uri=' : 'shortUrl=') + encodeURIComponent(url) + '&' +
|
||||
'domain=' + (domain || 'bit.ly') + '&' +
|
||||
'format=txt';
|
||||
req.open('GET', requestUri, callback);
|
||||
req.send(null);
|
||||
return !callback && fixResponseText(req.responseText);
|
||||
}
|
||||
|
||||
if (!url)
|
||||
url = buffer.URL;
|
||||
|
||||
let auth = getAuth();
|
||||
|
||||
if (auth)
|
||||
return get();
|
||||
|
||||
if (callback) {
|
||||
let args = Array.slice(arguments);
|
||||
setupAuth(function () shorten.apply(this, args));
|
||||
} else {
|
||||
liberator.echoerr('Not found API Key!! Try :bitly command, before use.');
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
['jmp', 'j.mp'],
|
||||
['bitly', 'bit.ly'],
|
||||
].forEach(function ([name, domain]) {
|
||||
commands.addUserCommand(
|
||||
[name],
|
||||
'Copy ' + domain + ' url',
|
||||
function (args) {
|
||||
let url = args.literalArg ? util.stringToURLArray(args.literalArg)[0] : buffer.URL;
|
||||
let cmd = args['-expand'] ? 'expand' : 'shorten';
|
||||
|
||||
shorten(url, domain, cmd, function (short) {
|
||||
util.copyToClipboard(short);
|
||||
liberator.echo(short + ' <= ' + url);
|
||||
});
|
||||
},
|
||||
{
|
||||
literal: 0,
|
||||
options: [
|
||||
[['-expand', '-e'], commands.OPTION_NOARG]
|
||||
],
|
||||
completer: function (context) {
|
||||
context.completions = [
|
||||
[buffer.URL, 'Current URL']
|
||||
];
|
||||
context.fork('URL', 0, context, completion.url);
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
__context__[name] = function (url, cmd, callback) shorten(url, domain, cmd, callback);
|
||||
});
|
||||
|
||||
__context__.get = shorten;
|
||||
})();
|
@ -0,0 +1,123 @@
|
||||
/**
|
||||
* bookmarklet wo command ni suru plugin
|
||||
*
|
||||
* @author halt feits <halt.feits@gmail.com>
|
||||
* @version 0.6.4
|
||||
*/
|
||||
|
||||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>{NAME}</name>
|
||||
<description>convert bookmarklets to commands</description>
|
||||
<description lang="ja">ブックマークレットをコマンドにする</description>
|
||||
<author mail="halt.feits@gmail.com">halt feits</author>
|
||||
<version>0.6.6</version>
|
||||
<minVersion>2.0pre</minVersion>
|
||||
<maxVersion>2.1pre</maxVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/commandBookmarklet.js</updateURL>
|
||||
<detail><![CDATA[
|
||||
== SYNOPSIS ==
|
||||
This plugin automatically converts bookmarklets to valid commands for Vimperator.
|
||||
|
||||
== COMMAND ==
|
||||
Nothing built-in command, but each bookmarklets convert to commands that start with "bml".
|
||||
|
||||
== EXAMPLE ==
|
||||
"Hatena-Bookmark" -> bmlhatena-bookmark
|
||||
|
||||
== GLOBAL VARIABLES ==
|
||||
command_bookmarklet_prefix:
|
||||
This variable determines the prefix of a command name.
|
||||
command_bookmarklet_use_sandbox:
|
||||
When this variable is 1, execute the script of bookmarklets in Sandbox.
|
||||
If you use NoScript addon, probably you should enable this option.
|
||||
|
||||
== KNOWN ISSUES ==
|
||||
When title has non-ASCII characters, it converts to unaccountable command.
|
||||
You should rewrite title of bookmarklet to ASCII characters, to escape this issue.
|
||||
|
||||
]]></detail>
|
||||
<detail lang="ja"><![CDATA[
|
||||
== SYNOPSIS ==
|
||||
このプラグインはブックマークレットを Vimperator で実行可能なコマンドに自動的に変換します。
|
||||
|
||||
== COMMAND ==
|
||||
固有のコマンドはありませんが、それぞれのブックマークレットは "bml" ではじまるコマンドに変換されます。
|
||||
|
||||
== EXAMPLE ==
|
||||
"Hatena-Bookmark" -> bmlhatena-bookmark
|
||||
|
||||
== GLOBAL VARIABLES ==
|
||||
command_bookmarklet_prefix:
|
||||
コマンドの先頭に付加される文字列を規定します。
|
||||
デフォルトは "bml"
|
||||
command_bookmarklet_use_sandbox:
|
||||
1 の時、ブックマークレットのスクリプトを sandbox で実行します。
|
||||
NoScript アドオンをつかっている場合は、このオプションを有効にする必要があるでしょう。
|
||||
|
||||
== KNOWN ISSUES ==
|
||||
タイトルに ASCII 文字以外が含まれている場合、わけのわからないコマンドになります。
|
||||
この問題を避けるためにブックマークレットのタイトルを ASCII 文字のみに書き換えることをおすすめします。
|
||||
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
|
||||
( function () {
|
||||
|
||||
let prefix = liberator.globalVariables.command_bookmarklet_prefix;
|
||||
if (prefix === undefined)
|
||||
prefix = 'bml';
|
||||
|
||||
let items = bookmarks.get('javascript:');
|
||||
if (!items.length) {
|
||||
liberator.echoerr('No bookmarks set');
|
||||
return;
|
||||
}
|
||||
|
||||
items.forEach(function (item) {
|
||||
let name = toValidCommandName(item.title);
|
||||
if (commands.get(name))
|
||||
return;
|
||||
commands.addUserCommand(
|
||||
[name],
|
||||
'bookmarklet : ' + item.title,
|
||||
function () evalScript(item.url),
|
||||
{ shortHelp: 'Bookmarklet' },
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
function toBoolean (value, def) {
|
||||
switch (typeof value) {
|
||||
case 'undefined':
|
||||
return def;
|
||||
case 'number':
|
||||
return !!value;
|
||||
case 'string':
|
||||
return !/^(\d+|false)$/i.test(value) || parseInt(value);
|
||||
default:
|
||||
return !!value;
|
||||
}
|
||||
}
|
||||
|
||||
function evalInSandbox (str) {
|
||||
let sandbox = new Components.utils.Sandbox("about:blank");
|
||||
sandbox.__proto__ = content.window.wrappedJSObject;
|
||||
return Components.utils.evalInSandbox(str, sandbox);
|
||||
}
|
||||
|
||||
function evalScript (url) {
|
||||
if (toBoolean(liberator.globalVariables.command_bookmarklet_use_sandbox, false)) {
|
||||
evalInSandbox(decodeURIComponent(url.replace(/^\s*javascript:/i, '')));
|
||||
} else {
|
||||
liberator.open(url);
|
||||
}
|
||||
}
|
||||
|
||||
function toValidCommandName(str) {
|
||||
str = prefix + escape(str.replace(/ +/g, '').toLowerCase()).replace(/[^a-zA-Z]+/g,'');
|
||||
return str.substr(0, str.length > 50 ? 50 : str.length);
|
||||
}
|
||||
|
||||
} )();
|
||||
// vim:sw=2 ts=2 et:
|
@ -0,0 +1,183 @@
|
||||
liberator.plugins.cssRules = function () {
|
||||
|
||||
liberator.commands.addUserCommand(
|
||||
["css[rule]"],
|
||||
"Sets CSS rule for current page",
|
||||
function (args, count, special) {
|
||||
// 1 2 3 4
|
||||
var matches = args.match(/^\s*?([:\[\]"'^*~|= #.,a-zA-Z0-9_>+-]+)(\s*([-+^])?=\s*(.*))?\s*$/);
|
||||
var ruleName = matches[1];
|
||||
var setValue = !!matches[2];
|
||||
var operator = matches[3];
|
||||
var ruleValue = matches[4];
|
||||
if (count > 0) count = count - 1; else count = -1;
|
||||
|
||||
var rule = liberator.plugins.cssRules.getRule(ruleName, count);
|
||||
if (!rule) {
|
||||
if (special) {
|
||||
rule = liberator.plugins.cssRules.addRule(ruleName, count);
|
||||
if (!rule) {
|
||||
liberator.echoerr("Failed to add CSS rule '" + ruleName + "'!");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
liberator.echoerr("CSS rule '" + ruleName + "' was not found!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!setValue) {
|
||||
liberator.echo(rule.selectorText + " {\n\t" + rule.style.cssText.replace(/; /g, ";\n\t") + "\n}");
|
||||
} else {
|
||||
liberator.plugins.cssRules.setRule(rule, ruleValue)
|
||||
}
|
||||
}, {}, true
|
||||
);
|
||||
|
||||
liberator.commands.addUserCommand(
|
||||
["rmcss[rule]"],
|
||||
"Remove CSS rule for current page",
|
||||
function (args, count, special) {
|
||||
var args = args.replace(/^\s*/, "").replace(/\s*$/, "");
|
||||
if (args.match(/[^:\[\]"'^*~|= #.,a-zA-Z0-9_>+-]/)) {
|
||||
liberator.echoerr("Not a CSS rule name: '" + args + "'!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count > 0) count = count - 1; else count = -1;
|
||||
var rule = liberator.plugins.cssRules.getRule(args, count);
|
||||
|
||||
if (!rule) {
|
||||
liberator.echoerr("CSS rule '" + args + "' was not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
liberator.plugins.cssRules.rmRule(rule);
|
||||
}, {}, true
|
||||
);
|
||||
|
||||
liberator.commands.addUserCommand(
|
||||
["cssrules"],
|
||||
"Lists all CSS rules for current page",
|
||||
function (args, count) {
|
||||
|
||||
var ss = liberator.tabs.getTab().linkedBrowser.contentDocument.styleSheets;
|
||||
var list = ":" + (liberator.util.escapeHTML(liberator.commandline.getCommand()) || ":cssrules") + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th colspan=\"2\">--- CSS rules ---</th></tr>";
|
||||
|
||||
var from = 0;
|
||||
var len = ss.length;
|
||||
|
||||
if (count > 0) {
|
||||
from = count - 1;
|
||||
len = count;
|
||||
}
|
||||
|
||||
for (var i = from; i < len; i++) {
|
||||
var href = ss[i].href;
|
||||
if (href)
|
||||
href = "<a href=\"#\" class=\"hl-URL\">" + liberator.util.escapeHTML(href) + "</a>";
|
||||
else
|
||||
href = "<span class=\"hl-InfoMsg\">Embedded Styles</span>";
|
||||
|
||||
var rules = "";
|
||||
for (var j = 0, lenj = ss[i].cssRules.length; j < lenj; j++) {
|
||||
rules += "<span style=\"font-weight: bold\">" + ss[i].cssRules[j].selectorText + "</span> {";
|
||||
rules += "<div style=\"margin-left: 2em\">" + ss[i].cssRules[j].style.cssText.replace(/; /g, ";<br/>") + "</div>}<br/><br/>";
|
||||
}
|
||||
list += "<tr align=\"left\"><th>" + (i + 1) + ":</th>" + href + "</th></tr>";
|
||||
list += "<tr><td> </td><td>" + rules + "</td></tr>";
|
||||
}
|
||||
list += "</table>";
|
||||
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
|
||||
}, {}, true
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
getRule: function (filter, num) {
|
||||
filter = filter.toLowerCase();
|
||||
var ss = liberator.tabs.getTab().linkedBrowser.contentDocument.styleSheets;
|
||||
|
||||
if (num >= 0) {
|
||||
|
||||
if (num <= ss.length) {
|
||||
var rules = ss[num].cssRules;
|
||||
for (var i = 0, len = rules.length; i < len; i++) {
|
||||
if (rules[i].selectorText == filter) {
|
||||
return rules[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
for (var j = 0, lenj = ss.length; j < lenj; j++) {
|
||||
for (var i = 0, len = ss[j].cssRules.length; i < len; i++) {
|
||||
if (ss[j].cssRules[i].selectorText == filter) {
|
||||
return ss[j].cssRules[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
setRule: function (rule, ruleValue) {
|
||||
var rulesList = ruleValue.split("; ");
|
||||
for (var i = 0; i < rulesList.length; i++) {
|
||||
var data = rulesList[i].match(/^\s*([a-zA-Z-]+)\s*:\s*(.*?)\s*;?$/);
|
||||
if (data) {
|
||||
var important = data[2].match(/!\s*important$/);
|
||||
if (important) data[2] = data[2].substring(0, data[2].length - important.length);
|
||||
rule.style.setProperty(data[1], data[2], important? "important": "");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addRule: function (name, num, place) {
|
||||
var ss = liberator.tabs.getTab().linkedBrowser.contentDocument.styleSheets;
|
||||
var newPlace;
|
||||
|
||||
if (num >= ss.length) return null;
|
||||
if (num < 0) num = 0;
|
||||
|
||||
if (!place) place = ss[num].cssRules.length;
|
||||
|
||||
try {
|
||||
var newPlace = ss[num].insertRule(name + "{}", place);
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ss[num].cssRules[newPlace];
|
||||
},
|
||||
|
||||
rmRule: function (rule) {
|
||||
var ss = rule.parentStyleSheet;
|
||||
var num = -1;
|
||||
for (var i = 0; i < ss.cssRules.length; i++) {
|
||||
if (ss.cssRules[i] == rule) {
|
||||
num = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num < 0) return false;
|
||||
|
||||
try {
|
||||
ss.deleteRule(num);
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} ();
|
||||
|
@ -0,0 +1,229 @@
|
||||
/* {{{
|
||||
Copyright (c) 2008-2009, anekos.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. The names of the authors may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
###################################################################################
|
||||
# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license #
|
||||
# に参考になる日本語訳がありますが、有効なのは上記英文となります。 #
|
||||
###################################################################################
|
||||
|
||||
}}} */
|
||||
|
||||
// PLUGIN_INFO {{{
|
||||
let PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>every.js</name>
|
||||
<description>to run a specified command every time at specified interval.</description>
|
||||
<description lang="ja">指定のコマンドを指定の間隔で実行する。</description>
|
||||
<version>1.3.1</version>
|
||||
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
|
||||
<license>new BSD License (Please read the source code comments of this plugin)</license>
|
||||
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/every.js</updateURL>
|
||||
<minVersion>2.3</minVersion>
|
||||
<maxVersion>2.3</maxVersion>
|
||||
<detail><![CDATA[
|
||||
== Usage ==
|
||||
:[INTERVAL]every [-i[nterval]=INTERVAL] [-init=INITIALIZE_COMMAND] [-from=COUNTER_FORM] [-step=COUNTER_STEP]<COMMAND>:
|
||||
run <COMMAND> every time at [INTERVAL] sec.
|
||||
|
||||
:[INTERVAL]delay [-i[nterval]=INTERVAL] <COMMAND>:
|
||||
run <COMMAND> after [INTERVAL] sec.
|
||||
|
||||
:every! <PROCESS-ID>:
|
||||
kill specified process.
|
||||
|
||||
The default value of [INTERVAL] is 1 sec.
|
||||
While Vimperator's focus is at command-line,
|
||||
these commands does not run.
|
||||
|
||||
== Links ==
|
||||
http://d.hatena.ne.jp/nokturnalmortum/20081102#1225552718
|
||||
]]></detail>
|
||||
<detail lang="ja"><![CDATA[
|
||||
== Usage ==
|
||||
:[INTERVAL]every [-i[nterval]=INTERVAL] [-init=INITIALIZE_COMMAND] [-from=COUNTER_FROM] [-step=COUNTER_STEP]<COMMAND>:
|
||||
[INTERVAL] 間隔で <COMMAND> を走らせる。
|
||||
|
||||
:[INTERVAL]delay [-i[nterval]=INTERVAL] <COMMAND>:
|
||||
[INTERVAL] 秒後に <COMMAND> を走らせる。
|
||||
|
||||
:every! <PROCESS-ID>:
|
||||
指定のプロセスを殺す。
|
||||
|
||||
INTERVAL:
|
||||
INTERVAL のデフォルトは 1秒。
|
||||
オプションでの指定時には、"s[ec]", "m[in]", "h[our]" の単位で指定可能。(e.g. "0.5hour")
|
||||
コマンドラインにいるときには、実行されないようになっている。
|
||||
INITIALIZE_COMMAND:
|
||||
指定すると、:every 実行直後にそれが実行されます。
|
||||
COUNTER_FROM/COUNTER_STEP:
|
||||
何れか一方を指定すると、COMMAND 中の "<counter>" という文字が、カウンター数字に置換されます。
|
||||
この数字は、COUNTER_FROM で初期化され、every での実行毎に COUNTER_STEP ずつ増えます。
|
||||
|
||||
== Links ==
|
||||
http://d.hatena.ne.jp/nokturnalmortum/20081102#1225552718
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
// }}}
|
||||
|
||||
ps = [];
|
||||
|
||||
(function () {
|
||||
|
||||
let (every = liberator.plugins.every) {
|
||||
if (every && every.ps)
|
||||
kill('*');
|
||||
}
|
||||
|
||||
function defined (value)
|
||||
(typeof value !== 'undefined');
|
||||
|
||||
function defaultValue (value, def)
|
||||
(defined(value) ? value : def);
|
||||
|
||||
function run (command, interval, opts) {
|
||||
let process = {
|
||||
handle: null,
|
||||
command: command,
|
||||
options: opts
|
||||
};
|
||||
if (opts.init)
|
||||
liberator.execute(opts.init);
|
||||
let fun = function () {
|
||||
if (liberator.mode == liberator.modules.modes.COMMAND_LINE)
|
||||
return;
|
||||
let cmd = process.command;
|
||||
if (defined(opts.from) || defined(opts.step)) {
|
||||
if (!defined(process.counter))
|
||||
process.counter = defaultValue(opts.from, 1);
|
||||
cmd = cmd.replace(/<counter>/i, process.counter);
|
||||
process.counter += defaultValue(opts.step, 1);
|
||||
}
|
||||
liberator.execute(cmd);
|
||||
};
|
||||
process.handle = setInterval(fun, parseInt(interval, 10));
|
||||
ps.push(process);
|
||||
}
|
||||
|
||||
function kill (index) {
|
||||
if (index == '*') {
|
||||
ps.forEach(function (process) clearInterval(process.handle));
|
||||
liberator.echo(ps.length + ' processes were killed!');
|
||||
ps = [];
|
||||
} else {
|
||||
let process = ps[index];
|
||||
if (process) {
|
||||
clearInterval(process.handle);
|
||||
ps.splice(index, index);
|
||||
liberator.echo('process "' + process.command + '" was killed!');
|
||||
} else {
|
||||
liberator.echoerr('unknown process');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function msec (count) {
|
||||
return (count > 0) ? count * 1000 : 1000;
|
||||
}
|
||||
|
||||
function expandSuffix (s) {
|
||||
const tbl = {
|
||||
'^s(ec)?$': 1,
|
||||
'^m(in)?$': 60,
|
||||
'^h(our)?$': 60 * 60
|
||||
};
|
||||
let [, a, b] = s.match(/^([\d\.]+)(.*)$/);
|
||||
let v = parseFloat(a);
|
||||
for (let e in tbl)
|
||||
if (b.match(e))
|
||||
return v * tbl[e];
|
||||
return v;
|
||||
}
|
||||
|
||||
liberator.modules.commands.addUserCommand(
|
||||
['every', 'ev'],
|
||||
'every',
|
||||
function (args) {
|
||||
if (args.bang) {
|
||||
kill(args.literalArg);
|
||||
} else {
|
||||
let interval = args['-interval'];
|
||||
let opts = {};
|
||||
'from step init'.split(' ').forEach(function (v) (opts[v] = args['-' + v]));
|
||||
run(args.literalArg, msec(interval ? expandSuffix(interval) : args.count), opts);
|
||||
}
|
||||
},
|
||||
{
|
||||
literal: 0,
|
||||
count: true,
|
||||
bang: true,
|
||||
completer: function (context, args) {
|
||||
if (args.bang) {
|
||||
context.title = ['PID', 'every process'];
|
||||
context.completions = [['*', 'kill em all']].concat(ps.map(function (p, i) ([i.toString(), p.command])));
|
||||
} else {
|
||||
liberator.modules.completion.ex(context);
|
||||
}
|
||||
},
|
||||
options: [
|
||||
[['-interval', '-i'], commands.OPTION_ANY],
|
||||
[['-from', '-f'], commands.OPTION_FLOAT],
|
||||
[['-step', '-s'], commands.OPTION_FLOAT],
|
||||
[['-init', '-i'], commands.OPTION_STRING],
|
||||
]
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
liberator.modules.commands.addUserCommand(
|
||||
['delay'],
|
||||
'delay',
|
||||
function (args) {
|
||||
let cmd = args.literalArg;
|
||||
let f = function () {
|
||||
if (liberator.mode == liberator.modules.modes.COMMAND_LINE) {
|
||||
setTimeout(f, 500);
|
||||
} else {
|
||||
liberator.execute(cmd);
|
||||
}
|
||||
};
|
||||
let interval = args['-interval'];
|
||||
setTimeout(f, msec(interval ? expandSuffix(interval) : args.count));
|
||||
},
|
||||
{
|
||||
literal: 0,
|
||||
count: true,
|
||||
completer: function (context) liberator.modules.completion.ex(context),
|
||||
options: [
|
||||
[['-interval', '-i'], commands.OPTION_ANY]
|
||||
]
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
})();
|
@ -0,0 +1,46 @@
|
||||
// INFO //
|
||||
var INFO =
|
||||
<plugin name="gmap.js" version="0.1"
|
||||
summary="Get google maps URL of current machine location."
|
||||
href="http://github.com/vimpr/vimperator-plugins/blob/master/gmap.js"
|
||||
xmlns="http://vimperator.org/namespaces/liberator">
|
||||
<author email="mitsugu.oyama@gmail.com">Mitsugu Oyama</author>
|
||||
<license href="http://opensource.org/licenses/mit-license.php">MIT</license>
|
||||
<project name="Vimperator" minVersion="2.3"/>
|
||||
<p>
|
||||
You can get Google Maps URL of current machine location by this plugin.
|
||||
</p>
|
||||
<item>
|
||||
<tags>'GoogleMaps'</tags>
|
||||
<spec>:gmap</spec>
|
||||
<description>
|
||||
<p>You can get Google Maps URL of current machine location by this plugin.</p>
|
||||
<dl>
|
||||
<dt>See.</dt>
|
||||
<dd>
|
||||
<p><link topic="http://mozilla.jp/firefox/features/geolocation/">http://mozilla.jp/firefox/features/geolocation/</link> (Japanese)</p>
|
||||
<p><link topic="https://developer.mozilla.org/Ja/Using_geolocation">https://developer.mozilla.org/Ja/Using_geolocation</link> (Japanese)</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</description>
|
||||
</item>
|
||||
</plugin>;
|
||||
|
||||
(function(){
|
||||
commands.addUserCommand(
|
||||
['gmap'],
|
||||
'Get Google Map URL of current location',
|
||||
function(){
|
||||
let strURL='http://maps.google.com/maps?ie=UTF8&q=';
|
||||
let Cc=Components.classes;
|
||||
let Ci=Components.interfaces;
|
||||
let geolocation=Cc["@mozilla.org/geolocation;1"]
|
||||
.getService(Ci.nsIDOMGeoGeolocation);
|
||||
geolocation.getCurrentPosition(function(position){
|
||||
let strL=position.coords.latitude+','+position.coords.longitude;
|
||||
liberator.echo(strURL+strL);
|
||||
util.copyToClipboard(strURL+strL,true);
|
||||
});
|
||||
}
|
||||
);
|
||||
})();
|
@ -0,0 +1,89 @@
|
||||
// PLUGIN_INFO//{{{
|
||||
var PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>{NAME}</name>
|
||||
<description>hash of file</description>
|
||||
<author mail="konbu.komuro@gmail.com" homepage="http://d.hatena.ne.jp/hogelog/">hogelog</author>
|
||||
<version>0.2.2</version>
|
||||
<minVersion>2.3</minVersion>
|
||||
<maxVersion>2.3</maxVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/hash.js</updateURL>
|
||||
<detail><![CDATA[
|
||||
|
||||
== COMMANDS ==
|
||||
hash:
|
||||
:hash md2|md5|sha1|sha256|sha384|sha512 file-path
|
||||
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
//}}}
|
||||
|
||||
(function() {
|
||||
const PR_UINT_MAX = 0xffffffff;
|
||||
let Crypt = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash);
|
||||
let Algos = [
|
||||
["md2", "MD2 Algorithm"],
|
||||
["md5", "MD5 Algorithm"],
|
||||
["sha1", "SHA1 Algorithm"], // SHA-1
|
||||
["sha256", "SHA256 Algorithm"], // SHA-256
|
||||
["sha384", "SHA384 Algorithm"], // SHA-384
|
||||
["sha512", "SHA512 Algorithm"], // SHA-512
|
||||
];
|
||||
|
||||
function getStream(path)
|
||||
{
|
||||
let file = io.File(path);
|
||||
let stream = Cc["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Ci.nsIFileInputStream);
|
||||
stream.init(file, 0x01, 0444, 0);
|
||||
return stream;
|
||||
}
|
||||
|
||||
// return the two-digit hexadecimal code for a byte
|
||||
function toHexString(charCode)
|
||||
{
|
||||
return ("0" + charCode.toString(16)).slice(-2);
|
||||
}
|
||||
|
||||
|
||||
commands.addUserCommand(["hash"], "hash of file",
|
||||
function(args){
|
||||
if (args.length!=2) {
|
||||
|
||||
liberator.echo("usage \":hash md2|md5|sha1|sha256|sha384|sha512 file-path\"");
|
||||
return false;
|
||||
}
|
||||
let [algo, path] = args;
|
||||
let stream = getStream(path);
|
||||
|
||||
Crypt.initWithString(algo);
|
||||
|
||||
// read the entire stream
|
||||
Crypt.updateFromStream(stream, PR_UINT_MAX);
|
||||
|
||||
stream.close();
|
||||
|
||||
// get base-64 string
|
||||
let hash = Crypt.finish(false);
|
||||
|
||||
// convert the binary hash data to a hex string.
|
||||
let str = [toHexString(hash.charCodeAt(i)) for(i in hash)].join("");
|
||||
util.copyToClipboard(str, true);
|
||||
},
|
||||
{
|
||||
bang: true,
|
||||
completer: function (context, args){
|
||||
if (args.completeArg == 0) {
|
||||
context.title = ["hash", "algorithm"];
|
||||
context.completions = Algos;
|
||||
} else if (args.completeArg == 1) {
|
||||
completion.url(context, "f");
|
||||
}
|
||||
},
|
||||
literal: 1,
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
})();
|
||||
// vim: fdm=marker sw=4 ts=4 et:
|
@ -0,0 +1,91 @@
|
||||
var PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>{NAME}</name>
|
||||
<description>History search backward like UNIX shell.</description>
|
||||
<description lang="ja">UNIX シェルのような、C-rで履歴検索を行うプラグイン</description>
|
||||
<minVersion>2.0</minVersion>
|
||||
<maxVersion>2.0</maxVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/history-search-backward.js</updateURL>
|
||||
<author mail="hotchpotch@gmail.com" homepage="http://d.hatena.ne.jp/secondlife/">Yuichi Tateno</author>
|
||||
<license>MIT</license>
|
||||
<version>0.2</version>
|
||||
<detail><![CDATA[
|
||||
UNIX シェルのように、コマンドラインで C-r でヒストリ検索を行うプラグインです。map の変更設定は以下のように行えます。
|
||||
>||
|
||||
liberator.globalVariables.history_search_backward_map = ['<C-r>'];
|
||||
||<
|
||||
|
||||
]]></detail>
|
||||
</VimperatorPlugin>;
|
||||
|
||||
(function() {
|
||||
let p = function(msg) {
|
||||
Application.console.log(''+msg);
|
||||
}
|
||||
|
||||
let evalWithContext = function(func, context) {
|
||||
let str;
|
||||
let fstr = func.toString();
|
||||
if (fstr.indexOf('function () {') == 0) {
|
||||
str = fstr.replace(/.*?{([\s\S]+)}.*?/m, "$1");
|
||||
} else {
|
||||
str = '(' + fstr + ')()';
|
||||
}
|
||||
return liberator.eval(str, context);
|
||||
}
|
||||
|
||||
let showCompletions = function() {
|
||||
if (!options.get('wildoptions').has('auto')) {
|
||||
evalWithContext(function() {
|
||||
completions.complete(true, false);
|
||||
completions.itemList.show();
|
||||
}, commandline.input);
|
||||
}
|
||||
}
|
||||
|
||||
let next = function() {
|
||||
evalWithContext(function() completions.tab(false), commandline.input);
|
||||
}
|
||||
|
||||
let prev = function() {
|
||||
evalWithContext(function() completions.tab(true), commandline.input);
|
||||
}
|
||||
|
||||
const commandlineWidget = document.getElementById("liberator-commandline");
|
||||
|
||||
mappings.addUserMap([modes.COMMAND_LINE],
|
||||
liberator.globalVariables.history_search_backward_map || ['<C-r>'],
|
||||
'History incremental search backward.',
|
||||
function()
|
||||
{
|
||||
if (evalWithContext(function() completions.itemList.visible(), commandline.input)) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
let command = commandline.command || '';
|
||||
let completionsList = [[key, i] for ([i, key] in storage['history-command'])].
|
||||
filter(function([key, i]) key).reverse();
|
||||
|
||||
commandline.input('bck-i-search: ', function(str) {
|
||||
try {
|
||||
liberator.execute(str);
|
||||
} catch(e) {};
|
||||
modes.pop();
|
||||
return;
|
||||
}, {
|
||||
completer: function(context) {
|
||||
context.title = ['CommandLine History', 'INDEX'];
|
||||
context.completions = completionsList;
|
||||
},
|
||||
onChange: function() {
|
||||
showCompletions();
|
||||
},
|
||||
default: command,
|
||||
});
|
||||
showCompletions();
|
||||
}
|
||||
);
|
||||
})();
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,98 @@
|
||||
var PLUGIN_INFO =
|
||||
<VimperatorPlugin>
|
||||
<name>{NAME}</name>
|
||||
<description>Send to your Android Phone</description>
|
||||
<description lang="ja">Android 端末に URL などを送信します</description>
|
||||
<author mail="hotchpotch@gmail.com">Yuichi Tateno</author>
|
||||
<minVersion>2.3</minVersion>
|
||||
<maxVersion>2.3</maxVersion>
|
||||
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/vimp_to_android_phone.js</updateURL>
|
||||
</VimperatorPlugin>;
|
||||
|
||||
(function() {
|
||||
|
||||
var apiVersion = '3';
|
||||
var base = 'http://chrometophone.appspot.com';
|
||||
var baseURL = base + '/send?ver=' + apiVersion;
|
||||
var signInURL = base + '/signin?extret=about:blankZ&ver=' + apiVersion;
|
||||
var signOutURL = base + '/signout?extret=about:blankZ&ver=' + apiVersion;
|
||||
// var loginURL = 'https://www.google.com/accounts/ServiceLoginAuth?service=ah&sig=d71ef8b8d6150b23958ad03b3bf546b7';
|
||||
|
||||
var serialize = function(hash) {
|
||||
var res = [];
|
||||
for (var key in hash) {
|
||||
res.push(encodeURIComponent(key) + '=' + encodeURIComponent(hash[key]));
|
||||
}
|
||||
return res.join('&');
|
||||
}
|
||||
|
||||
var sendToPhone = function(requestURL) {
|
||||
requestURL = baseURL + '&' + requestURL;
|
||||
var req = new libly.Request(requestURL, {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'X-Extension': 'true'
|
||||
});
|
||||
req.addEventListener('success', function(res) {
|
||||
var body = res.responseText;
|
||||
if (body.substring(0, 2) == 'OK') {
|
||||
liberator.echo('Send to phone successed.');
|
||||
} else if (body.indexOf('LOGIN_REQUIRED' == 0)) {
|
||||
liberator.echo('Please login first');
|
||||
liberator.open(signInURL, liberator.NEW_TAB);
|
||||
} else if (body.indexOf('DEVICE_NOT_REGISTERED') == 0) {
|
||||
liberator.echo('device not registered');
|
||||
liberator.open(signOutURL, liberator.NEW_TAB);
|
||||
}
|
||||
});
|
||||
req.addEventListener('failure', function(res) {
|
||||
liberator.echoerr('Send to phone failed.');
|
||||
});
|
||||
req.get();
|
||||
}
|
||||
|
||||
liberator.modules.commands.addUserCommand(["sp[hone]"], "Sent to your Android Phone",
|
||||
function(args) {
|
||||
if (args && args['-login']) {
|
||||
liberator.open(signInURL, liberator.NEW_TAB);
|
||||
return;
|
||||
} else if (args && args['-logout']) {
|
||||
liberator.open(signOutURL, liberator.NEW_TAB);
|
||||
return;
|
||||
}
|
||||
|
||||
var req = {
|
||||
sel: libly.$U.getSelectedString()
|
||||
};
|
||||
|
||||
if (args && !args.arguments && !args['-title'])
|
||||
req.url = args[0];
|
||||
else if (args && args.arguments)
|
||||
req.url = args.arguments[0];
|
||||
|
||||
if (args && args['-title'])
|
||||
req.title = args['-title'];
|
||||
else if (!req.url)
|
||||
req.title = content.document.title;
|
||||
|
||||
if (!req.url) req.url = content.location.href;
|
||||
if (!req.title) req.title = req.url;
|
||||
|
||||
if (!req.url || !req.url.match(/^https?/)) {
|
||||
liberator.echoerr('http/https schema only');
|
||||
return;
|
||||
};
|
||||
sendToPhone(serialize(req));
|
||||
}, {
|
||||
options: [
|
||||
[["-title", "-t"], liberator.modules.commands.OPTION_STRING],
|
||||
[["-login"], liberator.modules.commands.OPTION_NOARG],
|
||||
[["-logout"], liberator.modules.commands.OPTION_NOARG],
|
||||
]
|
||||
}, {
|
||||
// replace: true
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
set gui=none
|
||||
set hintchars=hjklasdfgyuiopqwertnmzxcvb
|
||||
set visualbell=true
|
||||
set complete=Sltf
|
||||
set suggestengines=wikipedia
|
Loading…
Reference in New Issue