No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

_keysnail.js 44 KiB

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