No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

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