25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_keysnail.js 40 KiB

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