Skip to content

Instantly share code, notes, and snippets.

@azu

azu/.keysnail.js

Created Mar 20, 2011
Embed
What would you like to do?
// ========================== KeySnail Init File =========================== //
// この領域は, GUI により設定ファイルを生成した際にも引き継がれます
// 特殊キー, キーバインド定義, フック, ブラックリスト以外のコードは, この中に書くようにして下さい
// ========================================================================= //
//{{%PRESERVE%
// ここにコードを入力して下さい.
// Site local keymap {{ ===================================================== /
var local = {};
plugins.options["site_local_keymap.local_keymap"] = local;
local["http://(www|tw|es|de|)\.nicovideo\.jp\/watch/*"] = [
["i", function (ev, arg) { ext.exec("nicoinfo", arg); }],
["p", function (ev, arg) { ext.exec("nicopause", arg); }],
["m", function (ev, arg) { ext.exec("nicomute", arg); }],
["r", function (ev, arg) { ext.exec("nicorepeat", arg); }],
["z", function (ev, arg) { ext.exec("nicosize", arg); }],
["h", function (ev, arg) { ext.exec("nicommentvisible", arg); }],
["s", function (ev, arg) { ext.exec("nicoseekForward", arg); }],
["S", function (ev, arg) { ext.exec("nicoseekBackward", arg); }],
[["v", "u"], function (ev, arg) { ext.exec("nicovolumeIncrement", arg); }],
[["v", "d"], function (ev, arg) { ext.exec("nicovolumeDecrement", arg); }],
[["V", "x"], function (ev) { ext.exec("nicovolume", 100); }],
[["V", "h"], function (ev) { ext.exec("nicovolume", 50); }],
["c", function (ev, arg) { ext.exec("nicomment", arg); }],
["C", function (ev, arg) { ext.exec("nicommand", arg); }]
];
plugins.options["Xbookmark_opt.Xbookmark_list"] = "hatebu";
plugins.options["Xbookmark_opt.diigo_post"] = true;
plugins.options["Xbookmark_opt.delicious_post"] = true;
plugins.options["Xbookmark_opt.delicious_username"] = "hoge";
plugins.options["Xbookmark_opt.google_post"] = false;
plugins.options["Xbookmark_opt.hatebu_post"] = true;
plugins.options["Xbookmark_opt.keymap"] = {
"C-z" : "prompt-toggle-edit-mode",
"SPC" : "prompt-next-page",
"b" : "prompt-previous-page",
"j" : "prompt-next-completion",
"k" : "prompt-previous-completion",
"g" : "prompt-beginning-of-candidates",
"G" : "prompt-end-of-candidates",
"D" : "prompt-cancel",
// Keydledo client specific actions
"o" : "local_open",
"h" : "local_show_hatebu_user",
"e" : "local_delete_bookmark",
"d" : "local_edit_tag"
};
plugins.options["hok.hint_keys"] = "asdfqwer";
// http://keysnail.g.hatena.ne.jp/mooz/20110102/1293983938
(function () {
function googleSuggest(word) {
const domain = "com";
const base = "http://www.google.%s/complete/search?output=toolbar&q=%s";
let ep = util.format(base, domain, encodeURIComponent(word));
let res = util.httpGet(ep);
let matched = res.responseText.match("(<toplevel>.*</toplevel>)");
if (!matched)
return null;
let xml = new XML(matched[1]);
return [cs.suggestion.@data for each (cs in xml.CompleteSuggestion)];
}
function googleCompleter(args, extra) {
let suggestions = googleSuggest(extra.query || "");
return { collection : suggestions, origin : extra.whole.indexOf(extra.left) };
}
shell.add("udic", "Urban dictionary", function (args, extra) {
const base = "http://www.urbandictionary.com/define.php?term=%s";
util.setBoolPref("accessibility.browsewithcaret", false);
gBrowser.loadOneTab(util.format(base, encodeURIComponent(args[0])),
null, null, null, extra.bang);
}, { bang: true, completer: googleCompleter });
shell.add("goodic", M({ja: "Goo 辞書", en: "Goo dic"}), function (args, extra) {
const base = "http://dictionary.goo.ne.jp/search.php?MT=%s&kind=all&mode=0&IE=UTF-8";
util.setBoolPref("accessibility.browsewithcaret", false);
gBrowser.loadOneTab(util.format(base, encodeURIComponent(args[0])),
null, null, null, extra.bang);
}, { bang: true, completer: googleCompleter });
})();
//}}%PRESERVE%
// ========================================================================= //
// ========================= Special key settings ========================== //
key.quitKey = "undefined";
key.helpKey = "undefined";
key.escapeKey = "undefined";
key.macroStartKey = "undefined";
key.macroEndKey = "undefined";
key.universalArgumentKey = "undefined";
key.negativeArgument1Key = "undefined";
key.negativeArgument2Key = "undefined";
key.negativeArgument3Key = "undefined";
key.suspendKey = "undefined";
// ================================= Hooks ================================= //
// ============================= Key bindings ============================== //
key.setGlobalKey('M-x', function (aEvent, aArg) {
ext.select(aArg);
}, 'エクステ', true);
key.setGlobalKey(['C-b', 't'], function (ev, arg) {
ext.exec("bmany-list-toolbar-bookmarks", arg, ev);
}, 'bmany - ツールバーのブックマークを一覧表示', true);
key.setGlobalKey(['C-b', 'b'], function (ev, arg) {
ext.exec("list-hateb-comments", arg, ev);
}, 'このページのはてなブックマークコメントを一覧表示', true);
key.setViewKey([['j'], ['SPC']], function (ev) {
plugins.scrollet.scrollByScrollSize(0.3, true);
}, 'ScrollBy * 画面サイズ ↓');
key.setViewKey([['k'], ['S-SPC']], function (ev) {
plugins.scrollet.scrollByScrollSize(0.3, false);
}, 'ScrollBy * 画面サイズ ↑');
key.setViewKey('h', function (aEvent, aArg) {
ext.exec("hok-start-foreground-mode", aArg);
}, 'Hit a Hint を開始', true);
key.setViewKey('H', function (aEvent, aArg) {
ext.exec("hok-start-background-mode", aArg);
}, 'リンクをバックグラウンドで開く Hit a Hint を開始', true);
key.setGlobalKey(['C-b', 'i'], function (ev, arg) {
ext.exec('list-hateb-items', arg, ev);
}, 'はてなブックマークのアイテムを一覧表示しジャンプ', true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.