Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

_keysnail.js 34 KiB

vor 13 Jahren
vor 11 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 11 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 11 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 11 Jahren
vor 11 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 11 Jahren
vor 11 Jahren
vor 11 Jahren
vor 11 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 11 Jahren
vor 12 Jahren
vor 11 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 11 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 12 Jahren
vor 12 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 12 Jahren
vor 13 Jahren
vor 11 Jahren
vor 12 Jahren
vor 13 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 11 Jahren
vor 13 Jahren
vor 12 Jahren
vor 12 Jahren
vor 11 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 11 Jahren
vor 12 Jahren
vor 13 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 11 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  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. (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. whereToOpenLink_org = whereToOpenLink;
  22. eval('whereToOpenLink = ' + whereToOpenLink_org.toString()
  23. .replace('if (ctrl', 'if (true')
  24. // .replace('if (ctrl', 'if (ctrl && !shift|| !ctrl && shift')
  25. // .replace('if (shift ||', 'if (shift && ctrl ||')
  26. // .replace('middle && middleUsesTabs',
  27. // 'middle && middleUsesTabs && !alt')
  28. );
  29. })();
  30. //////////////////////////////////////
  31. //// sitelocalkeymap
  32. var local = {};
  33. plugins.options["site_local_keymap.local_keymap"] = local;
  34. function fake(k, i) function(){ key.feed(k, i); };
  35. function pass(k, i) [k, fake(k, i)];
  36. function ignore(k, i) [k, null];
  37. // ext.add("ext-name", function () {}, "ext description");
  38. // style.register("");
  39. // local["^http://"] = [['a', function(ev, arg){}],];
  40. ///////////////////////////////////////////
  41. //// firefox
  42. // style.register("#bookmarksPanel > hbox,#history-panel > hbox {" +
  43. // "display: none !important;}" +
  44. // " //#urlbar-container{max-width: 500px !important;}");
  45. // style.register( //not work
  46. // <><![CDATA[
  47. // input,textarea {
  48. // font-family: monospace !important;
  49. // }
  50. // ]]></>.toString()
  51. // );
  52. ///////////////////////////////////
  53. //search engine
  54. plugins.options["search-url-list"] = [
  55. ["bing","http://bing.com/search?q=%q"],
  56. ["yatwitter search","http://yats-data.com/yats/search?query=%q"],
  57. ["twitter search","http://twitter.com/search?q=%q&lang=all"],
  58. ["tospy", "http://topsy.com/s?allow_lang=ja&q=%q"],
  59. ["2ch","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  60. ["I\'m feelig lucky!","http://www.google.co.jp/search?q=%q&btnI=kudos"],
  61. ["uncyclopedia","http://ja.uncyclopedia.info/wiki/%q"],
  62. ["wikipedia","http://ja.wikipedia.org/wiki/%q"],
  63. ["nicovideo.jp","http://www.nicovideo.jp/search/%q"],
  64. ["alc","http://eow.alc.co.jp/%q/UTF-8/"],
  65. ["google map",
  66. "http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  67. ["weblio","http://www.weblio.jp/content_find?query=%q"],
  68. ["shoutcast","http://www.shoutcast.com/Internet-Radio/%q"],
  69. ["delicious 10sr",
  70. "http://delicious.com/10sr?addtag=%q&setcount=50&opennew=1"],
  71. ["open raw","%r"],
  72. ];
  73. plugins.options["my-keysnail-bookmarks"] = [
  74. "twitter.com"
  75. ];
  76. // sitelocal keymap
  77. //////////////////////////////////////////
  78. // 2ch chaika
  79. // change chaika port every time firefox starts
  80. util.setIntPref("extensions.chaika.server_port.firefox",
  81. 8800 + Math.floor(Math.random() * 30));
  82. local["^http://127.0.0.1:88"] = [
  83. ['k', function(ev, arg){
  84. curl = window.content.location.href;
  85. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  86. window.content.location.href = kurl;
  87. }
  88. ]
  89. ];
  90. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  91. ['k', function(ev, arg){
  92. var url = window.content.location.href;
  93. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  94. var result = url.match(pt);
  95. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/",
  96. result[1], result[2], result[3]);
  97. window.content.location.href = k;
  98. }
  99. ]
  100. ];
  101. /////////////////////////////////////////
  102. // feedly
  103. local["^http://www.feedly.com/"] = [
  104. ['d', null],
  105. ['j', null],
  106. ['k', null],
  107. ['n', null],
  108. ['p', null],
  109. ['o', null],
  110. ['b', null],
  111. ['S', null],
  112. ['s', null],
  113. ['?', null],
  114. ['r', null],
  115. ['g', null],
  116. // ['x', function(ev, arg){
  117. // ev.target.dispatchEvent(key.stringToKeyEvent("g", true));
  118. // }],
  119. ['l', function(ev, arg){
  120. window.content.location.href = "http://www.feedly.com/home#latest";
  121. }],
  122. [['t', 'p'], function(ev, arg){
  123. ev.target.dispatchEvent(key.stringToKeyEvent("t", true));
  124. }],
  125. [['t', 'w'], function(ev, arg){
  126. ext.exec("twitter-client-tweet", arg, ev);
  127. }]
  128. ];
  129. /////////////////////////////////////////
  130. //nicovideo
  131. local["http://(www|tw|es|de|)\.nicovideo\.jp\/(watch|playlist)/*"] = [
  132. ["i", function(ev, arg){ ext.exec("nicoinfo", arg); }],
  133. ["p", function(ev, arg){ ext.exec("nicopause", arg); }],
  134. // ["o", function(ev, arg){ ext.exec("nicommentvisible", arg); }],
  135. ["m", function(ev, arg){ ext.exec("nicomute", arg); }],
  136. [".", function(ev, arg){ ext.exec("nicovolumeIncrement", arg); }],
  137. [",", function(ev, arg){ ext.exec("nicovolumeDecrement", arg); }],
  138. ['f', function(ev, arg){
  139. curl = window.content.location.href;
  140. kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  141. window.content.location.href = kurl;
  142. }
  143. ]
  144. ];
  145. /////////////////////////////////////////
  146. // tumblr/dashboard
  147. local["^http://www.tumblr.com/dashboard"] = [
  148. // ["C-<left>", function(ev, arg){
  149. // gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  150. // }],
  151. // ["C-<right>", function(ev, arg){
  152. // gBrowser.mTabContainer.advanceSelectedTab(1, true);
  153. // }],
  154. ["<left>", function(ev, arg){
  155. window.content.location.href = "http://www.tumblr.com/dashboard";
  156. }],
  157. ["<right>", null],
  158. ["J", function(ev, arg){
  159. if (window.loadURI) {
  160. 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;}())");
  161. }
  162. }]
  163. ];
  164. ///////////////////////////////////////////
  165. // plugin option
  166. plugins.options["builtin_commands_ext.ext_list"] = [
  167. "focus-to-prompt",
  168. "open-url-from-clipboard",
  169. "restart-firefox"
  170. ];
  171. plugins.options["instapaper.close_after_post"] = true;
  172. plugins.options["instapaper.initial_comment_function"] = function(){
  173. var now = new Date();
  174. return "[" + now.toString() + "]";
  175. };
  176. //////////////////////////////////////////
  177. // yatc
  178. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  179. plugins.options["twitter_client.popup_new_statuses"] = false;
  180. plugins.options["twitter_client.automatically_begin"] = false;
  181. plugins.options["twitter_client.automatically_begin_list"] = false;
  182. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  183. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  184. plugins.options["twitter_client.tweet_keymap"] = {
  185. "C-RET" : "prompt-decide",
  186. "RET" : ""
  187. };
  188. plugins.options["twitter_client.jmp_id"] = "10sr";
  189. plugins.options["twitter_client.jmp_key"] =
  190. "R_c51f889a77cb4b4e993ed868f65083f5";
  191. plugins.options["twitter_client.use_jmp"] = true;
  192. ////////////////////////////////////////////
  193. // my ext
  194. (function(){
  195. function getOrganizer(){
  196. // [How to call for Firefox bookmark dialog? - Stack Overflow]
  197. // (http://stackoverflow.com/questions/9158187/how-to-call-for-firefox-bookmark-dialog)
  198. Components.utils.import("resource://gre/modules/Services.jsm");
  199. var organizer = Services.wm.getMostRecentWindow("Places:Organizer");
  200. if (!organizer) {
  201. // No currently open places window,
  202. // so open one with the specified mode.
  203. openDialog("chrome://browser/content/places/places.xul",
  204. "",
  205. "chrome,toolbar=yes,dialog=no,resizable",
  206. "AllBookmarks");
  207. return null;
  208. } else {
  209. return organizer;
  210. }
  211. }
  212. ext.add("export-bookmarks", function(ev, arg){
  213. var organizer = getOrganizer();
  214. if (organizer) {
  215. organizer.PlacesOrganizer.exportBookmarks();
  216. }
  217. }, "export bookmarks");
  218. ext.add("import-bookmarks", function(ev, arg){
  219. var organizer = getOrganizer();
  220. if (organizer) {
  221. organizer.PlacesOrganizer.importBookmarks();
  222. }
  223. }, "import bookmarks");
  224. })();
  225. ext.add("my-index-html", function(ev, arg){
  226. homepath = util.getEnv("HOME");
  227. file = ".index.html";
  228. if (homepath) {
  229. path = "file://" + homepath + "/" + file;
  230. openUILinkIn(path, "tab");
  231. }
  232. }, "open my index.html");
  233. ext.add("echo-tab-info", function(){
  234. var all = gBrowser.tabs.length;
  235. var ix = gBrowser.mCurrentTab._tPos;
  236. var title = window.document.title;
  237. var url = window.content.location.href;
  238. display.echoStatusBar((ix + 1).toString() + " / " +
  239. all.toString() + " : " +
  240. title + " <" +
  241. url + ">");
  242. }, "echo tab info");
  243. ext.add("strong-fullscreen", function(){
  244. var elemids = [
  245. "navigator-toolbox"
  246. ];
  247. BrowserFullScreen();
  248. var isfullscreen = window.fullScreen;
  249. for(var i = 0; i < elemids.length; i++){
  250. var elem = document.getElementById(elemids[i]);
  251. if(elem){
  252. if(isfullscreen){
  253. elem.style.display = "none";
  254. }else{
  255. elem.style.display = null;
  256. }
  257. }
  258. }
  259. var tabs = document.getElementById("verticaltabs-box");
  260. if(tabs){
  261. var pref_key = "extensions.verticaltabs.width";
  262. var pref_key_bak = pref_key + "_bak";
  263. if(isfullscreen){
  264. var width_orig = util.getIntPref(pref_key);
  265. util.setIntPref(pref_key_bak, width_orig);
  266. util.setIntPref(pref_key, 0);
  267. tabs.setAttribute("width", "0");
  268. }else if(parseInt(tabs.getAttribute("width") || "") === 0){
  269. var width_bak = util.getIntPref(pref_key_bak);
  270. util.setIntPref(pref_key, width_bak);
  271. tabs.setAttribute("width", width_bak.toString());
  272. }
  273. }
  274. }, "go fullscreen with hiding toolbar and tabbar");
  275. ext.add("bookmark-delicious", function(){
  276. f= 'http://www.delicious.com/save?url=' +
  277. encodeURIComponent(window.content.location.href) +
  278. '&title=' + encodeURIComponent(document.title) +
  279. '&notes=' + encodeURIComponent(
  280. '' + (window.getSelection ?
  281. window.getSelection() : (
  282. document.getSelection ?
  283. document.getSelection() :
  284. document.selection.createRange().text))) + '&v=6&';
  285. a = function(){
  286. if(! window.open(
  287. f + 'noui=1&jump=doclose',
  288. 'deliciousuiv6',
  289. 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){
  290. location.href = f + 'jump=yes';
  291. }
  292. };
  293. if(/Firefox/.test(navigator.userAgent)){
  294. setTimeout(a,0);
  295. }else{
  296. a();
  297. }
  298. }, "bookmark delicious");
  299. ext.add('view-page-source', function(){
  300. window.content.location.href = "view-source:" +
  301. window.content.location.href;
  302. }, 'view page source');
  303. ext.add('my-setpref', function(){
  304. util.setPrefs(
  305. {
  306. "browser.bookmarks.max_backups":0,
  307. "browser.cache.memory.capacity":16384,
  308. "browser.download.manager.closeWhenDone":true,
  309. "browser.download.useDownloadDir":false,
  310. "browser.fullscreen.autohide":false,
  311. "browser.search.openintab":true,
  312. "browser.sessionhistory.max_total_viewers":8,
  313. "browser.sessionstore.restore_on_demand":true,
  314. "browser.tabs.closeWindowWithLastTab":false,
  315. "browser.tabs.loadDivertedInBackground": true,
  316. "browser.urlbar.autocomplete.enabled":false,
  317. "browser.urlbar.trimURLs":false,
  318. "dom.disable_window_open_feature.location": false,
  319. "dom.max_script_run_time": 30,
  320. "extensions.chaika.bbsmenu.open_new_tab":true,
  321. "extensions.chaika.bbsmenu.open_single_click":false,
  322. "extensions.chaika.board.open_new_tab":true,
  323. "extensions.chaika.board.open_single_click":false,
  324. "extensions.foxage2ch.openThreadInTab":true,
  325. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  326. "extensions.saveimageinfolder.general-fileprefixvalue":
  327. "%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  328. "extensions.saveimageinfolder.usecache":true,
  329. "extensions.tabutils.openTabNext":1,
  330. "extensions.tabutils.styles.current":
  331. "{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  332. "extensions.tabutils.styles.unread":
  333. "{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}",
  334. "extensions.yass.edgetype":0,
  335. "extensions.yass.selectedpreset":"red",
  336. "font.default.x-western":"sans-serif",
  337. "gecko.handlerService.schemes.mailto.1.name":"Gmail",
  338. "general.warnOnAboutConfig":false,
  339. "keyword.URL":"http://www.bing.com/search?q=",
  340. "network.dns.disableIPv6":true,
  341. "refcontrol.actions":
  342. "@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL",
  343. "scrapbook.tabs.open":true
  344. }
  345. );
  346. if(/^Linux/.test(navigator.platform)){
  347. util.setPrefs(
  348. {
  349. "browser.cache.disk.parent_directory":"/tmp",
  350. "browser.cache.disk.capacity":524288
  351. }
  352. );
  353. }
  354. display.showPopup("Keysnail", "My prefs done.");
  355. }, 'my setpref');
  356. ext.add('auto-install-plugins', function(ev, arg){
  357. var urls = [
  358. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  359. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  360. 'https://raw.github.com/mooz/keysnail/master/plugins/hok.ks.js',
  361. 'https://github.com/mooz/keysnail/raw/master/plugins/builtin-commands-ext.ks.js',
  362. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  363. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  364. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  365. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  366. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  367. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  368. 'https://raw.github.com/10sr/keysnail-plugin/master/pixiv_autojump.ks.js',
  369. 'https://raw.github.com/10sr/keysnail-plugin/master/list-current-urls.ks.js',
  370. 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js',
  371. 'https://raw.github.com/gist/1450594/mstranslator.ks.js'
  372. ];
  373. function inst(a){
  374. if(a.length == 0){
  375. display.showPopup("auto-install-plugins",
  376. "All installation finished.");
  377. }else{
  378. var url = a.shift();
  379. var path = userscript.pluginDir +
  380. userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  381. if(plugins.context[path] === undefined){
  382. userscript.installPluginFromURL(url, function(){inst(a);});
  383. }else{
  384. inst(a);
  385. }
  386. }
  387. }
  388. inst(urls);
  389. }, 'Install plugins automatically if not installed yet.');
  390. ext.add('put-aside-this-page', function (ev, arg) {
  391. var n = gBrowser.mCurrentTab._tPos;
  392. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  393. if (n != 0) {
  394. gBrowser.selectedTab = gBrowser.mTabs[n];
  395. }
  396. }, 'put aside this page');
  397. ext.add('send-escape', function (ev, arg) {
  398. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  399. }, 'escape');
  400. ext.add("open-hatebu-comment", function (ev, arg) {
  401. var url = window.content.location.href.replace(/^[^/]*\/\//, "");
  402. window.content.location.href = "http://b.hatena.ne.jp/entry/" + url;
  403. }, 'hatebu');
  404. // ext.add("focus-on-content", function(){
  405. // let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  406. // gBrowser.focus();
  407. // content.focus();
  408. // }, "forcus on content");
  409. ext.add("hide-sidebar", function(){
  410. var sidebarBox = document.getElementById("sidebar-box");
  411. if (!sidebarBox.hidden) {
  412. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  413. }
  414. }, "hide-sidebar");
  415. ext.add("close-and-next-tab", function (ev, arg) {
  416. var n = gBrowser.mCurrentTab._tPos;
  417. gBrowser.removeCurrentTab();
  418. gBrowser.selectedTab = gBrowser.mTabs[n];
  419. }, "close and focus to next tab");
  420. //////////////////////////////////////
  421. //
  422. ext.add("restart-firefox-add-menu", function(){
  423. const XUL_NS =
  424. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  425. var cmdelm = document.createElementNS(XUL_NS, "command");
  426. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs");
  427. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  428. var commandset = document.getElementById("mainCommandSet");
  429. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  430. commandset.appendChild(cmdelm);
  431. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  432. menuelm.setAttribute("label", "Restart Firefox");
  433. menuelm.setAttribute("id", "my_menu_restartFirefoxKs");
  434. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  435. var menu = document.getElementById("menu_FilePopup");
  436. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  437. menu.appendChild(menuelm);
  438. }, "add restart firefox menu");
  439. /////////////////////////////////////////
  440. // copy feed url
  441. ext.add("copy-url", function () {
  442. const doc = content.document;
  443. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  444. for ([, e] in Iterator(doc.querySelectorAll([
  445. 'link[type="application/rss+xml"]',
  446. 'link[type="application/atom+xml"]'
  447. ])))];
  448. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  449. for (i = 0; i < feeds.length; i++)
  450. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  451. feeds.unshift([window.content.document.title,window.content.location.href]);
  452. prompt.selector(
  453. {
  454. message : "Select Feed",
  455. collection : feeds,
  456. callback : function (i) {
  457. if (i >= 0)
  458. command.setClipboardText(feeds[i][1]);
  459. }
  460. }
  461. );
  462. }, "Copy url or feed url of current page");
  463. ///////////////////////////////////////
  464. // keysnail z menu
  465. ext.add("keysnail-setting-dialog", function(){
  466. KeySnail.openPreference();
  467. }, "keysnail setting dialog");
  468. ext.add("keysnail-plugin-manager", function(){
  469. userscript.openPluginManager();
  470. }, "keysnail plugin manager");
  471. ext.add("firefox-open-addon-manager", function(){
  472. BrowserOpenAddonsMgr();
  473. }, "firefox addon manager");
  474. ext.add("keysnail-reload-init-file", function(){
  475. userscript.reload();
  476. }, "keysnail reload init file");
  477. ext.add("keysnail-z-menu",function(){
  478. var list = [["keysnail-setting-dialog"],
  479. ["keysnail-plugin-manager"],
  480. ["firefox-open-addon-manager"],
  481. ["keysnail-reload-init-file"],
  482. // ["check-for-plugins-update"],
  483. ["restart-firefox"]
  484. ];
  485. prompt.selector(
  486. {
  487. message : "open setting dialog",
  488. collection : list,
  489. callback : function (i) {
  490. ext.exec(list[i][0]);
  491. }
  492. });
  493. },"open keysnail z menu");
  494. ///////////////////////////////////
  495. // search web
  496. ext.add("query-then-engine", function () {
  497. prompt.reader({
  498. message : "Search Word?:",
  499. group : "query_word",
  500. completer : completer.matcher.header(share.friendsCache || []),
  501. callback : function (q) {
  502. if (q) {
  503. prompt.selector({
  504. message : "search \"" + q + "\" with?",
  505. collection : plugins.options["search-url-list"],
  506. width : [20,80],
  507. callback : function (i) {
  508. getBrowser().selectedTab =
  509. getBrowser().addTab(
  510. plugins.options["search-url-list"][i][1].
  511. replace("%r",q).replace(
  512. "%q",encodeURIComponent(q)));
  513. }
  514. });
  515. };
  516. },
  517. initialInput : content.document.getSelection() || ""
  518. });
  519. }, "enter search word and then select engine");
  520. /////////////////////////////////////
  521. // closed tab list
  522. ext.add("list-closed-tabs", function () {
  523. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  524. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(
  525. Ci.nsISessionStore
  526. );
  527. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  528. var closedTabs = [[tab.image || fav, tab.title, tab.url]
  529. for each (tab in json.decode(ss.getClosedTabData(window)))
  530. ];
  531. if (!closedTabs.length)
  532. return void display.echoStatusBar("No recently closed tab.", 2000);
  533. prompt.selector(
  534. {
  535. message : "select tab to undo:",
  536. collection : closedTabs,
  537. flags : [ICON | IGNORE, 0, 0],
  538. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  539. });
  540. }, "List closed tabs");
  541. ///////////////////////////////
  542. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  543. ext.add("list-tab-history", function () {
  544. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  545. var tabHistory = [];
  546. var sessionHistory = gBrowser.webNavigation.sessionHistory;
  547. if (sessionHistory.count < 1)
  548. return void display.echoStatusBar("Tab history not exist", 2000);
  549. var curIdx = sessionHistory.index;
  550. for (var i = 0; i < sessionHistory.count; i++) {
  551. var entry = sessionHistory.getEntryAtIndex(i, false);
  552. if (!entry)
  553. continue;
  554. try {
  555. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  556. .getService(Ci.nsIFaviconService)
  557. .getFaviconForPage(entry.URI).spec;
  558. } catch (ex) {}
  559. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  560. }
  561. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  562. if (tabHistory[thIdx][3] == curIdx) break;
  563. }
  564. prompt.selector(
  565. {
  566. message : "select history in tab",
  567. collection : tabHistory,
  568. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  569. header : ["Title", "URL"],
  570. initialIndex : thIdx,
  571. callback : function(i) {
  572. if (i >= 0) gBrowser.webNavigation.gotoIndex(tabHistory[i][3]);
  573. }
  574. });
  575. }, 'List tab history');
  576. //}}%PRESERVE%
  577. // ========================================================================= //
  578. // ========================= Special key settings ========================== //
  579. key.quitKey = "ESC";
  580. key.helpKey = "<f1>";
  581. key.escapeKey = "C-q";
  582. key.macroStartKey = "";
  583. key.macroEndKey = "";
  584. key.universalArgumentKey = "C-u";
  585. key.negativeArgument1Key = "C--";
  586. key.negativeArgument2Key = "C-M--";
  587. key.negativeArgument3Key = "M--";
  588. key.suspendKey = "Not defined";
  589. // ================================= Hooks ================================= //
  590. hook.setHook('KeyBoardQuit', function (aEvent) {
  591. ext.exec("hide-sidebar");
  592. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  593. gBrowser.focus();
  594. content.focus();
  595. command.closeFindBar();
  596. if (util.isCaretEnabled()) {
  597. command.resetMark(aEvent);
  598. } else {
  599. goDoCommand("cmd_selectNone");
  600. }
  601. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  602. });
  603. hook.setHook('Unload', function () {
  604. util.getBrowserWindows().some(function (win) {
  605. if (win === window) {
  606. return false;
  607. }
  608. const ks = win.KeySnail;
  609. share.pluginUpdater = ks.getPluginUpdater(
  610. share.pluginUpdater.pluginsWithUpdate
  611. );
  612. ks.setUpPluginUpdaterDelegator();
  613. return true;
  614. });
  615. });
  616. // ============================= Key bindings ============================== //
  617. key.setGlobalKey('C-<right>', function () {
  618. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  619. }, 'ひとつ右のタブへ');
  620. key.setGlobalKey('C-<left>', function () {
  621. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  622. }, 'ひとつ左のタブへ');
  623. key.setGlobalKey('C-<up>', function () {
  624. var browser = getBrowser();
  625. if (browser.mCurrentTab.previousSibling) {
  626. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  627. } else {
  628. browser.moveTabTo(browser.mCurrentTab,
  629. browser.mTabContainer.childNodes.length - 1);
  630. }
  631. }, '選択中のタブを右へ');
  632. key.setGlobalKey('C-<down>', function () {
  633. var browser = getBrowser();
  634. if (browser.mCurrentTab.nextSibling) {
  635. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  636. } else {
  637. browser.moveTabTo(browser.mCurrentTab, 0);
  638. }
  639. }, '選択中のタブを左へ');
  640. key.setGlobalKey('<delete>', function (ev, arg) {
  641. let (elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  642. gBrowser.focus();
  643. content.focus();
  644. }, 'コンテンツへフォーカス', true);
  645. key.setGlobalKey('<f11>', function (ev, arg) {
  646. ext.exec("strong-fullscreen", arg, ev);
  647. }, 'go fullscreen with hiding toolbar and tabbar', true);
  648. key.setViewKey('0', function (ev) {
  649. BrowserCloseTabOrWindow();
  650. }, 'タブ / ウィンドウを閉じる');
  651. key.setViewKey('N', function (ev) {
  652. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  653. }, 'ひとつ右のタブへ');
  654. key.setViewKey('P', function (ev) {
  655. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  656. }, 'ひとつ左のタブへ');
  657. key.setViewKey('o', function (ev, arg) {
  658. ext.exec("hok-start-foreground-mode", arg, ev);
  659. }, 'Start Hit a Hint foreground mode', true);
  660. key.setViewKey('c', function (ev) {
  661. command.interpreter();
  662. }, 'JavaScript のコードを評価');
  663. key.setViewKey('D', function (ev, arg) {
  664. ext.exec("dig-url", arg, ev);
  665. }, 'dig url with selector', true);
  666. key.setViewKey('x', function (aEvent, aArg) {
  667. ext.select(aArg, aEvent);
  668. }, 'エクステ一覧');
  669. key.setViewKey(['t', 'w'], function (ev, arg) {
  670. ext.exec("twitter-client-tweet", arg, ev);
  671. }, 'つぶやく', true);
  672. key.setViewKey(['t', 'p'], function (ev, arg) {
  673. ext.exec("twitter-client-tweet-this-page", arg, ev);
  674. }, 'このページのタイトルと URL を使ってつぶやく', true);
  675. key.setViewKey([['u'], ['<left>']], function (ev) {
  676. goDoCommand("cmd_scrollPageUp");
  677. }, '一画面分スクロールアップ');
  678. key.setViewKey('g', function () {
  679. goDoCommand("cmd_scrollTop");
  680. }, 'ページ先頭へ移動');
  681. key.setViewKey('G', function () {
  682. goDoCommand("cmd_scrollBottom");
  683. }, 'ページ末尾へ移動');
  684. key.setViewKey('r', function (aEvent) {
  685. BrowserReload();
  686. }, '再読み込み');
  687. key.setViewKey('m', function (ev, arg) {
  688. _fi.toogle();
  689. }, 'fetchimiをトグル');
  690. key.setViewKey('SPC', function (ev, arg) {
  691. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  692. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  693. }, 'タブの選択をトグルして次のタブ');
  694. key.setViewKey('S-SPC', function (ev, arg) {
  695. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  696. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  697. }, 'タブの選択をトグルして前のタブ');
  698. key.setViewKey('z', function (ev, arg) {
  699. ext.exec("keysnail-z-menu", arg, ev);
  700. }, 'open keysnail setting menu', true);
  701. key.setViewKey('C-SPC', function (ev, arg) {
  702. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  703. }, 'タブの選択をトグル');
  704. key.setViewKey('e', function () {
  705. command.focusElement(command.elementsRetrieverTextarea, 0);
  706. }, '最初のインプットエリアへフォーカス', true);
  707. key.setViewKey('S', function (ev, arg) {
  708. if (window.loadURI) {
  709. 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{}");
  710. }
  711. }, 'google reader share');
  712. key.setViewKey('!', function (ev, arg) {
  713. shell.input();
  714. }, 'Command system');
  715. key.setViewKey('R', function () {
  716. BrowserReloadSkipCache();
  717. }, '更新(キャッシュを無視)');
  718. key.setViewKey('<backspace>', function () {
  719. BrowserBack();
  720. }, '戻る');
  721. key.setViewKey('S-<backspace>', function () {
  722. BrowserForward();
  723. }, '進む');
  724. key.setViewKey('q', function (ev, arg) {
  725. ext.exec("query-then-engine", arg, ev);
  726. }, 'enter search word and then select engine', true);
  727. key.setViewKey('/', function () {
  728. command.iSearchForward();
  729. }, 'インクリメンタル検索', true);
  730. key.setViewKey('?', function (ev) {
  731. command.iSearchForwardKs(ev);
  732. }, 'Emacs ライクなインクリメンタル検索', true);
  733. key.setViewKey('a', function (ev, arg) {
  734. allTabs.open();
  735. }, 'alltabs.open');
  736. key.setViewKey([['<right>'], ['d']], function (ev) {
  737. goDoCommand("cmd_scrollPageDown");
  738. }, '一画面スクロールダウン');
  739. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  740. return;
  741. }, 'ignore');
  742. key.setViewKey(':', function (ev, arg) {
  743. return !document.getElementById("keysnail-prompt").hidden &&
  744. document.getElementById("keysnail-prompt-textbox").focus();
  745. }, 'KeySnail のプロンプトへフォーカス', true);
  746. key.setViewKey('B', function (ev) {
  747. var browser = getBrowser();
  748. if (browser.mCurrentTab.previousSibling) {
  749. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  750. } else {
  751. browser.moveTabTo(browser.mCurrentTab,
  752. browser.mTabContainer.childNodes.length - 1);
  753. }
  754. }, '選択中のタブを左へ');
  755. key.setViewKey('C', function (ev, arg) {
  756. ext.exec("linksnail", arg, ev);
  757. }, 'LinkSnail', true);
  758. key.setViewKey('C-<backspace>', function (ev, arg) {
  759. ext.exec("list-tab-history", arg, ev);
  760. }, 'List tab history', true);
  761. key.setViewKey('I', function (ev, arg) {
  762. ext.exec("instapaper-post-page-with-comment", arg, ev);
  763. }, 'post page and comment', true);
  764. key.setViewKey('T', function (ev, arg) {
  765. ext.exec("mstranslator-open-prompt", arg, ev);
  766. }, 'MSTranslator - Open prompt', true);
  767. key.setViewKey('n', function (ev) {
  768. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
  769. }, '一行スクロールダウン');
  770. key.setViewKey('p', function (ev) {
  771. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
  772. }, '一行スクロールアップ');
  773. key.setViewKey('f', function (ev) {
  774. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RIGHT, true);
  775. }, '右へスクロール');
  776. key.setViewKey('b', function (ev) {
  777. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true);
  778. }, '左へスクロール');
  779. key.setViewKey('F', function (ev) {
  780. var browser = getBrowser();
  781. if (browser.mCurrentTab.nextSibling) {
  782. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  783. } else {
  784. browser.moveTabTo(browser.mCurrentTab, 0);
  785. }
  786. }, '選択中のタブを右へ');
  787. key.setViewKey('U', function (ev, arg) {
  788. ext.exec("list-closed-tabs", arg, ev);
  789. }, 'List closed tabs', true);
  790. key.setEditKey('C-<tab>', function (ev) {
  791. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  792. }, '次のテキストエリアへフォーカス');
  793. key.setEditKey('C-a', function (ev) {
  794. command.beginLine(ev);
  795. }, '行頭へ移動');
  796. key.setEditKey('C-e', function (ev) {
  797. command.endLine(ev);
  798. }, '行末へ');
  799. key.setEditKey('C-d', function (ev) {
  800. goDoCommand("cmd_deleteCharForward");
  801. }, '次の一文字削除');
  802. key.setEditKey('C-b', function (ev) {
  803. command.previousChar(ev);
  804. }, '一文字左へ移動');
  805. key.setEditKey('C-f', function (ev) {
  806. command.nextChar(ev);
  807. }, '一文字右へ移動');
  808. key.setEditKey('C-h', function (ev) {
  809. goDoCommand("cmd_deleteCharBackward");
  810. }, '前の一文字を削除');
  811. key.setEditKey('C-k', function (ev) {
  812. command.killLine(ev);
  813. }, 'カーソルから先を一行カット (Kill line)');
  814. key.setEditKey('C-l', function (ev) {
  815. command.recenter(ev);
  816. }, 'カーソル位置が画面の中央へ来るようスクロール', true);
  817. key.setEditKey('C-n', function (ev) {
  818. command.nextLine(ev);
  819. }, '一行下へ');
  820. key.setEditKey('C-p', function (ev) {
  821. command.previousLine(ev);
  822. }, '一行上へ');
  823. key.setEditKey('C-o', function (ev) {
  824. command.openLine(ev);
  825. }, '行を開く (Open line)');
  826. key.setViewKey('f', function (ev, arg) {
  827. ext.exec('strong-fullscreen', arg, ev);
  828. }, 'go fullscreen with hiding toolbar and tabbar', true);