You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

897 lines
34 KiB

  1. // ========================== KeySnail Init File =========================== //
  2. // この領域は, GUI により設定ファイルを生成した際にも引き継がれます
  3. // 特殊キー, キーバインド定義, フック, ブラックリスト以外のコードは, この中に書くようにして下さい
  4. // ========================================================================= //
  5. //{{%PRESERVE%
  6. // prompt.rows = 12;
  7. // prompt.useMigemo = false;
  8. // prompt.migemoMinWordLength = 2;
  9. // prompt.displayDelayTime = 300;
  10. // command.kill.killRingMax = 15;
  11. // command.kill.textLengthMax = 8192;
  12. //userscript.addLoadPath(".");
  13. //userscript.require("verticaltab.js");
  14. //////////////////////////////////////
  15. //// sitelocalkeymap
  16. var local = {};
  17. plugins.options["site_local_keymap.local_keymap"] = local;
  18. function fake(k, i) function () { key.feed(k, i); };
  19. function pass(k, i) [k, fake(k, i)];
  20. function ignore(k, i) [k, null];
  21. // ext.add("ext-name", function () {}, "ext description");
  22. // style.register("");
  23. // local["^http://"] = [['a', function(ev, arg){}],];
  24. ///////////////////////////////////////////
  25. //// firefox
  26. // style.register("#bookmarksPanel > hbox,#history-panel > hbox {display: none !important;} //#urlbar-container{max-width: 500px !important;}");
  27. util.setPrefs(
  28. {
  29. "browser.tabs.loadDivertedInBackground": true,
  30. "dom.disable_window_open_feature.location": false,
  31. "dom.max_script_run_time": 30,
  32. "browser.bookmarks.max_backups":0,
  33. "browser.urlbar.autocomplete.enabled":false,
  34. "browser.cache.memory.capacity":16384,
  35. "browser.sessionhistory.max_total_viewers":8,
  36. "browser.download.manager.closeWhenDone":true,
  37. "browser.download.useDownloadDir":false,
  38. "browser.tabs.closeWindowWithLastTab":false,
  39. "network.dns.disableIPv6":true
  40. }
  41. );
  42. ///////////////////////////////////
  43. //検索エンジン
  44. plugins.options["search-url-list"] = [
  45. ["bing","http://bing.com/search?q=%q"],
  46. ["yatwitter search","http://yats-data.com/yats/search?query=%q"],
  47. ["twitter search","http://search.twitter.com/search?q=%q&lang=all"],
  48. ["2ch","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  49. ["I\'m feelig lucky!","http://www.google.co.jp/search?q=%q&btnI=kudos"],
  50. ["uncyclopedia","http://ja.uncyclopedia.info/wiki/%q"],
  51. ["wikipedia","http://ja.wikipedia.org/wiki/%q"],
  52. ["nicovideo.jp","http://www.nicovideo.jp/search/%q"],
  53. ["alc","http://eow.alc.co.jp/%q/UTF-8/"],
  54. ["google map","http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  55. ["weblio","http://www.weblio.jp/content_find?query=%q"],
  56. ["shoutcast","http://www.shoutcast.com/Internet-Radio/%q"],
  57. ["10sr.posterous.com","http://www.google.com/search?q=%q&ie=UTF-8&oe=UTF-8&hl=ja&domains=10sr.posterous.com&sitesearch=10sr.posterous.com"],
  58. ["delicious 10sr","http://delicious.com/10sr?addtag=%q&setcount=50&opennew=1"],
  59. ["open raw","%r"],
  60. ];
  61. plugins.options["my-keysnail-bookmarks"] = [
  62. "twitter.com",
  63. ];
  64. //sitelocal
  65. //////////////////////////////////////////
  66. // 2ch chaika
  67. local["^http://127.0.0.1:8823/thread/"] = [
  68. ['k', function (ev, arg) {
  69. curl = window.content.location.href;
  70. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  71. window.content.location.href = kurl;
  72. }
  73. ],
  74. ];
  75. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  76. ['k', function (ev, arg) {
  77. var url = window.content.location.href;
  78. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  79. var result = url.match(pt);
  80. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/", result[1], result[2], result[3]);
  81. window.content.location.href = k;
  82. }
  83. ],
  84. ];
  85. /////////////////////////////////////////
  86. // feedly用マップ
  87. local["^http://www.feedly.com/"] = [
  88. ['d', null],
  89. ['j', null],
  90. ['k', null],
  91. ['n', null],
  92. ['p', null],
  93. ['o', null],
  94. ['b', null],
  95. ['S', null],
  96. ['s', null],
  97. ['?', null],
  98. ['l', function (ev, arg) {window.content.location.href = "http://www.feedly.com/home#latest";}],
  99. ['r', null],
  100. ['x', function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("g", true));}],
  101. [['t', 'p'], function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("t", true));}],
  102. [['t', 'w'], function (ev, arg) {ext.exec("twitter-client-tweet", arg, ev);}],
  103. ];
  104. /////////////////////////////////////////
  105. //nicovideo用
  106. local["http://(www|tw|es|de|)\.nicovideo\.jp\/watch/*"] = [
  107. ["i", function (ev, arg) { ext.exec("nicoinfo", arg); }],
  108. ["p", function (ev, arg) { ext.exec("nicopause", arg); }],
  109. ["o", function (ev, arg) { ext.exec("nicommentvisible", arg); }],
  110. ["m", function (ev, arg) { ext.exec("nicomute", arg); }],
  111. [".", function (ev, arg) { ext.exec("nicovolumeIncrement", arg); }],
  112. [",", function (ev, arg) { ext.exec("nicovolumeDecrement", arg); }],
  113. ['f', function (ev, arg) {
  114. curl = window.content.location.href;
  115. kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  116. window.content.location.href = kurl;
  117. }
  118. ],
  119. ];
  120. /////////////////////////////////////////
  121. // tumblr/dashboard
  122. local["^http://www.tumblr.com/dashboard"] = [
  123. // ["C-<left>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(-1, true); }],
  124. // ["C-<right>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(1, true); }],
  125. ["<left>", function (ev, arg) {window.content.location.href = "http://www.tumblr.com/dashboard"; }],
  126. // ["<right>", null],
  127. ["J", function (ev, arg) {
  128. if (window.loadURI) {
  129. loadURI("javascript:(function(){b=20;s=100;t=document.getElementById('next_page_link').href.split('/')[5];max=t.substr(0,t.length-5);min=max-s;i=Math.floor(Math.random()*(max-min)+min);u=(i<b)?'http://www.tumblr.com/dashboard':'http://www.tumblr.com/dashboard/2/'+i+'00000';window.content.location.href=u;}())");
  130. }
  131. }],
  132. ];
  133. ///////////////////////////////////
  134. //tanythhing用
  135. plugins.options["tanything_opt.keymap"] = {
  136. "\\" : "prompt-cancel",
  137. "j" : "prompt-next-completion",
  138. "k" : "prompt-previous-completion",
  139. "o" : "localOpen",
  140. ":" : "localClose",
  141. "L" : "localMovetoend"
  142. };
  143. //////////////////////////////////////////
  144. // yatc
  145. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  146. plugins.options["twitter_client.popup_new_statuses"] = false;
  147. plugins.options["twitter_client.automatically_begin"] = false;
  148. plugins.options["twitter_client.automatically_begin_list"] = false;
  149. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  150. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  151. plugins.options["twitter_client.tweet_keymap"] = {
  152. "C-RET" : "prompt-decide",
  153. "RET" : ""
  154. };
  155. plugins.options["twitter_client.jmp_id"] = "10sr";
  156. plugins.options["twitter_client.jmp_key"] = "R_c51f889a77cb4b4e993ed868f65083f5";
  157. ////////////////////////////////////////////
  158. // エクステ
  159. /////////////////////////////////////
  160. // google itranslate
  161. (function(){
  162. let targetLang = "ja"; // target lang to translate into
  163. let alternativeLang = "en"; // if given word is in targetLang, use this instead as a target lang
  164. function translate(word, target, next) {
  165. next("", "", " getting...");
  166. const base = "https://www.googleapis.com/language/translate/v2?key=%s&q=%s&target=%s";
  167. const apikey = "AIzaSyBq48p8NhFgaJ1DfUJ5ltbwLxeXpjEL86A";
  168. let ep = util.format(base, apikey, encodeURIComponent(word), target);
  169. util.httpGet(ep, false, function (res) {
  170. if (res.status === 200) {
  171. let json = decodeJSON(res.responseText);
  172. let srclang = json.data.translations[0].detectedSourceLanguage;
  173. if (target == srclang) {
  174. lookupword(word, alternativeLang);
  175. } else {
  176. let result = json.data.translations[0].translatedText;
  177. next(srclang, target, result);
  178. }
  179. } else {
  180. next("", "", "ERROR!");
  181. }
  182. });
  183. };
  184. function echo(srclang, from, tglang, to){
  185. display.echoStatusBar(srclang + " : " + from + " -> " + tglang + " : " + to);
  186. };
  187. function decodeJSON(json) {
  188. return util.safeEval("(" + json + ")");
  189. };
  190. function lookupword(word, target){
  191. translate(word, target, function (src, tg, translated) {
  192. echo(src, word, tg, translated);
  193. });
  194. };
  195. function read (aInitialInput) {
  196. let prevText = "";
  197. prompt.reader({
  198. message : "word or sentence to translate:",
  199. initialinput : aInitialInput,
  200. onChange: function (arg) {
  201. let word = arg.textbox.value;
  202. if (word !== prevText) {
  203. prevText = word;
  204. lookupword(word, targetLang);
  205. }
  206. },
  207. callback: function (s){},
  208. });
  209. };
  210. ext.add("google-itranslate",function(){read(content.document.getSelection() || "");},"google itranslate");
  211. })();
  212. //////////////////////////////////////
  213. //
  214. ext.add("restart-firefox-add-menu", function(){
  215. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  216. var elm = document.createElementNS(XUL_NS, "menuitem");
  217. elm.setAttribute("label", "Restart Firefox");
  218. elm.setAttribute("id", "menu_RestartFirefoxKs")
  219. elm.setAttribute("oncommand", function(){
  220. ext.exec("restart-firefox");});
  221. var menu = document.getElementById("menu_FilePopup");
  222. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  223. menu.appendChild(elm);
  224. }, "add restart firefox menu");
  225. //////////////////////////////////////
  226. //
  227. ext.add("fullscreen-page",function (ev) {
  228. getBrowser().selectedTab = getBrowser().addTab("http://home.tiscali.nl/annejan/swf/timeline.swf");
  229. BrowserFullScreen();
  230. }, "fullscreen page");
  231. //////////////////////////////////////
  232. // restart firefox
  233. // http://keysnail.g.hatena.ne.jp/Shinnya/20100723/1279878815
  234. ext.add("restart-firefox",function (ev) {
  235. const nsIAppStartup = Components.interfaces.nsIAppStartup;
  236. // Notify all windows that an application quit has been requested.
  237. var os = Components.classes["@mozilla.org/observer-service;1"]
  238. .getService(Components.interfaces.nsIObserverService);
  239. var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
  240. .createInstance(Components.interfaces.nsISupportsPRBool);
  241. os.notifyObservers(cancelQuit, "quit-application-requested", null);
  242. // Something aborted the quit process.
  243. if (cancelQuit.data)
  244. return;
  245. // Notify all windows that an application quit has been granted.
  246. os.notifyObservers(null, "quit-application-granted", null);
  247. // Enumerate all windows and call shutdown handlers
  248. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  249. .getService(Components.interfaces.nsIWindowMediator);
  250. var windows = wm.getEnumerator(null);
  251. while (windows.hasMoreElements()) {
  252. var win = windows.getNext();
  253. if (("tryToClose" in win) && !win.tryToClose())
  254. return;
  255. }
  256. Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
  257. .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
  258. }, "restart firefox");
  259. /////////////////////////////////////////
  260. // copy feed url
  261. ext.add("copy-url", function () {
  262. const doc = content.document;
  263. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  264. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  265. 'link[type="application/atom+xml"]'])))];
  266. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  267. for (i = 0; i < feeds.length; i++)
  268. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  269. feeds.unshift([window.content.document.title,window.content.location.href]);
  270. prompt.selector(
  271. {
  272. message : "Select Feed",
  273. collection : feeds,
  274. callback : function (i) {
  275. if (i >= 0)
  276. command.setClipboardText(feeds[i][1]);
  277. }
  278. }
  279. );
  280. }, "Copy url or feed url of current page");
  281. ///////////////////////////////////////
  282. // 評価しちゃうっぽい とりあえずこんな感じで
  283. ext.add("keysnail-setting-menu",function(){
  284. var settingmenulist = [["keysnail setting dialogue",function(){return function(){KeySnail.openPreference();};}],
  285. ["firefox addon manager",function(){return function(){BrowserOpenAddonsMgr();};}],
  286. ["reload .keysnail.js",function(){return function() {userscript.reload();};}],
  287. ["check for plugins update",function(){return function(){ext.exec("check-for-plugins-update");};}],
  288. ];
  289. prompt.selector(
  290. {
  291. message : "open setting dialog",
  292. collection : settingmenulist,
  293. callback : function (i) { settingmenulist[i][1]()(); },
  294. });
  295. },"open keysnail setting menu");
  296. //////////////////////////
  297. //プラグイン一括アップデート
  298. ext.add("check-for-plugins-update", function () {
  299. [p for (p in plugins.context)].forEach(function (p) { try { userscript.updatePlugin(p); } catch(e) {} });
  300. }, "Check for all plugin's update");
  301. ////////////////////////
  302. //マルチプルタブハンドラ
  303. ext.add("multiple-tab-handler-close-selected-and-current-tabs", function () {
  304. BrowserCloseTabOrWindow();
  305. // if (MultipleTabService) {
  306. // //BrowserCloseTabOrWindow();
  307. // //MultipleTabService.setSelection(gBrowser.mCurrentTab, true);
  308. MultipleTabService.closeTabs(MultipleTabService.getSelectedTabs());
  309. // } else {
  310. // BrowserCloseTabOrWindow();}
  311. }, '選択タブと現在のタブを閉じる');
  312. ext.add("if-mth-exist", function() {
  313. if (MultipleTabService != undefined) display.echoStatusBar("true");
  314. },'if mth exist');
  315. ////////////////////////
  316. // instapaper
  317. ext.add("instapaper-add-this-page-and-close",function(){
  318. var url = window.content.location.href;
  319. var title = window.content.document.title;
  320. var tab = gBrowser.selectedTab;
  321. var username = "8slashes+instapaper@gmail.com";
  322. var password = "";
  323. var passwordManager = (Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager));
  324. var logins = passwordManager.findLogins({}, "http://www.instapaper.com", "", null);
  325. for (var i = 0; i < logins.length; i++) {
  326. if (logins[i].username == username) {
  327. password = logins[i].password;
  328. break;
  329. }
  330. }
  331. var comment = "";
  332. // prompt.read("Instapaper comment:",function(cm){
  333. // if(cm){comment = cm;}
  334. // });
  335. display.echoStatusBar("Instapaper: adding " + url + "...");
  336. util.httpPost("https://www.instapaper.com/api/add",
  337. {"username" : encodeURIComponent(username),
  338. "password" : password,
  339. "url" : encodeURIComponent(url),
  340. "title" : encodeURIComponent(title),},
  341. function (xhr) {
  342. display.echoStatusBar(xhr.status);
  343. if (xhr.readyState == 4 && xhr.status == 201) {
  344. // var title = decodeURIComponent(xhr.getResponseHeader("X-Instapaper-Title")); //超文字化けする
  345. try {
  346. Components.classes['@mozilla.org/alerts-service;1'].
  347. getService(Components.interfaces.nsIAlertsService).
  348. showAlertNotification(null, "Instapaper", "Page " + title + " added successfully", false, '', null);
  349. } catch(e) {
  350. // prevents runtime error on platforms that don't implement nsIAlertsService
  351. }
  352. display.echoStatusBar("Instapaper: adding " + url + "...done.");
  353. gBrowser.removeTab(tab);
  354. } else{
  355. display.echoStatusBar("Instapaper: Something wrong has happended!");
  356. if (window.loadURI) {
  357. loadURI("javascript:function%20iprl5(){var%20d=document,z=d.createElement('scr'+'ipt'),b=d.body,l=d.location;try{if(!b)throw(0);d.title='(Saving...)%20'+d.title;z.setAttribute('src',l.protocol+'//www.instapaper.com/j/mt8YO6Cuosmf?u='+encodeURIComponent(l.href)+'&t='+(new%20Date().getTime()));b.appendChild(z);}catch(e){alert('Please%20wait%20until%20the%20page%20has%20loaded.');}}iprl5();void(0)");
  358. }
  359. }
  360. });
  361. },'instapaper add page and close tab when done without error.');
  362. ////////////////////////
  363. //検索
  364. ext.add("query-then-engine", function () {
  365. prompt.reader({message : "Search Word?:",
  366. callback : function (q) {
  367. if (q) {
  368. prompt.selector({ message : "search \"" + q + "\" with?",
  369. collection : plugins.options["search-url-list"],
  370. width : [20,80],
  371. callback : function (i) { getBrowser().selectedTab = getBrowser().addTab(plugins.options["search-url-list"][i][1].replace("%r",q).replace("%q",encodeURIComponent(q))); },
  372. });
  373. };
  374. },
  375. initialInput : content.document.getSelection() || "",
  376. });
  377. }, "enter search word and then select engine");
  378. ///////////////////////
  379. //diggler
  380. ext.add("dig-url", function () {
  381. var url = window.content.location.href;
  382. var nsurl = [];
  383. var pname = "";
  384. var ssurl = [];
  385. var durl = [];
  386. nsurl = url.split("#");
  387. var pname = nsurl[1];
  388. ssurl = nsurl[0].split("/");
  389. durl[0] = ssurl[0] + "//" + ssurl[2];
  390. ssurl.splice(0,3);
  391. for (var i = 0; i < ssurl.length; i++){
  392. var durlsaved = durl[0];
  393. durl.unshift(durlsaved + "/" + ssurl[i]);
  394. };
  395. if (pname) {
  396. var durlfull = durl[0] + "#"+ pname;
  397. durl.unshift(durlfull);
  398. };
  399. prompt.selector({ message : "dig " + url,
  400. collection : durl,
  401. callback : function (i) { window.content.location.href = durl[i]; },
  402. });
  403. },"keysnail diggler ");
  404. /////////////////////////////////////
  405. // 閉じたタブリスト
  406. ext.add("list-closed-tabs", function () {
  407. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  408. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  409. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  410. var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  411. if (!closedTabs.length)
  412. return void display.echoStatusBar("最近閉じたタブが見つかりませんでした", 2000);
  413. prompt.selector(
  414. {
  415. message : "select tab to undo:",
  416. collection : closedTabs,
  417. flags : [ICON | IGNORE, 0, 0],
  418. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  419. });
  420. }, "List closed tabs");
  421. ext.add("echo-closed-tabs", function () {
  422. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  423. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  424. // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  425. var lasttab = json.decode(ss.getClosedTabData(window))[0];
  426. dump = ""
  427. for (var i in lasttab) { dump += lasttab[i] + "\n"; }
  428. confirm(dump);
  429. }, "List closed tabs");
  430. ///////////////////////////////////////
  431. //
  432. ext.add("focus-on-content", function(){
  433. document.getElementById("searchbar").focus();
  434. document.commandDispatcher.advanceFocus();
  435. document.commandDispatcher.advanceFocus();
  436. }, "forcus on content");
  437. ext.add("_focus-on-content", function(){
  438. gBrowser.focus();
  439. _content.focus();
  440. }, "focus on content");
  441. ext.add("hide-sidebar", function(){
  442. var sidebarBox = document.getElementById("sidebar-box");
  443. if (!sidebarBox.hidden) {
  444. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  445. }
  446. }, "hide-sidebar");
  447. //}}%PRESERVE%
  448. // ========================================================================= //
  449. // ========================= Special key settings ========================== //
  450. key.quitKey = "ESC";
  451. key.helpKey = "C-h";
  452. key.escapeKey = "C-q";
  453. key.macroStartKey = "";
  454. key.macroEndKey = "";
  455. key.universalArgumentKey = "C-u";
  456. key.negativeArgument1Key = "C--";
  457. key.negativeArgument2Key = "C-M--";
  458. key.negativeArgument3Key = "M--";
  459. key.suspendKey = "Not defined";
  460. // ================================= Hooks ================================= //
  461. hook.setHook('KeySnailInitialized', function () {
  462. ext.exec("shiitake-toggle-style");
  463. });
  464. hook.setHook('KeyBoardQuit', function (aEvent) {
  465. command.closeFindBar();
  466. if (util.isCaretEnabled()) {
  467. command.resetMark(aEvent);
  468. } else {
  469. goDoCommand("cmd_selectNone");
  470. }
  471. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  472. });
  473. hook.addToHook('KeyBoardQuit', function (aEvent) {
  474. ext.exec("hide-sidebar");
  475. });
  476. hook.setHook('Unload', function () {
  477. util.getBrowserWindows().some(function (win) {
  478. if (win === window) {
  479. return false;
  480. }
  481. const ks = win.KeySnail;
  482. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  483. ks.setUpPluginUpdaterDelegator();
  484. return true;
  485. });
  486. });
  487. // ============================= Key bindings ============================== //
  488. key.setGlobalKey([['<delete>'], ['\\']], function (ev, arg) {
  489. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  490. }, 'escape');
  491. key.setGlobalKey('C-<right>', function () {
  492. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  493. }, 'ひとつ右のタブへ');
  494. key.setGlobalKey('C-<left>', function () {
  495. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  496. }, 'ひとつ左のタブへ');
  497. key.setGlobalKey('C-<up>', function () {
  498. var browser = getBrowser();
  499. if (browser.mCurrentTab.previousSibling) {
  500. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  501. } else {
  502. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  503. }
  504. }, '選択中のタブを右へ');
  505. key.setGlobalKey('C-<down>', function () {
  506. var browser = getBrowser();
  507. if (browser.mCurrentTab.nextSibling) {
  508. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  509. } else {
  510. browser.moveTabTo(browser.mCurrentTab, 0);
  511. }
  512. }, '選択中のタブを左へ');
  513. key.setGlobalKey('M-:', function (ev) {
  514. command.interpreter();
  515. }, 'JavaScript のコードを評価');
  516. key.setGlobalKey('C-g', function (ev, arg) {
  517. return;
  518. }, 'ignore');
  519. key.setViewKey('0', function (ev, arg) {
  520. var n = gBrowser.mCurrentTab._tPos;
  521. BrowserCloseTabOrWindow();
  522. gBrowser.selectedTab = gBrowser.mTabs[n];
  523. }, '閉じて次のタブ');
  524. key.setViewKey('x', function (aEvent, aArg) {
  525. ext.select(aArg, aEvent);
  526. }, 'エクステ一覧');
  527. key.setViewKey(['t', 'm'], function (ev, arg) {
  528. if (window.loadURI) {
  529. loadURI("javascript:window.location='http://api.tweetmeme.com/visit?url='+window.location;");
  530. }
  531. }, 'open with tweetmeme');
  532. key.setViewKey(['t', 'w'], function (ev, arg) {
  533. ext.exec("twitter-client-tweet", arg, ev);
  534. }, 'つぶやく', true);
  535. key.setViewKey(['t', 'p'], function (ev, arg) {
  536. ext.exec("twitter-client-tweet-this-page", arg, ev);
  537. }, 'このページのタイトルと URL を使ってつぶやく', true);
  538. key.setViewKey('u', function () {
  539. undoCloseTab();
  540. }, '閉じたタブを元に戻す');
  541. key.setViewKey('g', function () {
  542. goDoCommand("cmd_scrollTop");
  543. }, 'ページ先頭へ移動');
  544. key.setViewKey('G', function () {
  545. goDoCommand("cmd_scrollBottom");
  546. }, 'ページ末尾へ移動');
  547. key.setViewKey('r', function (aEvent) {
  548. BrowserReload();
  549. }, '再読み込み');
  550. key.setViewKey('m', function (ev, arg) {
  551. _fi.toogle();
  552. }, 'fetchimiをトグル');
  553. key.setViewKey('d', function (ev, arg) {
  554. if (window.loadURI) {
  555. loadURI("javascript:(function(){f='http://www.delicious.com/save?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=6&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv6','location=1,links=0,scrollbars=0,toolbar=0,width=550,height=585'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()");
  556. }
  557. }, 'deliciousでブックマーク');
  558. key.setViewKey('p', function (ev, arg) {
  559. if (window.loadURI) {
  560. loadURI("javascript:var%20b=document.body;var%20POSTEROUS___bookmarklet_domain='http://posterous.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='http://posterous.com/javascripts/bookmarklet2.js');void(b.appendChild(z));}else{}");
  561. }
  562. }, 'posterousに投稿');
  563. key.setViewKey('SPC', function (ev, arg) {
  564. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  565. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  566. }, 'タブの選択をトグルして次のタブ');
  567. key.setViewKey('S-SPC', function (ev, arg) {
  568. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  569. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  570. }, 'タブの選択をトグルして前のタブ');
  571. key.setViewKey('z', function (ev, arg) {
  572. ext.exec("keysnail-setting-menu", arg, ev);
  573. }, 'open keysnail setting menu', true);
  574. key.setViewKey('T', function (ev, arg) {
  575. ext.exec("google-itranslate", arg, ev);
  576. }, 'google itranslate', true);
  577. key.setViewKey('l', function (ev, arg) {
  578. var n = gBrowser.mCurrentTab._tPos;
  579. gBrowser.moveTabTo(gBrowser.mCurrentTab, gBrowser.mTabContainer.childNodes.length - 1);
  580. gBrowser.selectedTab = gBrowser.mTabs[n];
  581. }, 'このタブを後回し');
  582. key.setViewKey('C-SPC', function (ev, arg) {
  583. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  584. }, 'タブの選択をトグル');
  585. key.setViewKey('s', function (ev, arg) {
  586. var n = gBrowser.mCurrentTab._tPos;
  587. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  588. if (n != 0) {
  589. gBrowser.selectedTab = gBrowser.mTabs[n];
  590. }
  591. }, 'このタブを保持する');
  592. key.setViewKey('U', function (ev, arg) {
  593. ext.exec("list-closed-tabs", arg, ev);
  594. }, 'List closed tabs', true);
  595. key.setViewKey('e', function () {
  596. command.focusElement(command.elementsRetrieverTextarea, 0);
  597. }, '最初のインプットエリアへフォーカス', true);
  598. key.setViewKey('S', function (ev, arg) {
  599. if (window.loadURI) {
  600. loadURI("javascript:var%20b=document.body;var%20GR________bookmarklet_domain='https://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='https://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}");
  601. }
  602. }, 'google reader share');
  603. key.setViewKey('!', function (ev, arg) {
  604. shell.input();
  605. }, 'Command system');
  606. key.setViewKey('b', function (ev, arg) {
  607. BarTap.putOnTap(gBrowser.mCurrentTab, gBrowser);
  608. }, 'bartab put on tab');
  609. key.setViewKey('R', function () {
  610. BrowserReloadSkipCache();
  611. }, '更新(キャッシュを無視)');
  612. key.setViewKey('<backspace>', function () {
  613. BrowserBack();
  614. }, '戻る');
  615. key.setViewKey('S-<backspace>', function () {
  616. BrowserForward();
  617. }, '進む');
  618. key.setViewKey('q', function (ev, arg) {
  619. ext.exec("query-then-engine", arg, ev);
  620. }, 'enter search word and then select engine', true);
  621. key.setViewKey('D', function (ev, arg) {
  622. ext.exec("dig-url", arg, ev);
  623. }, 'keysnail diggler ', true);
  624. key.setViewKey('/', function () {
  625. command.iSearchForward();
  626. }, 'インクリメンタル検索', true);
  627. key.setViewKey('?', function (ev) {
  628. command.iSearchForwardKs(ev);
  629. }, 'Emacs ライクなインクリメンタル検索', true);
  630. key.setViewKey('a', function (ev, arg) {
  631. allTabs.open();
  632. }, 'alltabs.open');
  633. key.setViewKey('C', function (ev, arg) {
  634. ext.exec("copy-url", arg, ev);
  635. }, '選択タブと現在のタブを閉じる', true);
  636. key.setViewKey('I', function (ev, arg) {
  637. ext.exec("instapaper-add-this-page-and-close", arg, ev);
  638. }, 'instapaper add page', true);
  639. key.setViewKey('<left>', function (ev) {
  640. goDoCommand("cmd_scrollPageUp");
  641. }, '一画面分スクロールアップ');
  642. key.setViewKey('<right>', function (ev) {
  643. goDoCommand("cmd_scrollPageDown");
  644. }, '一画面スクロールダウン');
  645. key.setViewKey('C-w', function (ev) {
  646. command.copyRegion(ev);
  647. }, '選択中のテキストをコピー');
  648. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  649. return;
  650. }, 'ignore');
  651. key.setEditKey(['C-x', 'h'], function (ev) {
  652. command.selectAll(ev);
  653. }, '全て選択', true);
  654. key.setEditKey([['C-x', 'u'], ['C-_']], function (ev) {
  655. display.echoStatusBar("Undo!", 2000);
  656. goDoCommand("cmd_undo");
  657. }, 'アンドゥ');
  658. key.setEditKey(['C-x', 'r', 'd'], function (ev, arg) {
  659. command.replaceRectangle(ev.originalTarget, "", false, !arg);
  660. }, '矩形削除', true);
  661. key.setEditKey(['C-x', 'r', 't'], function (ev) {
  662. prompt.read("String rectangle: ", function (aStr, aInput) {command.replaceRectangle(aInput, aStr);}, ev.originalTarget);
  663. }, '矩形置換', true);
  664. key.setEditKey(['C-x', 'r', 'o'], function (ev) {
  665. command.openRectangle(ev.originalTarget);
  666. }, '矩形行空け', true);
  667. key.setEditKey(['C-x', 'r', 'k'], function (ev, arg) {
  668. command.kill.buffer = command.killRectangle(ev.originalTarget, !arg);
  669. }, '矩形キル', true);
  670. key.setEditKey(['C-x', 'r', 'y'], function (ev) {
  671. command.yankRectangle(ev.originalTarget, command.kill.buffer);
  672. }, '矩形ヤンク', true);
  673. key.setEditKey([['C-SPC'], ['C-@']], function (ev) {
  674. command.setMark(ev);
  675. }, 'マークをセット', true);
  676. key.setEditKey('C-o', function (ev) {
  677. command.openLine(ev);
  678. }, '行を開く (Open line)');
  679. key.setEditKey('C-\\', function (ev) {
  680. display.echoStatusBar("Redo!", 2000);
  681. goDoCommand("cmd_redo");
  682. }, 'リドゥ');
  683. key.setEditKey('C-a', function (ev) {
  684. command.beginLine(ev);
  685. }, '行頭へ移動');
  686. key.setEditKey('C-e', function (ev) {
  687. command.endLine(ev);
  688. }, '行末へ');
  689. key.setEditKey('M-h', function (ev) {
  690. command.previousChar(ev);
  691. }, '一文字左へ移動');
  692. key.setEditKey('M-f', function (ev) {
  693. command.forwardWord(ev);
  694. }, '一単語右へ移動');
  695. key.setEditKey('M-b', function (ev) {
  696. command.backwardWord(ev);
  697. }, '一単語左へ移動');
  698. key.setEditKey('M-j', function (ev) {
  699. command.nextLine(ev);
  700. }, '一行下へ');
  701. key.setEditKey('M-k', function (ev) {
  702. command.previousLine(ev);
  703. }, '一行上へ');
  704. key.setEditKey('C-v', function (ev) {
  705. command.pageDown(ev);
  706. }, '一画面分下へ');
  707. key.setEditKey('M-v', function (ev) {
  708. command.pageUp(ev);
  709. }, '一画面分上へ');
  710. key.setEditKey('M-<', function (ev) {
  711. command.moveTop(ev);
  712. }, 'テキストエリア先頭へ');
  713. key.setEditKey('M->', function (ev) {
  714. command.moveBottom(ev);
  715. }, 'テキストエリア末尾へ');
  716. key.setEditKey('C-d', function (ev) {
  717. goDoCommand("cmd_deleteCharForward");
  718. }, '次の一文字削除');
  719. key.setEditKey('C-h', function (ev) {
  720. goDoCommand("cmd_deleteCharBackward");
  721. }, '前の一文字を削除');
  722. key.setEditKey('M-d', function (ev) {
  723. command.deleteForwardWord(ev);
  724. }, '次の一単語を削除');
  725. key.setEditKey([['C-<backspace>'], ['M-<delete>']], function (ev) {
  726. command.deleteBackwardWord(ev);
  727. }, '前の一単語を削除');
  728. key.setEditKey('M-u', function (ev, arg) {
  729. command.wordCommand(ev, arg, command.upcaseForwardWord, command.upcaseBackwardWord);
  730. }, '次の一単語を全て大文字に (Upper case)');
  731. key.setEditKey('M-c', function (ev, arg) {
  732. command.wordCommand(ev, arg, command.capitalizeForwardWord, command.capitalizeBackwardWord);
  733. }, '次の一単語をキャピタライズ');
  734. key.setEditKey('C-k', function (ev) {
  735. command.killLine(ev);
  736. }, 'カーソルから先を一行カット (Kill line)');
  737. key.setEditKey('C-y', command.yank, '貼り付け (Yank)');
  738. key.setEditKey('M-y', command.yankPop, '古いクリップボードの中身を順に貼り付け (Yank pop)', true);
  739. key.setEditKey('C-M-y', function (ev) {
  740. if (!command.kill.ring.length) {
  741. return;
  742. }
  743. let (ct = command.getClipboardText()) (!command.kill.ring.length || ct != command.kill.ring[0]) &&
  744. command.pushKillRing(ct);
  745. prompt.selector({message: "Paste:", collection: command.kill.ring, callback: function (i) {if (i >= 0) {key.insertText(command.kill.ring[i]);}}});
  746. }, '以前にコピーしたテキスト一覧から選択して貼り付け', true);
  747. key.setEditKey('C-w', function (ev) {
  748. goDoCommand("cmd_copy");
  749. goDoCommand("cmd_delete");
  750. command.resetMark(ev);
  751. }, '選択中のテキストを切り取り (Kill region)', true);
  752. key.setEditKey('M-n', function (ev) {
  753. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  754. }, '次のテキストエリアへフォーカス');
  755. key.setEditKey('M-p', function (ev) {
  756. command.walkInputElement(command.elementsRetrieverTextarea, false, true);
  757. }, '前のテキストエリアへフォーカス');
  758. key.setEditKey('M-w', function (ev) {
  759. command.copyRegion(ev);
  760. }, '選択中のテキストをコピー');
  761. key.setEditKey('M-l', function (ev) {
  762. command.nextChar(ev);
  763. }, '一文字右へ移動');