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.
 
 
 
 
 
 

1325 lines
42 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. function openFromFile(){
  312. var file = selectFile();
  313. openFromLFSplittedString(util.readTextFile(file));
  314. }
  315. function openFromClipboard(){
  316. openFromLFSplittedString(command.getClipboardText());
  317. }
  318. function openFromLFSplittedString(str) {
  319. var urls = str.split("\n");
  320. for (var i = 0; i < urls.length; i++) {
  321. if (urls[i].match(/^http/)) {
  322. window.openUILinkIn(urls[i], "tab");
  323. }
  324. }
  325. }
  326. return {
  327. selectDirectory: selectDirectory,
  328. setup: setup,
  329. getTabList: getTabList,
  330. saveCurrentList: saveCurrentList,
  331. openFromClipboard: openFromClipboard
  332. };
  333. })();
  334. ext.add("astl-setup", autoSaveTabList.setup, "Auto save tab list - Setup");
  335. ext.add("astl-open-from-clipboard", autoSaveTabList.openFromClipboard, "Auto save tab list - Open tabs from clipboard");
  336. ext.add("astl-save-current", autoSaveTabList.saveCurrentList,
  337. "Auto save tab list - Save current list");
  338. var echoTabInfo = (function(){
  339. var currenttab;
  340. function _display(msg){
  341. display.prettyPrint(msg, {
  342. timeout: 1500,
  343. style: {
  344. "font-size": "18px",
  345. "font-family": "monospace"
  346. }
  347. });
  348. }
  349. function __display(msg){
  350. display.echoStatusBar(msg);
  351. }
  352. function echo(){
  353. var newtab = getBrowser().mCurrentTab;
  354. if (currenttab === newtab) {
  355. return;
  356. }
  357. currenttab = newtab;
  358. var len = getBrowser().tabs.length;
  359. var idx = currenttab._tPos;
  360. var title = window.content.document.title;
  361. var url = window.content.location.href;
  362. var doc = content ? content.document : document;
  363. var dBody = doc.body;
  364. if (dBody && !util.isFrameSetWindow(content)) {
  365. // if page has been prepared
  366. _display(
  367. "[" +
  368. (idx + 1).toString() + "/" +
  369. len.toString() + "] " +
  370. title + " <" +
  371. decodeURIComponent(url) + ">"
  372. );
  373. }
  374. }
  375. return {
  376. echo: echo
  377. };
  378. })();
  379. ext.add("open-remote-init-file", function(ev, arg){
  380. const URL = "https://raw.github.com/10sr/dotfiles/master/_keysnail.js";
  381. window.openUILinkIn(URL, "tab");
  382. }, "Open remote initialization file");
  383. var updateInitFile = (function(){
  384. const URL = "https://raw.github.com/10sr/dotfiles/master/_keysnail.js";
  385. // content/modules/userscript.js
  386. // copy file from aFile
  387. function placeFile(aFile, force) {
  388. var dstdir = util.getUnicharPref("extensions.keysnail.userscript.location");
  389. if (dstdir === "") {
  390. throw util.getLocaleString("failedToInstallFile", [aFile.leafName]) + " :: " + x;
  391. }
  392. try
  393. {
  394. // calc dir from path
  395. let destinationDir = util.openFile(dstdir);
  396. let destinationFile = util.openFile(dstdir);
  397. destinationFile.append(aFile.leafName);
  398. if (destinationFile.exists())
  399. {
  400. if (util.hashFile(aFile) === util.hashFile(destinationFile))
  401. {
  402. // no need to install this file
  403. return destinationFile;
  404. }
  405. let confirmed = force ||
  406. util.confirm(
  407. util.getLocaleString("overWriteConfirmationTitle"),
  408. util.getLocaleString("overWriteConfirmation",
  409. [destinationFile.path])
  410. );
  411. if (!confirmed) {
  412. throw util.getLocaleString("canceledByUser");
  413. }
  414. }
  415. aFile.moveTo(destinationDir, "");
  416. return destinationFile;
  417. }
  418. catch (x)
  419. {
  420. throw util.getLocaleString("failedToInstallFile",
  421. [aFile.leafName]) +
  422. " :: " + x;
  423. }
  424. }
  425. function updateFile() {
  426. util.httpGet(URL, false, function (req) {
  427. if (req.status !== 200) {
  428. util.message(req.responseText);
  429. }
  430. try {
  431. let name = util.getLeafNameFromURL(URL);
  432. let file = userscript.writeTextTmp(name, req.responseText);
  433. let installed = placeFile(file);
  434. util.message(installed.path + " installed");
  435. display.showPopup("update-init-file",
  436. installed.path + " installed")
  437. } catch (x) {
  438. util.message(
  439. "An error occured while installing required scripts :: " +
  440. x.message
  441. );
  442. display.showPopup(
  443. "update-init-file",
  444. "An error occured while installing required scripts :: " +
  445. x.message
  446. );
  447. }
  448. });
  449. }
  450. return {
  451. updateFile: updateFile
  452. };
  453. })();
  454. ext.add("update-init-file", updateInitFile.updateFile, "update init file");
  455. var importExportBookmarks = (function(){
  456. function getOrganizer(){
  457. // [How to call for Firefox bookmark dialog? - Stack Overflow]
  458. // (http://stackoverflow.com/questions/9158187/how-to-call-for-firefox-bookmark-dialog)
  459. Components.utils.import("resource://gre/modules/Services.jsm");
  460. var organizer = Services.wm.getMostRecentWindow("Places:Organizer");
  461. if (!organizer) {
  462. // No currently open places window,
  463. // so open one with the specified mode.
  464. openDialog("chrome://browser/content/places/places.xul",
  465. "",
  466. "chrome,toolbar=yes,dialog=no,resizable",
  467. "AllBookmarks");
  468. return null;
  469. } else {
  470. return organizer;
  471. }
  472. }
  473. ext.add("export-bookmarks", function(ev, arg){
  474. var organizer = getOrganizer();
  475. if (organizer) {
  476. organizer.PlacesOrganizer.exportBookmarks();
  477. }
  478. }, "export bookmarks");
  479. ext.add("import-bookmarks", function(ev, arg){
  480. var organizer = getOrganizer();
  481. if (organizer) {
  482. organizer.PlacesOrganizer.importBookmarks();
  483. }
  484. }, "import bookmarks");
  485. return {
  486. getOrganizer: getOrganizer
  487. };
  488. })();
  489. ext.add("my-index-html", function(ev, arg){
  490. homepath = util.getEnv("HOME");
  491. file = ".index.html";
  492. if (homepath) {
  493. path = "file://" + homepath + "/" + file;
  494. window.openUILinkIn(path, "tab");
  495. }
  496. }, "open my index.html");
  497. ext.add("strong-fullscreen", function(){
  498. var elemids = [
  499. "navigator-toolbox"
  500. ];
  501. BrowserFullScreen();
  502. var isfullscreen = window.fullScreen;
  503. for(var i = 0; i < elemids.length; i++){
  504. var elem = document.getElementById(elemids[i]);
  505. if(elem){
  506. if(isfullscreen){
  507. elem.style.display = "none";
  508. }else{
  509. elem.style.display = null;
  510. }
  511. }
  512. }
  513. var tabs = document.getElementById("verticaltabs-box");
  514. if(tabs){
  515. var pref_key = "extensions.verticaltabs.width";
  516. var pref_key_bak = pref_key + "_bak";
  517. if(isfullscreen){
  518. var width_orig = util.getIntPref(pref_key);
  519. util.setIntPref(pref_key_bak, width_orig);
  520. util.setIntPref(pref_key, 0);
  521. tabs.setAttribute("width", "0");
  522. }else if(parseInt(tabs.getAttribute("width") || "") === 0){
  523. var width_bak = util.getIntPref(pref_key_bak);
  524. util.setIntPref(pref_key, width_bak);
  525. tabs.setAttribute("width", width_bak.toString());
  526. }
  527. }
  528. }, "go fullscreen with hiding toolbar and tabbar");
  529. ext.add("bookmark-delicious", function(){
  530. f= 'http://www.delicious.com/save?url=' +
  531. encodeURIComponent(window.content.location.href) +
  532. '&title=' + encodeURIComponent(document.title) +
  533. '&notes=' + encodeURIComponent(
  534. '' + (window.getSelection ?
  535. window.getSelection() : (
  536. document.getSelection ?
  537. document.getSelection() :
  538. document.selection.createRange().text))) + '&v=6&';
  539. a = function(){
  540. if(! window.open(
  541. f + 'noui=1&jump=doclose',
  542. 'deliciousuiv6',
  543. 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){
  544. location.href = f + 'jump=yes';
  545. }
  546. };
  547. if(/Firefox/.test(navigator.userAgent)){
  548. setTimeout(a,0);
  549. }else{
  550. a();
  551. }
  552. }, "bookmark delicious");
  553. ext.add('view-page-source', function(){
  554. window.content.location.href = "view-source:" +
  555. window.content.location.href;
  556. }, 'view page source');
  557. ext.add('my-setpref', function(){
  558. util.setPrefs(
  559. {
  560. "browser.bookmarks.max_backups":0,
  561. "browser.cache.memory.capacity":16384,
  562. "browser.download.manager.closeWhenDone":true,
  563. "browser.download.useDownloadDir":false,
  564. "browser.fullscreen.autohide":false,
  565. "browser.search.openintab":true,
  566. "browser.sessionhistory.max_total_viewers":8,
  567. "browser.sessionstore.restore_on_demand":true,
  568. "browser.tabs.closeWindowWithLastTab":false,
  569. "browser.tabs.loadDivertedInBackground": true,
  570. "browser.urlbar.autocomplete.enabled":false,
  571. "browser.urlbar.trimURLs":false,
  572. "browser.fixup.alternate.enabled": false,
  573. "dom.disable_window_open_feature.location": false,
  574. "dom.max_script_run_time": 30,
  575. "extensions.chaika.bbsmenu.open_new_tab":true,
  576. "extensions.chaika.bbsmenu.open_single_click":false,
  577. "extensions.chaika.board.open_new_tab":true,
  578. "extensions.chaika.board.open_single_click":false,
  579. "extensions.foxage2ch.openThreadInTab":true,
  580. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  581. "extensions.saveimageinfolder.general-fileprefixvalue":
  582. "%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  583. "extensions.saveimageinfolder.usecache":true,
  584. "extensions.tabutils.openTabNext":1,
  585. "extensions.tabutils.openUrlInTab":false,
  586. "extensions.tabutils.styles.current":
  587. "{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  588. "extensions.tabutils.styles.unread":
  589. "{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}",
  590. "extensions.tabutils.TFS_Enable":false,
  591. // Always select right tab on close
  592. "extensions.tabutils.selectOnClose":10,
  593. "extensions.yass.edgetype":0,
  594. "extensions.yass.selectedpreset":"red",
  595. "font.default.x-western":"sans-serif",
  596. "gecko.handlerService.schemes.mailto.1.name":"Gmail",
  597. "general.warnOnAboutConfig":false,
  598. "keyword.URL":"http://www.bing.com/search?q=",
  599. "browser.search.defaultenginename":"Bing",
  600. "browser.search.defaulturl":"http://www.bing.com/search?q=",
  601. "network.dns.disableIPv6":true,
  602. "refcontrol.actions":
  603. "@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL",
  604. "scrapbook.tabs.open":true
  605. }
  606. );
  607. if(/^Linux/.test(navigator.platform)){
  608. util.setPrefs(
  609. {
  610. "browser.cache.disk.parent_directory":"/tmp",
  611. "browser.cache.disk.capacity":524288
  612. }
  613. );
  614. }
  615. display.showPopup("Keysnail", "My prefs done.");
  616. }, 'my setpref');
  617. ext.add('auto-install-plugins', function(ev, arg){
  618. var urls = [
  619. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  620. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  621. 'https://raw.github.com/mooz/keysnail/master/plugins/hok.ks.js',
  622. 'https://github.com/mooz/keysnail/raw/master/plugins/builtin-commands-ext.ks.js',
  623. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  624. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  625. 'https://raw.githubusercontent.com/azu/keysnail-plugin/master/nicontroller.ks.js',
  626. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  627. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  628. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  629. 'https://raw.github.com/10sr/keysnail-plugin/master/pixiv_autojump.ks.js',
  630. 'https://raw.github.com/10sr/keysnail-plugin/master/list-current-urls.ks.js',
  631. 'https://gist.githubusercontent.com/10sr/1976942/raw/firefox-addon-manager.ks.js',
  632. 'https://gist.githubusercontent.com/958/1450594/raw/mstranslator.ks.js'
  633. ];
  634. function inst(a){
  635. if(a.length == 0){
  636. display.showPopup("auto-install-plugins",
  637. "All installation finished.");
  638. }else{
  639. var url = a.shift();
  640. var path = userscript.pluginDir +
  641. userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  642. if(plugins.context[path] === undefined){
  643. userscript.installPluginFromURL(url, function(){inst(a);});
  644. }else{
  645. inst(a);
  646. }
  647. }
  648. }
  649. inst(urls);
  650. }, 'Install plugins automatically if not installed yet.');
  651. ext.add('put-aside-this-page', function (ev, arg) {
  652. var n = getBrowser().mCurrentTab._tPos;
  653. getBrowser().moveTabTo(getBrowser().mCurrentTab, 0);
  654. if (n != 0) {
  655. getBrowser().selectedTab = getBrowser().mTabs[n];
  656. }
  657. }, 'put aside this page');
  658. ext.add('send-escape', function (ev, arg) {
  659. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  660. }, 'escape');
  661. ext.add("open-hatebu-comment", function (ev, arg) {
  662. var url = window.content.location.href.replace(/^[^/]*\/\//, "");
  663. window.content.location.href = "http://b.hatena.ne.jp/entry/" + url;
  664. }, 'hatebu');
  665. // ext.add("focus-on-content", function(){
  666. // let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  667. // gBrowser.focus();
  668. // content.focus();
  669. // }, "forcus on content");
  670. ext.add("hide-sidebar", function(){
  671. var sidebarBox = document.getElementById("sidebar-box");
  672. if (!sidebarBox.hidden) {
  673. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  674. }
  675. }, "hide-sidebar");
  676. ext.add("close-and-next-tab", function (ev, arg) {
  677. var n = getBrowser().mCurrentTab._tPos;
  678. getBrowser().removeCurrentTab();
  679. getBrowser().selectedTab = getBrowser().mTabs[n];
  680. }, "close and focus to next tab");
  681. //////////////////////////////////////
  682. //
  683. ext.add("restart-firefox-add-menu", function(){
  684. const XUL_NS =
  685. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  686. var cmdelm = document.createElementNS(XUL_NS, "command");
  687. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs");
  688. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  689. var commandset = document.getElementById("mainCommandSet");
  690. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  691. commandset.appendChild(cmdelm);
  692. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  693. menuelm.setAttribute("label", "Restart Firefox");
  694. menuelm.setAttribute("id", "my_menu_restartFirefoxKs");
  695. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  696. var menu = document.getElementById("menu_FilePopup");
  697. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  698. menu.appendChild(menuelm);
  699. }, "add restart firefox menu");
  700. /////////////////////////////////////////
  701. // feed url
  702. ext.add("feed-add-to-feedly", function(){
  703. var url = window.content.location.href;
  704. window.content.location.href =
  705. "http://cloud.feedly.com/#subscription%2Ffeed%2F" +
  706. encodeURIComponent(url);
  707. }, "Add current feed to feedly");
  708. var feedUtils = (function(){
  709. var feedhandler = "http://cloud.feedly.com/#subscription%2Ffeed%2F%s";
  710. function getFeeds(){
  711. const doc = content.document;
  712. var feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  713. for ([, e] in Iterator(doc.querySelectorAll([
  714. 'link[type="application/rss+xml"]',
  715. 'link[type="application/atom+xml"]'
  716. ])))];
  717. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,
  718. "$1");
  719. for (i = 0; i < feeds.length; i++)
  720. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  721. // feeds.unshift([window.content.document.title,
  722. // window.content.location.href]);
  723. return feeds;
  724. };
  725. ext.add("copy-feed-url", function () {
  726. var feeds = getFeeds();
  727. if (! feeds.length) {
  728. display.echoStatusBar("No feed found.");
  729. return;
  730. }
  731. prompt.selector({
  732. message : "Select Feed",
  733. collection : feeds,
  734. callback : function (i) {
  735. if (i >= 0) {
  736. command.setClipboardText(feeds[i][1]);
  737. }
  738. }
  739. });
  740. }, "Copy url or feed url of current page");
  741. ext.add("open-feed", function () {
  742. var feeds = getFeeds();
  743. if (! feeds.length) {
  744. display.echoStatusBar("No feed found.");
  745. return;
  746. }
  747. prompt.selector({
  748. message : "Select Feed",
  749. collection : feeds,
  750. callback : function (i) {
  751. if (i < 0) {
  752. return;
  753. }
  754. var feedurl = feeds[i][1];
  755. if (feedhandler) {
  756. window.openUILinkIn(
  757. feedhandler.replace("%s", feedurl),
  758. "tab"
  759. );
  760. } else {
  761. window.openUILinkIn(feedurl, "tab");
  762. }
  763. }
  764. });
  765. }, "Copy url or feed url of current page");
  766. return {
  767. getFeeds: getFeeds
  768. };
  769. })();
  770. ///////////////////////////////////////
  771. // keysnail z menu
  772. ext.add("keysnail-setting-dialog", function(){
  773. KeySnail.openPreference();
  774. }, "keysnail setting dialog");
  775. ext.add("keysnail-plugin-manager", function(){
  776. userscript.openPluginManager();
  777. }, "keysnail plugin manager");
  778. ext.add("firefox-open-addon-manager", function(){
  779. BrowserOpenAddonsMgr();
  780. }, "firefox addon manager");
  781. ext.add("keysnail-reload-init-file", function(){
  782. userscript.reload();
  783. }, "keysnail reload init file");
  784. ext.add("keysnail-z-menu",function(){
  785. var list = [["keysnail-setting-dialog"],
  786. ["keysnail-plugin-manager"],
  787. ["firefox-open-addon-manager"],
  788. ["keysnail-reload-init-file"],
  789. // ["check-for-plugins-update"],
  790. ["restart-firefox"]
  791. ];
  792. prompt.selector(
  793. {
  794. message : "open setting dialog",
  795. collection : list,
  796. callback : function (i) {
  797. ext.exec(list[i][0]);
  798. }
  799. });
  800. },"open keysnail z menu");
  801. ///////////////////////////////////
  802. // search web
  803. ext.add("query-then-engine", function () {
  804. prompt.reader({
  805. message : "Search Word?:",
  806. group : "query_word",
  807. // completer : completer.matcher.header(share.friendsCache || []),
  808. initialInput : content.document.getSelection() || "",
  809. callback : function (q) {
  810. if (q) {
  811. prompt.selector({
  812. message : "search \"" + q + "\" with?",
  813. collection : plugins.options["search-url-list"],
  814. width : [20,80],
  815. callback : function (i) {
  816. getBrowser().selectedTab =
  817. getBrowser().addTab(
  818. plugins.options["search-url-list"][i][1].
  819. replace("%r",q).replace(
  820. "%q",encodeURIComponent(q)
  821. )
  822. )
  823. ;
  824. }
  825. });
  826. };
  827. }
  828. });
  829. }, "enter search word and then select engine");
  830. /////////////////////////////////////
  831. // closed tab list
  832. ext.add("list-closed-tabs", function () {
  833. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  834. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(
  835. Ci.nsISessionStore
  836. );
  837. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  838. var closedTabs = [[tab.image || fav, tab.title, tab.url]
  839. for each (tab in json.decode(ss.getClosedTabData(window)))
  840. ];
  841. if (!closedTabs.length)
  842. return void display.echoStatusBar("No recently closed tab.", 2000);
  843. prompt.selector(
  844. {
  845. message : "select tab to undo:",
  846. collection : closedTabs,
  847. flags : [ICON | IGNORE, 0, 0],
  848. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  849. });
  850. }, "List closed tabs");
  851. ///////////////////////////////
  852. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  853. ext.add("list-tab-history", function () {
  854. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  855. var tabHistory = [];
  856. var sessionHistory = getBrowser().webNavigation.sessionHistory;
  857. if (sessionHistory.count < 1)
  858. return void display.echoStatusBar("Tab history not exist", 2000);
  859. var curIdx = sessionHistory.index;
  860. for (var i = 0; i < sessionHistory.count; i++) {
  861. var entry = sessionHistory.getEntryAtIndex(i, false);
  862. if (!entry)
  863. continue;
  864. try {
  865. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  866. .getService(Ci.nsIFaviconService)
  867. .getFaviconForPage(entry.URI).spec;
  868. } catch (ex) {}
  869. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  870. }
  871. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  872. if (tabHistory[thIdx][3] == curIdx) break;
  873. }
  874. prompt.selector(
  875. {
  876. message : "select history in tab",
  877. collection : tabHistory,
  878. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  879. header : ["Title", "URL"],
  880. initialIndex : thIdx,
  881. callback : function(i) {
  882. if (i >= 0)
  883. getBrowser().webNavigation.gotoIndex(tabHistory[i][3]);
  884. }
  885. });
  886. }, 'List tab history');
  887. //}}%PRESERVE%
  888. // ========================================================================= //
  889. // ========================= Special key settings ========================== //
  890. key.quitKey = "ESC";
  891. key.helpKey = "<f1>";
  892. key.escapeKey = "C-q";
  893. key.macroStartKey = "";
  894. key.macroEndKey = "";
  895. key.universalArgumentKey = "C-u";
  896. key.negativeArgument1Key = "C--";
  897. key.negativeArgument2Key = "C-M--";
  898. key.negativeArgument3Key = "M--";
  899. key.suspendKey = "Not defined";
  900. // ================================= Hooks ================================= //
  901. hook.setHook('KeyBoardQuit', function (aEvent) {
  902. // ext.exec("hide-sidebar");
  903. let(elem = document.commandDispatcher.focusedElement) {elem && elem.blur()};
  904. getBrowser().focus();
  905. content.focus();
  906. command.closeFindBar();
  907. if (util.isCaretEnabled()) {
  908. command.resetMark(aEvent);
  909. } else {
  910. goDoCommand("cmd_selectNone");
  911. }
  912. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  913. });
  914. hook.setHook('Unload', function () {
  915. util.getBrowserWindows().some(function (win) {
  916. if (win === window) {
  917. return false;
  918. }
  919. const ks = win.KeySnail;
  920. share.pluginUpdater = ks.getPluginUpdater(
  921. share.pluginUpdater.pluginsWithUpdate);
  922. ks.setUpPluginUpdaterDelegator();
  923. return true;
  924. });
  925. });
  926. hook.setHook('LocationChange', function (aNsURI) {
  927. echoTabInfo.echo();
  928. });
  929. // ============================= Key bindings ============================== //
  930. key.setGlobalKey('C-<up>', function () {
  931. var browser = getBrowser();
  932. if (browser.mCurrentTab.previousSibling) {
  933. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  934. } else {
  935. browser.moveTabTo(browser.mCurrentTab,
  936. browser.mTabContainer.childNodes.length - 1);
  937. }
  938. }, '選択中のタブを右へ');
  939. key.setGlobalKey('C-<down>', function () {
  940. var browser = getBrowser();
  941. if (browser.mCurrentTab.nextSibling) {
  942. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  943. } else {
  944. browser.moveTabTo(browser.mCurrentTab, 0);
  945. }
  946. }, '選択中のタブを左へ');
  947. key.setGlobalKey('<delete>', function (ev, arg) {
  948. let (elem = document.commandDispatcher.focusedElement) {elem && elem.blur()};
  949. getBrowser().focus();
  950. content.focus();
  951. }, 'コンテンツへフォーカス', true);
  952. key.setGlobalKey('<f11>', function (ev, arg) {
  953. ext.exec("strong-fullscreen", arg, ev);
  954. }, 'go fullscreen with hiding toolbar and tabbar', true);
  955. key.setGlobalKey('<end>', function (ev) {
  956. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  957. }, 'ひとつ右のタブへ');
  958. key.setGlobalKey('<home>', function (ev) {
  959. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  960. }, 'ひとつ左のタブへ');
  961. key.setGlobalKey('<next>', function (ev) {
  962. let browser = getBrowser();
  963. if (browser.mCurrentTab.nextSibling) {
  964. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  965. } else {
  966. browser.moveTabTo(browser.mCurrentTab, 0);
  967. }
  968. }, '選択中のタブを右へ');
  969. key.setGlobalKey('<prior>', function (ev) {
  970. let browser = getBrowser();
  971. if (browser.mCurrentTab.previousSibling) {
  972. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  973. } else {
  974. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  975. }
  976. }, '選択中のタブを左へ');
  977. key.setViewKey('0', function (ev) {
  978. BrowserCloseTabOrWindow();
  979. }, 'タブ / ウィンドウを閉じる');
  980. key.setViewKey('l', function (ev) {
  981. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  982. }, 'ひとつ右のタブへ');
  983. key.setViewKey('h', function (ev) {
  984. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  985. }, 'ひとつ左のタブへ');
  986. key.setViewKey('o', function (ev, arg) {
  987. ext.exec("hok-start-foreground-mode", arg, ev);
  988. }, 'Start Hit a Hint foreground mode', true);
  989. key.setViewKey('c', function (ev) {
  990. command.interpreter();
  991. }, 'JavaScript のコードを評価');
  992. key.setViewKey('D', function (ev, arg) {
  993. ext.exec("dig-url", arg, ev);
  994. }, 'dig url with selector', true);
  995. key.setViewKey('x', function (aEvent, aArg) {
  996. ext.select(aArg, aEvent);
  997. }, 'エクステ一覧');
  998. key.setViewKey(['t', 'w'], function (ev, arg) {
  999. ext.exec("twitter-client-tweet", arg, ev);
  1000. }, 'つぶやく', true);
  1001. key.setViewKey(['t', 'p'], function (ev, arg) {
  1002. ext.exec("twitter-client-tweet-this-page", arg, ev);
  1003. }, 'このページのタイトルと URL を使ってつぶやく', true);
  1004. key.setViewKey([['u'], ['S-SPC']], function (ev) {
  1005. goDoCommand("cmd_scrollPageUp");
  1006. }, '一画面分スクロールアップ');
  1007. key.setViewKey('g', function () {
  1008. goDoCommand("cmd_scrollTop");
  1009. }, 'ページ先頭へ移動');
  1010. key.setViewKey('G', function () {
  1011. goDoCommand("cmd_scrollBottom");
  1012. }, 'ページ末尾へ移動');
  1013. key.setViewKey('r', function (aEvent) {
  1014. BrowserReload();
  1015. }, '再読み込み');
  1016. key.setViewKey('z', function (ev, arg) {
  1017. ext.exec("keysnail-z-menu", arg, ev);
  1018. }, 'open keysnail setting menu', true);
  1019. key.setViewKey('e', function () {
  1020. command.focusElement(command.elementsRetrieverTextarea, 0);
  1021. }, '最初のインプットエリアへフォーカス', true);
  1022. key.setViewKey('S', function (ev, arg) {
  1023. if (window.loadURI) {
  1024. 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{}");
  1025. }
  1026. }, 'google reader share');
  1027. key.setViewKey('!', function (ev, arg) {
  1028. shell.input();
  1029. }, 'Command system');
  1030. key.setViewKey('R', function () {
  1031. BrowserReloadSkipCache();
  1032. }, '更新(キャッシュを無視)');
  1033. key.setViewKey('<backspace>', function () {
  1034. BrowserBack();
  1035. }, '戻る');
  1036. key.setViewKey('S-<backspace>', function () {
  1037. BrowserForward();
  1038. }, '進む');
  1039. key.setViewKey('q', function (ev, arg) {
  1040. ext.exec("query-then-engine", arg, ev);
  1041. }, 'enter search word and then select engine', true);
  1042. key.setViewKey('/', function () {
  1043. command.iSearchForward();
  1044. }, 'インクリメンタル検索', true);
  1045. key.setViewKey('?', function (ev) {
  1046. command.iSearchForwardKs(ev);
  1047. }, 'Emacs ライクなインクリメンタル検索', true);
  1048. key.setViewKey('a', function (ev, arg) {
  1049. allTabs.open();
  1050. }, 'alltabs.open');
  1051. key.setViewKey([['d'], ['SPC']], function (ev) {
  1052. goDoCommand("cmd_scrollPageDown");
  1053. }, '一画面スクロールダウン');
  1054. key.setViewKey(':', function (ev, arg) {
  1055. return !document.getElementById("keysnail-prompt").hidden &&
  1056. document.getElementById("keysnail-prompt-textbox").focus();
  1057. }, 'KeySnail のプロンプトへフォーカス', true);
  1058. key.setViewKey('B', function (ev) {
  1059. var browser = getBrowser();
  1060. if (browser.mCurrentTab.previousSibling) {
  1061. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  1062. } else {
  1063. browser.moveTabTo(browser.mCurrentTab,
  1064. browser.mTabContainer.childNodes.length - 1);
  1065. }
  1066. }, '選択中のタブを左へ');
  1067. key.setViewKey('C', function (ev, arg) {
  1068. ext.exec("linksnail", arg, ev);
  1069. }, 'LinkSnail', true);
  1070. key.setViewKey('C-<backspace>', function (ev, arg) {
  1071. ext.exec("list-tab-history", arg, ev);
  1072. }, 'List tab history', true);
  1073. key.setViewKey('I', function (ev, arg) {
  1074. ext.exec("instapaper-post-page-with-comment", arg, ev);
  1075. }, 'post page and comment', true);
  1076. key.setViewKey('T', function (ev, arg) {
  1077. ext.exec("mstranslator-open-prompt", arg, ev);
  1078. }, 'MSTranslator - Open prompt', true);
  1079. key.setViewKey('f', function (ev, arg) {
  1080. ext.exec('strong-fullscreen', arg, ev);
  1081. }, 'go fullscreen with hiding toolbar and tabbar', true);
  1082. key.setViewKey('F', function (ev) {
  1083. var browser = getBrowser();
  1084. if (browser.mCurrentTab.nextSibling) {
  1085. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  1086. } else {
  1087. browser.moveTabTo(browser.mCurrentTab, 0);
  1088. }
  1089. }, '選択中のタブを右へ');
  1090. key.setViewKey('U', function (ev, arg) {
  1091. ext.exec("list-closed-tabs", arg, ev);
  1092. }, 'List closed tabs', true);
  1093. key.setViewKey('j', function (ev) {
  1094. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
  1095. }, '一行スクロールダウン');
  1096. key.setViewKey('k', function (ev) {
  1097. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
  1098. }, '一行スクロールアップ');
  1099. key.setViewKey('p', function (ev, arg) {
  1100. ext.exec('pocket-add-current', arg, ev);
  1101. }, 'Add current page', true);
  1102. key.setViewKey('P', function (ev, arg) {
  1103. ext.exec('pocket-open-latest', arg, ev);
  1104. }, 'Open last saved page', true);
  1105. key.setEditKey('C-<tab>', function (ev) {
  1106. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  1107. }, '次のテキストエリアへフォーカス');
  1108. key.setEditKey('C-a', function (ev) {
  1109. command.beginLine(ev);
  1110. }, '行頭へ移動');
  1111. key.setEditKey('C-e', function (ev) {
  1112. command.endLine(ev);
  1113. }, '行末へ');
  1114. key.setEditKey('C-d', function (ev) {
  1115. goDoCommand("cmd_deleteCharForward");
  1116. }, '次の一文字削除');
  1117. key.setEditKey('C-b', function (ev) {
  1118. command.previousChar(ev);
  1119. }, '一文字左へ移動');
  1120. key.setEditKey('C-f', function (ev) {
  1121. command.nextChar(ev);
  1122. }, '一文字右へ移動');
  1123. key.setEditKey('C-h', function (ev) {
  1124. goDoCommand("cmd_deleteCharBackward");
  1125. }, '前の一文字を削除');
  1126. key.setEditKey('C-k', function (ev) {
  1127. command.killLine(ev);
  1128. }, 'カーソルから先を一行カット (Kill line)');
  1129. key.setEditKey('C-l', function (ev) {
  1130. command.recenter(ev);
  1131. }, 'カーソル位置が画面の中央へ来るようスクロール', true);
  1132. key.setEditKey('C-n', function (ev) {
  1133. command.nextLine(ev);
  1134. }, '一行下へ');
  1135. key.setEditKey('C-p', function (ev) {
  1136. command.previousLine(ev);
  1137. }, '一行上へ');
  1138. key.setEditKey('C-o', function (ev) {
  1139. command.openLine(ev);
  1140. }, '行を開く (Open line)');
  1141. key.setGlobalKey('C-<right>', function (ev) {
  1142. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  1143. }, 'ひとつ右のタブへ');
  1144. key.setGlobalKey('C-<left>', function (ev) {
  1145. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  1146. }, 'ひとつ左のタブへ');