25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

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