Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

_keysnail.js 41 KiB

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