You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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