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

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