25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

_keysnail.js 32 KiB

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