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

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