選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

1298 行
41 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. // Original is at https://gist.github.com/Griever/62715
  13. ext.add("open-bookmarks-in-new-tab", function(){
  14. // this makes all clicks open in new tab.
  15. // return;
  16. // test if firefox 12
  17. if (12 > parseFloat(Cc['@mozilla.org/xre/app-info;1'].
  18. getService(Ci.nsIXULAppInfo).version)) {
  19. return;
  20. }
  21. // I cannot fully understand what happen but keysnail emit error
  22. // *after* initialization of firefox finished successfully and I assured
  23. // that new tabs open as I expect when clicking bookmarks, for example,
  24. // when I try to tweet using the twitter keysnail plugin, with error
  25. // message saying "whereToOpenLink is undefined.".
  26. // if no modifier key pressed open in new tab.
  27. try {
  28. var whereToOpenLink_org = new String(window.whereToOpenLink.toString());
  29. window.whereToOpenLink = eval(
  30. "(" +
  31. whereToOpenLink_org.replace(
  32. '{',
  33. '{ if(!e || ' +
  34. '(!e.ctrlKey && !e.shiftKey && !e.metaKey && ' +
  35. '!(e.altKKey && !ignoreAlt))) ' +
  36. 'return "tab";'
  37. ) +
  38. ")"
  39. );
  40. } catch (e if e instanceof TypeError) {
  41. return;
  42. }
  43. // This is useless because this makes reload open new tab.
  44. // window.whereToOpenLink = function(e, ib, ia){ return "tab"; };
  45. }, "open in new tab");
  46. // ext.exec("open-bookmarks-in-new-tab");
  47. //////////////////////////////////////
  48. //// sitelocalkeymap
  49. var local = {};
  50. plugins.options["site_local_keymap.local_keymap"] = local;
  51. function fake(k, i) function(){ key.feed(k, i); };
  52. function pass(k, i) [k, fake(k, i)];
  53. function ignore(k, i) [k, null];
  54. // ext.add("ext-name", function () {}, "ext description");
  55. // style.register("");
  56. // local["^http://"] = [['a', function(ev, arg){}],];
  57. ///////////////////////////////////////////
  58. //// firefox
  59. // style.register("#bookmarksPanel > hbox,#history-panel > hbox {" +
  60. // "display: none !important;}" +
  61. // " //#urlbar-container{max-width: 500px !important;}");
  62. // style.register( //not work
  63. // <><![CDATA[
  64. // input,textarea {
  65. // font-family: monospace !important;
  66. // }
  67. // ]]></>.toString()
  68. // );
  69. style.register(
  70. '@-moz-document ' +
  71. 'url-prefix(\"http://www.tumblr.com/\"), ' +
  72. 'url-prefix(\"https://www.tumblr.com/\") ' +
  73. '{ #pagination {' +
  74. 'position: fixed;' +
  75. 'bottom: 50px;' +
  76. 'right: 100px;' +
  77. 'padding-right: 0px !important' +
  78. '} }' , style.XHTML);
  79. ///////////////////////////////////
  80. //search engine
  81. plugins.options["search-url-list"] = [
  82. ["DuckDuckGo", "https://duckduckgo.com/?q=%q"],
  83. ["Bing", "http://bing.com/search?q=%q"],
  84. ["yatwitter search", "http://yats-data.com/yats/search?query=%q"],
  85. ["Yahoo Realtime",
  86. "http://realtime.search.yahoo.co.jp/search?rkf=1&ei=UTF-8&p=%q"],
  87. ["Twitter Search", "http://twitter.com/search?q=%q&lang=all"],
  88. ["Tospy", "http://topsy.com/s?allow_lang=ja&q=%q"],
  89. ["2ch syoboi.jp", "http://ff2ch.syoboi.jp/?q=%q"],
  90. ["2ch-ranking","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  91. ["2ch ttsearch", "http://ttsearch.net/s2.cgi?k=%q&o=r"],
  92. ["I\'m feelig lucky!", "http://www.google.co.jp/search?q=%q&btnI=kudos"],
  93. ["Uncyclopedia", "http://ja.uncyclopedia.info/wiki/%q"],
  94. ["Wikipedia", "http://ja.wikipedia.org/wiki/%q"],
  95. ["nicovideo.jp", "http://www.nicovideo.jp/search/%q"],
  96. ["alc", "http://eow.alc.co.jp/%q/UTF-8/"],
  97. ["google map",
  98. "http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  99. ["Weblio", "http://www.weblio.jp/content_find?query=%q"],
  100. ["ShoutCast", "http://www.shoutcast.com/Internet-Radio/%q"],
  101. ["Delicious 10sr", "http://delicious.com/10sr/%q"],
  102. ["Open raw", "%r"]
  103. ];
  104. plugins.options["my-keysnail-bookmarks"] = [
  105. "twitter.com"
  106. ];
  107. // sitelocal keymap
  108. //////////////////////////////////////////
  109. // 2ch chaika
  110. // change chaika port every time firefox starts
  111. util.setIntPref("extensions.chaika.server_port.firefox",
  112. 8800 + Math.floor(Math.random() * 30));
  113. local["^http://127.0.0.1:88"] = [
  114. ['k', function(ev, arg){
  115. curl = window.content.location.href;
  116. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  117. window.content.location.href = kurl;
  118. }
  119. ]
  120. ];
  121. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  122. ['k', function(ev, arg){
  123. var url = window.content.location.href;
  124. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  125. var result = url.match(pt);
  126. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/",
  127. result[1], result[2], result[3]);
  128. window.content.location.href = k;
  129. }
  130. ]
  131. ];
  132. /////////////////////////////////////////
  133. // feedly
  134. local["^https?://(www\.|cloud\.|)feedly\.com/"] = [
  135. ['d', null],
  136. ['j', null],
  137. ['k', null],
  138. ['n', null],
  139. ['p', null],
  140. ['o', null],
  141. ['b', null],
  142. ['S', null],
  143. ['s', null],
  144. ['?', null],
  145. ['r', null],
  146. ['g', null],
  147. // ['x', function(ev, arg){
  148. // ev.target.dispatchEvent(key.stringToKeyEvent("g", true));
  149. // }],
  150. // ['l', function(ev, arg){
  151. // var host = window.content.location.host;
  152. // if (host === "cloud.feedly.com" || host === "feedly.com") {
  153. // window.content.location.href = "http://" + host + "/#latest";
  154. // } else if (host === "www.feedly.com") {
  155. // window.content.location.href = "http://" + host + "/home#latest";
  156. // }
  157. // }],
  158. ['a', null],
  159. [['t', 'p'], function(ev, arg){
  160. ev.target.dispatchEvent(key.stringToKeyEvent("t", true));
  161. }],
  162. [['t', 'w'], function(ev, arg){
  163. ext.exec("twitter-client-tweet", arg, ev);
  164. }]
  165. ];
  166. /////////////////////////////////////////
  167. //nicovideo
  168. // local["http://(www|tw|es|de|)\.nicovideo\.jp\/(watch|playlist)/*"] = [
  169. // ["i", function(ev, arg){ ext.exec("nicoinfo", arg); }],
  170. // ["p", function(ev, arg){ ext.exec("nicopause", arg); }],
  171. // // ["o", function(ev, arg){ ext.exec("nicommentvisible", arg); }],
  172. // ["m", function(ev, arg){ ext.exec("nicomute", arg); }],
  173. // [".", function(ev, arg){ ext.exec("nicovolumeIncrement", arg); }],
  174. // [",", function(ev, arg){ ext.exec("nicovolumeDecrement", arg); }],
  175. // ['f', function(ev, arg){
  176. // curl = window.content.location.href;
  177. // kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  178. // window.content.location.href = kurl;
  179. // }
  180. // ]
  181. // ];
  182. /////////////////////////////////////////
  183. // tumblr/dashboard
  184. local["^http://www.tumblr.com/dashboard"] = [
  185. // ["C-<left>", function(ev, arg){
  186. // gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  187. // }],
  188. // ["C-<right>", function(ev, arg){
  189. // gBrowser.mTabContainer.advanceSelectedTab(1, true);
  190. // }],
  191. ["<left>", function(ev, arg){
  192. window.content.location.href = "http://www.tumblr.com/dashboard";
  193. }],
  194. ["<right>", null],
  195. ["J", function(ev, arg){
  196. if (window.loadURI) {
  197. 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;}())");
  198. }
  199. }]
  200. ];
  201. ///////////////////////////////////////////
  202. // plugin option
  203. plugins.options["builtin_commands_ext.ext_list"] = [
  204. "focus-to-prompt",
  205. "open-url-from-clipboard",
  206. "restart-firefox"
  207. ];
  208. plugins.options["instapaper.close_after_post"] = true;
  209. plugins.options["instapaper.initial_comment_function"] = function(){
  210. var now = new Date();
  211. return "[" + now.toString() + "]";
  212. };
  213. //////////////////////////////////////////
  214. // yatc
  215. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  216. plugins.options["twitter_client.popup_new_statuses"] = false;
  217. plugins.options["twitter_client.automatically_begin"] = false;
  218. plugins.options["twitter_client.automatically_begin_list"] = false;
  219. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  220. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  221. plugins.options["twitter_client.tweet_keymap"] = {
  222. "C-RET" : "prompt-decide",
  223. "RET" : ""
  224. };
  225. plugins.options["twitter_client.jmp_id"] = "10sr";
  226. plugins.options["twitter_client.jmp_key"] =
  227. "R_c51f889a77cb4b4e993ed868f65083f5";
  228. plugins.options["twitter_client.use_jmp"] = true;
  229. ////////////////////////////////////////////
  230. // my exts and functions
  231. var autoSaveTabList = (function(){
  232. const PREF_PREFIX = "extensions.keysnail.plugins.autosavetablist.";
  233. const PREF_DSTDIR = "dstdir";
  234. const PREF_ENABLED = "enabled";
  235. // use plugin option to set
  236. var save_interval = 60 * 10;
  237. // "/" for unix system
  238. const DIR_DELIM = userscript.directoryDelimitter;
  239. function selectDirectory(title){
  240. // open dialog and return nsILocalFile object
  241. // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile
  242. // this function blocks.
  243. var nsIFilePicker = Components.interfaces.nsIFilePicker;
  244. var fp = Components.classes["@mozilla.org/filepicker;1"].
  245. createInstance(nsIFilePicker);
  246. fp.init(window, title, nsIFilePicker.modeGetFolder);
  247. // block
  248. var res = fp.show();
  249. if (res !== nsIFilePicker.returnOK) {
  250. return null;
  251. }
  252. return fp.file;
  253. }
  254. function setup(){
  255. // set destination directory
  256. var dstdir = selectDirectory("Select Directory to Save Tab List");
  257. if (! dstdir) { return; }
  258. if (! dstdir.isWritable()) {
  259. display.notify("Directory is not writable");
  260. return;
  261. }
  262. util.setUnicharPref(PREF_PREFIX + PREF_DSTDIR, dstdir.path);
  263. }
  264. function genFileName(){
  265. function formatCurrent(){
  266. var d = new Date();
  267. function pad(n){
  268. return n < 10 ? '0' + n.toString() : n.toString()
  269. }
  270. return [
  271. d.getFullYear().toString(),
  272. pad(d.getMonth() + 1),
  273. pad(d.getDate()),
  274. "-",
  275. pad(d.getHours()),
  276. pad(d.getMinutes()),
  277. pad(d.getSeconds())
  278. ].join("");
  279. }
  280. return "tablist." + formatCurrent() + ".lst";
  281. }
  282. function getTabList(){
  283. // returns list of urls of current tabs.
  284. return [(function(){
  285. var browser = tab.linkedBrowser;
  286. var win = browser.contentWindow;
  287. // var title = tab.label;
  288. var url = win.location.href;
  289. return url;
  290. })() for each (tab in Array.slice(gBrowser.mTabContainer.childNodes))];
  291. // Array.slice is required?
  292. }
  293. function saveCurrentList(){
  294. var dstdir = util.getUnicharPref(PREF_PREFIX + PREF_DSTDIR);
  295. if (! dstdir) {
  296. display.showPopup("AutoSaveTabList",
  297. "Dest dir is not set yet. Run setup first");
  298. return;
  299. }
  300. var filename = genFileName();
  301. util.writeTextFile(
  302. getTabList().join("\n") + "\n",
  303. dstdir + userscript.directoryDelimiter + filename
  304. );
  305. display.showPopup("AutoSaveTabList",
  306. "Tab List saved: " + filename);
  307. }
  308. return {
  309. selectDirectory: selectDirectory,
  310. setup: setup,
  311. getTabList: getTabList,
  312. saveCurrentList: saveCurrentList
  313. };
  314. })();
  315. ext.add("astl-setup", autoSaveTabList.setup, "Auto save tab list - Setup");
  316. ext.add("astl-save-current", autoSaveTabList.saveCurrentList,
  317. "Auto save tab list - Save current list");
  318. var echoTabInfo = (function(){
  319. var currenttab;
  320. function _display(msg){
  321. display.prettyPrint(msg, {
  322. timeout: 1500,
  323. style: {
  324. "font-size": "18px",
  325. "font-family": "monospace"
  326. }
  327. });
  328. }
  329. function __display(msg){
  330. display.echoStatusBar(msg);
  331. }
  332. function echo(){
  333. var newtab = getBrowser().mCurrentTab;
  334. if (currenttab === newtab) {
  335. return;
  336. }
  337. currenttab = newtab;
  338. var len = getBrowser().tabs.length;
  339. var idx = currenttab._tPos;
  340. var title = window.content.document.title;
  341. var url = window.content.location.href;
  342. var doc = content ? content.document : document;
  343. var dBody = doc.body;
  344. if (dBody && !util.isFrameSetWindow(content)) {
  345. // if page has been prepared
  346. _display(
  347. "[" +
  348. (idx + 1).toString() + "/" +
  349. len.toString() + "] " +
  350. title + " <" +
  351. decodeURIComponent(url) + ">"
  352. );
  353. }
  354. }
  355. return {
  356. echo: echo
  357. };
  358. })();
  359. ext.add("open-remote-init-file", function(ev, arg){
  360. const URL = "https://raw.github.com/10sr/dotfiles/master/_keysnail.js";
  361. window.openUILinkIn(URL, "tab");
  362. }, "Open remote initialization file");
  363. var updateInitFile = (function(){
  364. const URL = "https://raw.github.com/10sr/dotfiles/master/_keysnail.js";
  365. // content/modules/userscript.js
  366. // copy file from aFile
  367. function placeFile(aFile, force) {
  368. var dstdir = util.getUnicharPref("extensions.keysnail.userscript.location");
  369. if (dstdir === "") {
  370. throw util.getLocaleString("failedToInstallFile", [aFile.leafName]) + " :: " + x;
  371. }
  372. try
  373. {
  374. // calc dir from path
  375. let destinationDir = util.openFile(dstdir);
  376. let destinationFile = util.openFile(dstdir);
  377. destinationFile.append(aFile.leafName);
  378. if (destinationFile.exists())
  379. {
  380. if (util.hashFile(aFile) === util.hashFile(destinationFile))
  381. {
  382. // no need to install this file
  383. return destinationFile;
  384. }
  385. let confirmed = force ||
  386. util.confirm(
  387. util.getLocaleString("overWriteConfirmationTitle"),
  388. util.getLocaleString("overWriteConfirmation",
  389. [destinationFile.path])
  390. );
  391. if (!confirmed) {
  392. throw util.getLocaleString("canceledByUser");
  393. }
  394. }
  395. aFile.moveTo(destinationDir, "");
  396. return destinationFile;
  397. }
  398. catch (x)
  399. {
  400. throw util.getLocaleString("failedToInstallFile",
  401. [aFile.leafName]) +
  402. " :: " + x;
  403. }
  404. }
  405. function updateFile() {
  406. util.httpGet(URL, false, function (req) {
  407. if (req.status !== 200) {
  408. util.message(req.responseText);
  409. }
  410. try {
  411. let name = util.getLeafNameFromURL(URL);
  412. let file = userscript.writeTextTmp(name, req.responseText);
  413. let installed = placeFile(file);
  414. util.message(installed.path + " installed");
  415. display.showPopup("update-init-file",
  416. installed.path + " installed")
  417. } catch (x) {
  418. util.message(
  419. "An error occured while installing required scripts :: " +
  420. x.message
  421. );
  422. display.showPopup(
  423. "update-init-file",
  424. "An error occured while installing required scripts :: " +
  425. x.message
  426. );
  427. }
  428. });
  429. }
  430. return {
  431. updateFile: updateFile
  432. };
  433. })();
  434. ext.add("update-init-file", updateInitFile.updateFile, "update init file");
  435. var importExportBookmarks = (function(){
  436. function getOrganizer(){
  437. // [How to call for Firefox bookmark dialog? - Stack Overflow]
  438. // (http://stackoverflow.com/questions/9158187/how-to-call-for-firefox-bookmark-dialog)
  439. Components.utils.import("resource://gre/modules/Services.jsm");
  440. var organizer = Services.wm.getMostRecentWindow("Places:Organizer");
  441. if (!organizer) {
  442. // No currently open places window,
  443. // so open one with the specified mode.
  444. openDialog("chrome://browser/content/places/places.xul",
  445. "",
  446. "chrome,toolbar=yes,dialog=no,resizable",
  447. "AllBookmarks");
  448. return null;
  449. } else {
  450. return organizer;
  451. }
  452. }
  453. ext.add("export-bookmarks", function(ev, arg){
  454. var organizer = getOrganizer();
  455. if (organizer) {
  456. organizer.PlacesOrganizer.exportBookmarks();
  457. }
  458. }, "export bookmarks");
  459. ext.add("import-bookmarks", function(ev, arg){
  460. var organizer = getOrganizer();
  461. if (organizer) {
  462. organizer.PlacesOrganizer.importBookmarks();
  463. }
  464. }, "import bookmarks");
  465. return {
  466. getOrganizer: getOrganizer
  467. };
  468. })();
  469. ext.add("my-index-html", function(ev, arg){
  470. homepath = util.getEnv("HOME");
  471. file = ".index.html";
  472. if (homepath) {
  473. path = "file://" + homepath + "/" + file;
  474. window.openUILinkIn(path, "tab");
  475. }
  476. }, "open my index.html");
  477. ext.add("strong-fullscreen", function(){
  478. var elemids = [
  479. "navigator-toolbox"
  480. ];
  481. BrowserFullScreen();
  482. var isfullscreen = window.fullScreen;
  483. for(var i = 0; i < elemids.length; i++){
  484. var elem = document.getElementById(elemids[i]);
  485. if(elem){
  486. if(isfullscreen){
  487. elem.style.display = "none";
  488. }else{
  489. elem.style.display = null;
  490. }
  491. }
  492. }
  493. var tabs = document.getElementById("verticaltabs-box");
  494. if(tabs){
  495. var pref_key = "extensions.verticaltabs.width";
  496. var pref_key_bak = pref_key + "_bak";
  497. if(isfullscreen){
  498. var width_orig = util.getIntPref(pref_key);
  499. util.setIntPref(pref_key_bak, width_orig);
  500. util.setIntPref(pref_key, 0);
  501. tabs.setAttribute("width", "0");
  502. }else if(parseInt(tabs.getAttribute("width") || "") === 0){
  503. var width_bak = util.getIntPref(pref_key_bak);
  504. util.setIntPref(pref_key, width_bak);
  505. tabs.setAttribute("width", width_bak.toString());
  506. }
  507. }
  508. }, "go fullscreen with hiding toolbar and tabbar");
  509. ext.add("bookmark-delicious", function(){
  510. f= 'http://www.delicious.com/save?url=' +
  511. encodeURIComponent(window.content.location.href) +
  512. '&title=' + encodeURIComponent(document.title) +
  513. '&notes=' + encodeURIComponent(
  514. '' + (window.getSelection ?
  515. window.getSelection() : (
  516. document.getSelection ?
  517. document.getSelection() :
  518. document.selection.createRange().text))) + '&v=6&';
  519. a = function(){
  520. if(! window.open(
  521. f + 'noui=1&jump=doclose',
  522. 'deliciousuiv6',
  523. 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){
  524. location.href = f + 'jump=yes';
  525. }
  526. };
  527. if(/Firefox/.test(navigator.userAgent)){
  528. setTimeout(a,0);
  529. }else{
  530. a();
  531. }
  532. }, "bookmark delicious");
  533. ext.add('view-page-source', function(){
  534. window.content.location.href = "view-source:" +
  535. window.content.location.href;
  536. }, 'view page source');
  537. ext.add('my-setpref', function(){
  538. util.setPrefs(
  539. {
  540. "browser.bookmarks.max_backups":0,
  541. "browser.cache.memory.capacity":16384,
  542. "browser.download.manager.closeWhenDone":true,
  543. "browser.download.useDownloadDir":false,
  544. "browser.fullscreen.autohide":false,
  545. "browser.search.openintab":true,
  546. "browser.sessionhistory.max_total_viewers":8,
  547. "browser.sessionstore.restore_on_demand":true,
  548. "browser.tabs.closeWindowWithLastTab":false,
  549. "browser.tabs.loadDivertedInBackground": true,
  550. "browser.urlbar.autocomplete.enabled":false,
  551. "browser.urlbar.trimURLs":false,
  552. "dom.disable_window_open_feature.location": false,
  553. "dom.max_script_run_time": 30,
  554. "extensions.chaika.bbsmenu.open_new_tab":true,
  555. "extensions.chaika.bbsmenu.open_single_click":false,
  556. "extensions.chaika.board.open_new_tab":true,
  557. "extensions.chaika.board.open_single_click":false,
  558. "extensions.foxage2ch.openThreadInTab":true,
  559. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  560. "extensions.saveimageinfolder.general-fileprefixvalue":
  561. "%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  562. "extensions.saveimageinfolder.usecache":true,
  563. "extensions.tabutils.openTabNext":1,
  564. "extensions.tabutils.styles.current":
  565. "{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  566. "extensions.tabutils.styles.unread":
  567. "{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}",
  568. "extensions.tabutils.TFS_Enable":false,
  569. "extensions.yass.edgetype":0,
  570. "extensions.yass.selectedpreset":"red",
  571. "font.default.x-western":"sans-serif",
  572. "gecko.handlerService.schemes.mailto.1.name":"Gmail",
  573. "general.warnOnAboutConfig":false,
  574. "keyword.URL":"http://www.bing.com/search?q=",
  575. "browser.search.defaultenginename":"Bing",
  576. "browser.search.defaulturl":"http://www.bing.com/search?q=",
  577. "network.dns.disableIPv6":true,
  578. "refcontrol.actions":
  579. "@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL",
  580. "scrapbook.tabs.open":true
  581. }
  582. );
  583. if(/^Linux/.test(navigator.platform)){
  584. util.setPrefs(
  585. {
  586. "browser.cache.disk.parent_directory":"/tmp",
  587. "browser.cache.disk.capacity":524288
  588. }
  589. );
  590. }
  591. display.showPopup("Keysnail", "My prefs done.");
  592. }, 'my setpref');
  593. ext.add('auto-install-plugins', function(ev, arg){
  594. var urls = [
  595. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  596. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  597. 'https://raw.github.com/mooz/keysnail/master/plugins/hok.ks.js',
  598. 'https://github.com/mooz/keysnail/raw/master/plugins/builtin-commands-ext.ks.js',
  599. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  600. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  601. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  602. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  603. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  604. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  605. 'https://raw.github.com/10sr/keysnail-plugin/master/pixiv_autojump.ks.js',
  606. 'https://raw.github.com/10sr/keysnail-plugin/master/list-current-urls.ks.js',
  607. 'https://gist.githubusercontent.com/10sr/1976942/raw/firefox-addon-manager.ks.js',
  608. 'https://gist.githubusercontent.com/958/1450594/raw/mstranslator.ks.js'
  609. ];
  610. function inst(a){
  611. if(a.length == 0){
  612. display.showPopup("auto-install-plugins",
  613. "All installation finished.");
  614. }else{
  615. var url = a.shift();
  616. var path = userscript.pluginDir +
  617. userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  618. if(plugins.context[path] === undefined){
  619. userscript.installPluginFromURL(url, function(){inst(a);});
  620. }else{
  621. inst(a);
  622. }
  623. }
  624. }
  625. inst(urls);
  626. }, 'Install plugins automatically if not installed yet.');
  627. ext.add('put-aside-this-page', function (ev, arg) {
  628. var n = getBrowser().mCurrentTab._tPos;
  629. getBrowser().moveTabTo(getBrowser().mCurrentTab, 0);
  630. if (n != 0) {
  631. getBrowser().selectedTab = getBrowser().mTabs[n];
  632. }
  633. }, 'put aside this page');
  634. ext.add('send-escape', function (ev, arg) {
  635. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  636. }, 'escape');
  637. ext.add("open-hatebu-comment", function (ev, arg) {
  638. var url = window.content.location.href.replace(/^[^/]*\/\//, "");
  639. window.content.location.href = "http://b.hatena.ne.jp/entry/" + url;
  640. }, 'hatebu');
  641. // ext.add("focus-on-content", function(){
  642. // let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  643. // gBrowser.focus();
  644. // content.focus();
  645. // }, "forcus on content");
  646. ext.add("hide-sidebar", function(){
  647. var sidebarBox = document.getElementById("sidebar-box");
  648. if (!sidebarBox.hidden) {
  649. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  650. }
  651. }, "hide-sidebar");
  652. ext.add("close-and-next-tab", function (ev, arg) {
  653. var n = getBrowser().mCurrentTab._tPos;
  654. getBrowser().removeCurrentTab();
  655. getBrowser().selectedTab = getBrowser().mTabs[n];
  656. }, "close and focus to next tab");
  657. //////////////////////////////////////
  658. //
  659. ext.add("restart-firefox-add-menu", function(){
  660. const XUL_NS =
  661. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  662. var cmdelm = document.createElementNS(XUL_NS, "command");
  663. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs");
  664. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  665. var commandset = document.getElementById("mainCommandSet");
  666. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  667. commandset.appendChild(cmdelm);
  668. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  669. menuelm.setAttribute("label", "Restart Firefox");
  670. menuelm.setAttribute("id", "my_menu_restartFirefoxKs");
  671. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  672. var menu = document.getElementById("menu_FilePopup");
  673. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  674. menu.appendChild(menuelm);
  675. }, "add restart firefox menu");
  676. /////////////////////////////////////////
  677. // feed url
  678. ext.add("feed-add-to-feedly", function(){
  679. var url = window.content.location.href;
  680. window.content.location.href =
  681. "http://cloud.feedly.com/#subscription%2Ffeed%2F" +
  682. encodeURIComponent(url);
  683. }, "Add current feed to feedly");
  684. var feedUtils = (function(){
  685. var feedhandler = "http://cloud.feedly.com/#subscription%2Ffeed%2F%s";
  686. function getFeeds(){
  687. const doc = content.document;
  688. var feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  689. for ([, e] in Iterator(doc.querySelectorAll([
  690. 'link[type="application/rss+xml"]',
  691. 'link[type="application/atom+xml"]'
  692. ])))];
  693. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,
  694. "$1");
  695. for (i = 0; i < feeds.length; i++)
  696. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  697. // feeds.unshift([window.content.document.title,
  698. // window.content.location.href]);
  699. return feeds;
  700. };
  701. ext.add("copy-feed-url", function () {
  702. var feeds = getFeeds();
  703. if (! feeds.length) {
  704. display.echoStatusBar("No feed found.");
  705. return;
  706. }
  707. prompt.selector({
  708. message : "Select Feed",
  709. collection : feeds,
  710. callback : function (i) {
  711. if (i >= 0) {
  712. command.setClipboardText(feeds[i][1]);
  713. }
  714. }
  715. });
  716. }, "Copy url or feed url of current page");
  717. ext.add("open-feed", function () {
  718. var feeds = getFeeds();
  719. if (! feeds.length) {
  720. display.echoStatusBar("No feed found.");
  721. return;
  722. }
  723. prompt.selector({
  724. message : "Select Feed",
  725. collection : feeds,
  726. callback : function (i) {
  727. if (i < 0) {
  728. return;
  729. }
  730. var feedurl = feeds[i][1];
  731. if (feedhandler) {
  732. window.openUILinkIn(
  733. feedhandler.replace("%s", feedurl),
  734. "tab"
  735. );
  736. } else {
  737. window.openUILinkIn(feedurl, "tab");
  738. }
  739. }
  740. });
  741. }, "Copy url or feed url of current page");
  742. return {
  743. getFeeds: getFeeds
  744. };
  745. })();
  746. ///////////////////////////////////////
  747. // keysnail z menu
  748. ext.add("keysnail-setting-dialog", function(){
  749. KeySnail.openPreference();
  750. }, "keysnail setting dialog");
  751. ext.add("keysnail-plugin-manager", function(){
  752. userscript.openPluginManager();
  753. }, "keysnail plugin manager");
  754. ext.add("firefox-open-addon-manager", function(){
  755. BrowserOpenAddonsMgr();
  756. }, "firefox addon manager");
  757. ext.add("keysnail-reload-init-file", function(){
  758. userscript.reload();
  759. }, "keysnail reload init file");
  760. ext.add("keysnail-z-menu",function(){
  761. var list = [["keysnail-setting-dialog"],
  762. ["keysnail-plugin-manager"],
  763. ["firefox-open-addon-manager"],
  764. ["keysnail-reload-init-file"],
  765. // ["check-for-plugins-update"],
  766. ["restart-firefox"]
  767. ];
  768. prompt.selector(
  769. {
  770. message : "open setting dialog",
  771. collection : list,
  772. callback : function (i) {
  773. ext.exec(list[i][0]);
  774. }
  775. });
  776. },"open keysnail z menu");
  777. ///////////////////////////////////
  778. // search web
  779. ext.add("query-then-engine", function () {
  780. prompt.reader({
  781. message : "Search Word?:",
  782. group : "query_word",
  783. // completer : completer.matcher.header(share.friendsCache || []),
  784. initialInput : content.document.getSelection() || "",
  785. callback : function (q) {
  786. if (q) {
  787. prompt.selector({
  788. message : "search \"" + q + "\" with?",
  789. collection : plugins.options["search-url-list"],
  790. width : [20,80],
  791. callback : function (i) {
  792. getBrowser().selectedTab =
  793. getBrowser().addTab(
  794. plugins.options["search-url-list"][i][1].
  795. replace("%r",q).replace(
  796. "%q",encodeURIComponent(q)
  797. )
  798. )
  799. ;
  800. }
  801. });
  802. };
  803. }
  804. });
  805. }, "enter search word and then select engine");
  806. /////////////////////////////////////
  807. // closed tab list
  808. ext.add("list-closed-tabs", function () {
  809. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  810. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(
  811. Ci.nsISessionStore
  812. );
  813. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  814. var closedTabs = [[tab.image || fav, tab.title, tab.url]
  815. for each (tab in json.decode(ss.getClosedTabData(window)))
  816. ];
  817. if (!closedTabs.length)
  818. return void display.echoStatusBar("No recently closed tab.", 2000);
  819. prompt.selector(
  820. {
  821. message : "select tab to undo:",
  822. collection : closedTabs,
  823. flags : [ICON | IGNORE, 0, 0],
  824. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  825. });
  826. }, "List closed tabs");
  827. ///////////////////////////////
  828. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  829. ext.add("list-tab-history", function () {
  830. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  831. var tabHistory = [];
  832. var sessionHistory = getBrowser().webNavigation.sessionHistory;
  833. if (sessionHistory.count < 1)
  834. return void display.echoStatusBar("Tab history not exist", 2000);
  835. var curIdx = sessionHistory.index;
  836. for (var i = 0; i < sessionHistory.count; i++) {
  837. var entry = sessionHistory.getEntryAtIndex(i, false);
  838. if (!entry)
  839. continue;
  840. try {
  841. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  842. .getService(Ci.nsIFaviconService)
  843. .getFaviconForPage(entry.URI).spec;
  844. } catch (ex) {}
  845. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  846. }
  847. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  848. if (tabHistory[thIdx][3] == curIdx) break;
  849. }
  850. prompt.selector(
  851. {
  852. message : "select history in tab",
  853. collection : tabHistory,
  854. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  855. header : ["Title", "URL"],
  856. initialIndex : thIdx,
  857. callback : function(i) {
  858. if (i >= 0)
  859. getBrowser().webNavigation.gotoIndex(tabHistory[i][3]);
  860. }
  861. });
  862. }, 'List tab history');
  863. //}}%PRESERVE%
  864. // ========================================================================= //
  865. // ========================= Special key settings ========================== //
  866. key.quitKey = "ESC";
  867. key.helpKey = "<f1>";
  868. key.escapeKey = "C-q";
  869. key.macroStartKey = "";
  870. key.macroEndKey = "";
  871. key.universalArgumentKey = "C-u";
  872. key.negativeArgument1Key = "C--";
  873. key.negativeArgument2Key = "C-M--";
  874. key.negativeArgument3Key = "M--";
  875. key.suspendKey = "Not defined";
  876. // ================================= Hooks ================================= //
  877. hook.setHook('KeyBoardQuit', function (aEvent) {
  878. // ext.exec("hide-sidebar");
  879. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  880. getBrowser().focus();
  881. content.focus();
  882. command.closeFindBar();
  883. if (util.isCaretEnabled()) {
  884. command.resetMark(aEvent);
  885. } else {
  886. goDoCommand("cmd_selectNone");
  887. }
  888. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  889. });
  890. hook.setHook('Unload', function () {
  891. util.getBrowserWindows().some(function (win) {
  892. if (win === window) {
  893. return false;
  894. }
  895. const ks = win.KeySnail;
  896. share.pluginUpdater = ks.getPluginUpdater(
  897. share.pluginUpdater.pluginsWithUpdate);
  898. ks.setUpPluginUpdaterDelegator();
  899. return true;
  900. });
  901. });
  902. hook.setHook('LocationChange', function (aNsURI) {
  903. echoTabInfo.echo();
  904. });
  905. // ============================= Key bindings ============================== //
  906. key.setGlobalKey('C-<up>', function () {
  907. var browser = getBrowser();
  908. if (browser.mCurrentTab.previousSibling) {
  909. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  910. } else {
  911. browser.moveTabTo(browser.mCurrentTab,
  912. browser.mTabContainer.childNodes.length - 1);
  913. }
  914. }, '選択中のタブを右へ');
  915. key.setGlobalKey('C-<down>', function () {
  916. var browser = getBrowser();
  917. if (browser.mCurrentTab.nextSibling) {
  918. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  919. } else {
  920. browser.moveTabTo(browser.mCurrentTab, 0);
  921. }
  922. }, '選択中のタブを左へ');
  923. key.setGlobalKey('<delete>', function (ev, arg) {
  924. let (elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  925. getBrowser().focus();
  926. content.focus();
  927. }, 'コンテンツへフォーカス', true);
  928. key.setGlobalKey('<f11>', function (ev, arg) {
  929. ext.exec("strong-fullscreen", arg, ev);
  930. }, 'go fullscreen with hiding toolbar and tabbar', true);
  931. key.setGlobalKey('<end>', function (ev) {
  932. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  933. }, 'ひとつ右のタブへ');
  934. key.setGlobalKey('<home>', function (ev) {
  935. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  936. }, 'ひとつ左のタブへ');
  937. key.setGlobalKey('<next>', function (ev) {
  938. let browser = getBrowser();
  939. if (browser.mCurrentTab.nextSibling) {
  940. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  941. } else {
  942. browser.moveTabTo(browser.mCurrentTab, 0);
  943. }
  944. }, '選択中のタブを右へ');
  945. key.setGlobalKey('<prior>', function (ev) {
  946. let browser = getBrowser();
  947. if (browser.mCurrentTab.previousSibling) {
  948. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  949. } else {
  950. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  951. }
  952. }, '選択中のタブを左へ');
  953. key.setViewKey('0', function (ev) {
  954. BrowserCloseTabOrWindow();
  955. }, 'タブ / ウィンドウを閉じる');
  956. key.setViewKey('l', function (ev) {
  957. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  958. }, 'ひとつ右のタブへ');
  959. key.setViewKey('h', function (ev) {
  960. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  961. }, 'ひとつ左のタブへ');
  962. key.setViewKey('o', function (ev, arg) {
  963. ext.exec("hok-start-foreground-mode", arg, ev);
  964. }, 'Start Hit a Hint foreground mode', true);
  965. key.setViewKey('c', function (ev) {
  966. command.interpreter();
  967. }, 'JavaScript のコードを評価');
  968. key.setViewKey('D', function (ev, arg) {
  969. ext.exec("dig-url", arg, ev);
  970. }, 'dig url with selector', true);
  971. key.setViewKey('x', function (aEvent, aArg) {
  972. ext.select(aArg, aEvent);
  973. }, 'エクステ一覧');
  974. key.setViewKey(['t', 'w'], function (ev, arg) {
  975. ext.exec("twitter-client-tweet", arg, ev);
  976. }, 'つぶやく', true);
  977. key.setViewKey(['t', 'p'], function (ev, arg) {
  978. ext.exec("twitter-client-tweet-this-page", arg, ev);
  979. }, 'このページのタイトルと URL を使ってつぶやく', true);
  980. key.setViewKey([['u'], ['S-SPC']], function (ev) {
  981. goDoCommand("cmd_scrollPageUp");
  982. }, '一画面分スクロールアップ');
  983. key.setViewKey('g', function () {
  984. goDoCommand("cmd_scrollTop");
  985. }, 'ページ先頭へ移動');
  986. key.setViewKey('G', function () {
  987. goDoCommand("cmd_scrollBottom");
  988. }, 'ページ末尾へ移動');
  989. key.setViewKey('r', function (aEvent) {
  990. BrowserReload();
  991. }, '再読み込み');
  992. key.setViewKey('z', function (ev, arg) {
  993. ext.exec("keysnail-z-menu", arg, ev);
  994. }, 'open keysnail setting menu', true);
  995. key.setViewKey('e', function () {
  996. command.focusElement(command.elementsRetrieverTextarea, 0);
  997. }, '最初のインプットエリアへフォーカス', true);
  998. key.setViewKey('S', function (ev, arg) {
  999. if (window.loadURI) {
  1000. 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{}");
  1001. }
  1002. }, 'google reader share');
  1003. key.setViewKey('!', function (ev, arg) {
  1004. shell.input();
  1005. }, 'Command system');
  1006. key.setViewKey('R', function () {
  1007. BrowserReloadSkipCache();
  1008. }, '更新(キャッシュを無視)');
  1009. key.setViewKey('<backspace>', function () {
  1010. BrowserBack();
  1011. }, '戻る');
  1012. key.setViewKey('S-<backspace>', function () {
  1013. BrowserForward();
  1014. }, '進む');
  1015. key.setViewKey('q', function (ev, arg) {
  1016. ext.exec("query-then-engine", arg, ev);
  1017. }, 'enter search word and then select engine', true);
  1018. key.setViewKey('/', function () {
  1019. command.iSearchForward();
  1020. }, 'インクリメンタル検索', true);
  1021. key.setViewKey('?', function (ev) {
  1022. command.iSearchForwardKs(ev);
  1023. }, 'Emacs ライクなインクリメンタル検索', true);
  1024. key.setViewKey('a', function (ev, arg) {
  1025. allTabs.open();
  1026. }, 'alltabs.open');
  1027. key.setViewKey([['d'], ['SPC']], function (ev) {
  1028. goDoCommand("cmd_scrollPageDown");
  1029. }, '一画面スクロールダウン');
  1030. key.setViewKey(':', function (ev, arg) {
  1031. return !document.getElementById("keysnail-prompt").hidden &&
  1032. document.getElementById("keysnail-prompt-textbox").focus();
  1033. }, 'KeySnail のプロンプトへフォーカス', true);
  1034. key.setViewKey('B', function (ev) {
  1035. var browser = getBrowser();
  1036. if (browser.mCurrentTab.previousSibling) {
  1037. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  1038. } else {
  1039. browser.moveTabTo(browser.mCurrentTab,
  1040. browser.mTabContainer.childNodes.length - 1);
  1041. }
  1042. }, '選択中のタブを左へ');
  1043. key.setViewKey('C', function (ev, arg) {
  1044. ext.exec("linksnail", arg, ev);
  1045. }, 'LinkSnail', true);
  1046. key.setViewKey('C-<backspace>', function (ev, arg) {
  1047. ext.exec("list-tab-history", arg, ev);
  1048. }, 'List tab history', true);
  1049. key.setViewKey('I', function (ev, arg) {
  1050. ext.exec("instapaper-post-page-with-comment", arg, ev);
  1051. }, 'post page and comment', true);
  1052. key.setViewKey('T', function (ev, arg) {
  1053. ext.exec("mstranslator-open-prompt", arg, ev);
  1054. }, 'MSTranslator - Open prompt', true);
  1055. key.setViewKey('f', function (ev, arg) {
  1056. ext.exec('strong-fullscreen', arg, ev);
  1057. }, 'go fullscreen with hiding toolbar and tabbar', true);
  1058. key.setViewKey('F', function (ev) {
  1059. var browser = getBrowser();
  1060. if (browser.mCurrentTab.nextSibling) {
  1061. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  1062. } else {
  1063. browser.moveTabTo(browser.mCurrentTab, 0);
  1064. }
  1065. }, '選択中のタブを右へ');
  1066. key.setViewKey('U', function (ev, arg) {
  1067. ext.exec("list-closed-tabs", arg, ev);
  1068. }, 'List closed tabs', true);
  1069. key.setViewKey('j', function (ev) {
  1070. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
  1071. }, '一行スクロールダウン');
  1072. key.setViewKey('k', function (ev) {
  1073. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
  1074. }, '一行スクロールアップ');
  1075. key.setViewKey('p', function (ev, arg) {
  1076. ext.exec('pocket-add-current', arg, ev);
  1077. }, 'Add current page', true);
  1078. key.setViewKey('P', function (ev, arg) {
  1079. ext.exec('pocket-open-latest', arg, ev);
  1080. }, 'Open last saved page', true);
  1081. key.setEditKey('C-<tab>', function (ev) {
  1082. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  1083. }, '次のテキストエリアへフォーカス');
  1084. key.setEditKey('C-a', function (ev) {
  1085. command.beginLine(ev);
  1086. }, '行頭へ移動');
  1087. key.setEditKey('C-e', function (ev) {
  1088. command.endLine(ev);
  1089. }, '行末へ');
  1090. key.setEditKey('C-d', function (ev) {
  1091. goDoCommand("cmd_deleteCharForward");
  1092. }, '次の一文字削除');
  1093. key.setEditKey('C-b', function (ev) {
  1094. command.previousChar(ev);
  1095. }, '一文字左へ移動');
  1096. key.setEditKey('C-f', function (ev) {
  1097. command.nextChar(ev);
  1098. }, '一文字右へ移動');
  1099. key.setEditKey('C-h', function (ev) {
  1100. goDoCommand("cmd_deleteCharBackward");
  1101. }, '前の一文字を削除');
  1102. key.setEditKey('C-k', function (ev) {
  1103. command.killLine(ev);
  1104. }, 'カーソルから先を一行カット (Kill line)');
  1105. key.setEditKey('C-l', function (ev) {
  1106. command.recenter(ev);
  1107. }, 'カーソル位置が画面の中央へ来るようスクロール', true);
  1108. key.setEditKey('C-n', function (ev) {
  1109. command.nextLine(ev);
  1110. }, '一行下へ');
  1111. key.setEditKey('C-p', function (ev) {
  1112. command.previousLine(ev);
  1113. }, '一行上へ');
  1114. key.setEditKey('C-o', function (ev) {
  1115. command.openLine(ev);
  1116. }, '行を開く (Open line)');
  1117. key.setGlobalKey('C-<right>', function (ev) {
  1118. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  1119. }, 'ひとつ右のタブへ');
  1120. key.setGlobalKey('C-<left>', function (ev) {
  1121. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  1122. }, 'ひとつ左のタブへ');