Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

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