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.
 
 
 
 
 
 

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