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 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  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. //userscript.addLoadPath(".");
  13. //userscript.require("verticaltab.js");
  14. //////////////////////////////////////
  15. //// sitelocalkeymap
  16. var local = {};
  17. plugins.options["site_local_keymap.local_keymap"] = local;
  18. function fake(k, i) function () { key.feed(k, i); };
  19. function pass(k, i) [k, fake(k, i)];
  20. function ignore(k, i) [k, null];
  21. // ext.add("ext-name", function () {}, "ext description");
  22. // style.register("");
  23. // local["^http://"] = [['a', function(ev, arg){}],];
  24. ///////////////////////////////////////////
  25. //// firefox
  26. // style.register("#bookmarksPanel > hbox,#history-panel > hbox {display: none !important;} //#urlbar-container{max-width: 500px !important;}");
  27. util.setPrefs(
  28. {
  29. "browser.tabs.loadDivertedInBackground": true,
  30. "dom.disable_window_open_feature.location": false,
  31. "dom.max_script_run_time": 30,
  32. "browser.bookmarks.max_backups":0,
  33. "browser.urlbar.autocomplete.enabled":false,
  34. "browser.cache.memory.capacity":16384,
  35. "browser.sessionhistory.max_total_viewers":8,
  36. "browser.download.manager.closeWhenDone":true,
  37. "browser.download.useDownloadDir":false,
  38. "browser.tabs.closeWindowWithLastTab":false,
  39. "network.dns.disableIPv6":true,
  40. "browser.urlbar.trimURLs":false,
  41. "browser.fullscreen.autohide":false,
  42. "keyword.URL":"http://www.bing.com/search?q=",
  43. }
  44. );
  45. ///////////////////////////////////
  46. //検索エンジン
  47. plugins.options["search-url-list"] = [
  48. ["bing","http://bing.com/search?q=%q"],
  49. ["yatwitter search","http://yats-data.com/yats/search?query=%q"],
  50. ["twitter search","http://search.twitter.com/search?q=%q&lang=all"],
  51. ["tospy", "http://topsy.com/s?allow_lang=ja&q=%q"],
  52. ["2ch","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  53. ["I\'m feelig lucky!","http://www.google.co.jp/search?q=%q&btnI=kudos"],
  54. ["uncyclopedia","http://ja.uncyclopedia.info/wiki/%q"],
  55. ["wikipedia","http://ja.wikipedia.org/wiki/%q"],
  56. ["nicovideo.jp","http://www.nicovideo.jp/search/%q"],
  57. ["alc","http://eow.alc.co.jp/%q/UTF-8/"],
  58. ["google map","http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  59. ["weblio","http://www.weblio.jp/content_find?query=%q"],
  60. ["shoutcast","http://www.shoutcast.com/Internet-Radio/%q"],
  61. ["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"],
  62. ["delicious 10sr","http://delicious.com/10sr?addtag=%q&setcount=50&opennew=1"],
  63. ["open raw","%r"],
  64. ];
  65. plugins.options["my-keysnail-bookmarks"] = [
  66. "twitter.com",
  67. ];
  68. //sitelocal
  69. //////////////////////////////////////////
  70. // 2ch chaika
  71. local["^http://127.0.0.1:8823/thread/"] = [
  72. ['k', function (ev, arg) {
  73. curl = window.content.location.href;
  74. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  75. window.content.location.href = kurl;
  76. }
  77. ],
  78. ];
  79. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  80. ['k', function (ev, arg) {
  81. var url = window.content.location.href;
  82. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  83. var result = url.match(pt);
  84. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/", result[1], result[2], result[3]);
  85. window.content.location.href = k;
  86. }
  87. ],
  88. ];
  89. /////////////////////////////////////////
  90. // feedly用マップ
  91. local["^http://www.feedly.com/"] = [
  92. ['d', null],
  93. ['j', null],
  94. ['k', null],
  95. ['n', null],
  96. ['p', null],
  97. ['o', null],
  98. ['b', null],
  99. ['S', null],
  100. ['s', null],
  101. ['?', null],
  102. ['l', function (ev, arg) {window.content.location.href = "http://www.feedly.com/home#latest";}],
  103. ['r', null],
  104. ['x', function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("g", true));}],
  105. [['t', 'p'], function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("t", true));}],
  106. [['t', 'w'], function (ev, arg) {ext.exec("twitter-client-tweet", arg, ev);}],
  107. ];
  108. /////////////////////////////////////////
  109. //nicovideo用
  110. local["http://(www|tw|es|de|)\.nicovideo\.jp\/watch/*"] = [
  111. ["i", function (ev, arg) { ext.exec("nicoinfo", arg); }],
  112. ["p", function (ev, arg) { ext.exec("nicopause", arg); }],
  113. ["o", function (ev, arg) { ext.exec("nicommentvisible", arg); }],
  114. ["m", function (ev, arg) { ext.exec("nicomute", arg); }],
  115. [".", function (ev, arg) { ext.exec("nicovolumeIncrement", arg); }],
  116. [",", function (ev, arg) { ext.exec("nicovolumeDecrement", arg); }],
  117. ['f', function (ev, arg) {
  118. curl = window.content.location.href;
  119. kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  120. window.content.location.href = kurl;
  121. }
  122. ],
  123. ];
  124. /////////////////////////////////////////
  125. // tumblr/dashboard
  126. local["^http://www.tumblr.com/dashboard"] = [
  127. // ["C-<left>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(-1, true); }],
  128. // ["C-<right>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(1, true); }],
  129. ["<left>", function (ev, arg) {window.content.location.href = "http://www.tumblr.com/dashboard"; }],
  130. // ["<right>", null],
  131. ["J", function (ev, arg) {
  132. if (window.loadURI) {
  133. 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;}())");
  134. }
  135. }],
  136. ];
  137. ///////////////////////////////////
  138. //tanythhing用
  139. plugins.options["tanything_opt.keymap"] = {
  140. "\\" : "prompt-cancel",
  141. "j" : "prompt-next-completion",
  142. "k" : "prompt-previous-completion",
  143. "o" : "localOpen",
  144. ":" : "localClose",
  145. "L" : "localMovetoend"
  146. };
  147. //////////////////////////////////////////
  148. // yatc
  149. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  150. plugins.options["twitter_client.popup_new_statuses"] = false;
  151. plugins.options["twitter_client.automatically_begin"] = false;
  152. plugins.options["twitter_client.automatically_begin_list"] = false;
  153. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  154. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  155. plugins.options["twitter_client.tweet_keymap"] = {
  156. "C-RET" : "prompt-decide",
  157. "RET" : ""
  158. };
  159. plugins.options["twitter_client.jmp_id"] = "10sr";
  160. plugins.options["twitter_client.jmp_key"] = "R_c51f889a77cb4b4e993ed868f65083f5";
  161. plugins.options["twitter_client.use_jmp"] = true;
  162. ////////////////////////////////////////////
  163. // エクステ
  164. ext.add('send-escape', function (ev, arg) {
  165. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  166. }, 'escape');
  167. ext.add("open-hatebu-comment", function (ev, arg) {
  168. if (window.loadURI) {
  169. loadURI("javascript:location.href='http://b.hatena.ne.jp/entry?mode=more&url='+escape(location.href);");
  170. }
  171. }, 'hatebu');
  172. /////////////////////////////////////
  173. // google itranslate
  174. (function(){
  175. let targetLang = "ja"; // target lang to translate into
  176. let alternativeLang = "en"; // if given word is in targetLang, use this instead as a target lang
  177. function translate(word, target, next) {
  178. next("", "", " getting...");
  179. const base = "https://www.googleapis.com/language/translate/v2?key=%s&q=%s&target=%s";
  180. const apikey = "AIzaSyBq48p8NhFgaJ1DfUJ5ltbwLxeXpjEL86A";
  181. let ep = util.format(base, apikey, encodeURIComponent(word), target);
  182. util.httpGet(ep, false, function (res) {
  183. if (res.status === 200) {
  184. let json = decodeJSON(res.responseText);
  185. let srclang = json.data.translations[0].detectedSourceLanguage;
  186. if (target == srclang) {
  187. lookupword(word, alternativeLang);
  188. } else {
  189. let result = json.data.translations[0].translatedText;
  190. next(srclang, target, result);
  191. }
  192. } else {
  193. next("", "", "ERROR!");
  194. }
  195. });
  196. };
  197. function echo(srclang, from, tglang, to){
  198. display.echoStatusBar(srclang + " : " + from + " -> " + tglang + " : " + to);
  199. };
  200. function decodeJSON(json) {
  201. return util.safeEval("(" + json + ")");
  202. };
  203. function lookupword(word, target){
  204. translate(word, target, function (src, tg, translated) {
  205. echo(src, word, tg, translated);
  206. });
  207. };
  208. function read (aInitialInput) {
  209. let prevText = "";
  210. prompt.reader({
  211. message : "word or sentence to translate:",
  212. initialinput : aInitialInput,
  213. onChange: function (arg) {
  214. let word = arg.textbox.value;
  215. if (word !== prevText) {
  216. prevText = word;
  217. lookupword(word, targetLang);
  218. }
  219. },
  220. callback: function (s){},
  221. });
  222. };
  223. ext.add("google-itranslate",function(){read(content.document.getSelection() || "");},"google itranslate");
  224. })();
  225. //////////////////////////////////////
  226. //
  227. ext.add("restart-firefox-add-menu", function(){
  228. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  229. var cmdelm = document.createElementNS(XUL_NS, "command");
  230. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs")
  231. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  232. var commandset = document.getElementById("mainCommandSet");
  233. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  234. commandset.appendChild(cmdelm);
  235. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  236. menuelm.setAttribute("label", "Restart Firefox");
  237. menuelm.setAttribute("id", "my_menu_restartFirefoxKs")
  238. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  239. var menu = document.getElementById("menu_FilePopup");
  240. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  241. menu.appendChild(menuelm);
  242. }, "add restart firefox menu");
  243. //////////////////////////////////////
  244. //
  245. ext.add("fullscreen-page",function (ev) {
  246. getBrowser().selectedTab = getBrowser().addTab("http://home.tiscali.nl/annejan/swf/timeline.swf");
  247. BrowserFullScreen();
  248. }, "fullscreen page");
  249. //////////////////////////////////////
  250. // restart firefox
  251. // http://keysnail.g.hatena.ne.jp/Shinnya/20100723/1279878815
  252. ext.add("restart-firefox",function (ev) {
  253. const nsIAppStartup = Components.interfaces.nsIAppStartup;
  254. // Notify all windows that an application quit has been requested.
  255. var os = Components.classes["@mozilla.org/observer-service;1"]
  256. .getService(Components.interfaces.nsIObserverService);
  257. var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
  258. .createInstance(Components.interfaces.nsISupportsPRBool);
  259. os.notifyObservers(cancelQuit, "quit-application-requested", null);
  260. // Something aborted the quit process.
  261. if (cancelQuit.data)
  262. return;
  263. // Notify all windows that an application quit has been granted.
  264. os.notifyObservers(null, "quit-application-granted", null);
  265. // Enumerate all windows and call shutdown handlers
  266. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  267. .getService(Components.interfaces.nsIWindowMediator);
  268. var windows = wm.getEnumerator(null);
  269. while (windows.hasMoreElements()) {
  270. var win = windows.getNext();
  271. if (("tryToClose" in win) && !win.tryToClose())
  272. return;
  273. }
  274. Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
  275. .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
  276. }, "restart firefox");
  277. /////////////////////////////////////////
  278. // copy feed url
  279. ext.add("copy-url", function () {
  280. const doc = content.document;
  281. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  282. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  283. 'link[type="application/atom+xml"]'])))];
  284. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  285. for (i = 0; i < feeds.length; i++)
  286. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  287. feeds.unshift([window.content.document.title,window.content.location.href]);
  288. prompt.selector(
  289. {
  290. message : "Select Feed",
  291. collection : feeds,
  292. callback : function (i) {
  293. if (i >= 0)
  294. command.setClipboardText(feeds[i][1]);
  295. }
  296. }
  297. );
  298. }, "Copy url or feed url of current page");
  299. ///////////////////////////////////////
  300. // 評価しちゃうっぽい とりあえずこんな感じで
  301. ext.add("keysnail-setting-menu",function(){
  302. var settingmenulist = [["keysnail setting dialogue", function(){return function(){KeySnail.openPreference();};}],
  303. ["firefox addon manager", function(){return function(){BrowserOpenAddonsMgr();};}],
  304. ["reload .keysnail.js", function(){return function() {userscript.reload();};}],
  305. // ["check for plugins update", function(){return function(){ext.exec("check-for-plugins-update");};}],
  306. ["restart firefox", function(){return function(){ext.exec("restart-firefox");};}],
  307. ];
  308. prompt.selector(
  309. {
  310. message : "open setting dialog",
  311. collection : settingmenulist,
  312. callback : function (i) { settingmenulist[i][1]()(); },
  313. });
  314. },"open keysnail setting menu");
  315. // //////////////////////////
  316. // //プラグイン一括アップデート
  317. // ext.add("check-for-plugins-update", function () {
  318. // [p for (p in plugins.context)].forEach(function (p) { try { userscript.updatePlugin(p); } catch(e) {} });
  319. // }, "Check for all plugin's update");
  320. ////////////////////////
  321. //マルチプルタブハンドラ
  322. ext.add("multiple-tab-handler-close-selected-and-current-tabs", function () {
  323. BrowserCloseTabOrWindow();
  324. // if (MultipleTabService) {
  325. // //BrowserCloseTabOrWindow();
  326. // //MultipleTabService.setSelection(gBrowser.mCurrentTab, true);
  327. MultipleTabService.closeTabs(MultipleTabService.getSelectedTabs());
  328. // } else {
  329. // BrowserCloseTabOrWindow();}
  330. }, '選択タブと現在のタブを閉じる');
  331. ext.add("if-mth-exist", function() {
  332. if (MultipleTabService != undefined) display.echoStatusBar("true");
  333. },'if mth exist');
  334. ////////////////////////
  335. // instapaper
  336. ext.add("instapaper-add-this-page-and-close",function(){
  337. var url = window.content.location.href;
  338. var title = window.content.document.title;
  339. var tab = gBrowser.selectedTab;
  340. var username = "8slashes+instapaper@gmail.com";
  341. var password = "";
  342. var passwordManager = (Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager));
  343. var logins = passwordManager.findLogins({}, "http://www.instapaper.com", "", null);
  344. for (var i = 0; i < logins.length; i++) {
  345. if (logins[i].username == username) {
  346. password = logins[i].password;
  347. break;
  348. }
  349. }
  350. var comment = "";
  351. // prompt.read("Instapaper comment:",function(cm){
  352. // if(cm){comment = cm;}
  353. // });
  354. display.echoStatusBar("Instapaper: adding " + url + "...");
  355. util.httpPost("https://www.instapaper.com/api/add",
  356. {"username" : encodeURIComponent(username),
  357. "password" : password,
  358. "url" : encodeURIComponent(url),
  359. "title" : encodeURIComponent(title),},
  360. function (xhr) {
  361. display.echoStatusBar(xhr.status);
  362. if (xhr.readyState == 4 && xhr.status == 201) {
  363. // var title = decodeURIComponent(xhr.getResponseHeader("X-Instapaper-Title")); //超文字化けする
  364. try {
  365. Components.classes['@mozilla.org/alerts-service;1'].
  366. getService(Components.interfaces.nsIAlertsService).
  367. showAlertNotification(null, "Instapaper", "Page " + title + " added successfully", false, '', null);
  368. } catch(e) {
  369. // prevents runtime error on platforms that don't implement nsIAlertsService
  370. }
  371. display.echoStatusBar("Instapaper: adding " + url + "...done.");
  372. gBrowser.removeTab(tab);
  373. } else{
  374. display.echoStatusBar("Instapaper: Something wrong has happended!");
  375. if (window.loadURI) {
  376. loadURI("javascript:function%20iprl5(){var%20d=document,z=d.createElement('scr'+'ipt'),b=d.body,l=d.location;try{if(!b)throw(0);d.title='(Saving...)%20'+d.title;z.setAttribute('src',l.protocol+'//www.instapaper.com/j/mt8YO6Cuosmf?u='+encodeURIComponent(l.href)+'&t='+(new%20Date().getTime()));b.appendChild(z);}catch(e){alert('Please%20wait%20until%20the%20page%20has%20loaded.');}}iprl5();void(0)");
  377. }
  378. }
  379. });
  380. },'instapaper add page and close tab when done without error.');
  381. ////////////////////////
  382. //検索
  383. ext.add("query-then-engine", function () {
  384. prompt.reader({message : "Search Word?:",
  385. callback : function (q) {
  386. if (q) {
  387. prompt.selector({ message : "search \"" + q + "\" with?",
  388. collection : plugins.options["search-url-list"],
  389. width : [20,80],
  390. callback : function (i) { getBrowser().selectedTab = getBrowser().addTab(plugins.options["search-url-list"][i][1].replace("%r",q).replace("%q",encodeURIComponent(q))); },
  391. });
  392. };
  393. },
  394. initialInput : content.document.getSelection() || "",
  395. });
  396. }, "enter search word and then select engine");
  397. ///////////////////////
  398. //diggler
  399. ext.add("dig-url", function () {
  400. var url = window.content.location.href;
  401. var nsurl = [];
  402. var pname = "";
  403. var ssurl = [];
  404. var durl = [];
  405. nsurl = url.split("#");
  406. var pname = nsurl[1];
  407. ssurl = nsurl[0].split("/");
  408. durl[0] = ssurl[0] + "//" + ssurl[2];
  409. ssurl.splice(0,3);
  410. for (var i = 0; i < ssurl.length; i++){
  411. var durlsaved = durl[0];
  412. durl.unshift(durlsaved + "/" + ssurl[i]);
  413. };
  414. if (pname) {
  415. var durlfull = durl[0] + "#"+ pname;
  416. durl.unshift(durlfull);
  417. };
  418. prompt.selector({ message : "dig " + url,
  419. collection : durl,
  420. callback : function (i) { window.content.location.href = durl[i]; },
  421. });
  422. },"keysnail diggler ");
  423. /////////////////////////////////////
  424. // 閉じたタブリスト
  425. ext.add("list-closed-tabs", function () {
  426. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  427. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  428. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  429. var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  430. if (!closedTabs.length)
  431. return void display.echoStatusBar("最近閉じたタブが見つかりませんでした", 2000);
  432. prompt.selector(
  433. {
  434. message : "select tab to undo:",
  435. collection : closedTabs,
  436. flags : [ICON | IGNORE, 0, 0],
  437. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  438. });
  439. }, "List closed tabs");
  440. ext.add("echo-closed-tabs", function () {
  441. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  442. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  443. // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  444. var lasttab = json.decode(ss.getClosedTabData(window))[0];
  445. dump = ""
  446. for (var i in lasttab) { dump += lasttab[i] + "\n"; }
  447. confirm(dump);
  448. }, "List closed tabs");
  449. ///////////////////////////////////////
  450. //
  451. ext.add("focus-on-content", function(){
  452. document.getElementById("searchbar").focus();
  453. document.commandDispatcher.advanceFocus();
  454. document.commandDispatcher.advanceFocus();
  455. }, "forcus on content");
  456. ext.add("_focus-on-content", function(){
  457. gBrowser.focus();
  458. _content.focus();
  459. }, "focus on content");
  460. ext.add("hide-sidebar", function(){
  461. var sidebarBox = document.getElementById("sidebar-box");
  462. if (!sidebarBox.hidden) {
  463. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  464. }
  465. }, "hide-sidebar");
  466. ext.add("close-and-next-tab", function (ev, arg) {
  467. var n = gBrowser.mCurrentTab._tPos;
  468. BrowserCloseTabOrWindow();
  469. gBrowser.selectedTab = gBrowser.mTabs[n];
  470. }, "close and focus to next tab")
  471. //}}%PRESERVE%
  472. // ========================================================================= //
  473. // ========================= Special key settings ========================== //
  474. key.quitKey = "<delete>";
  475. key.helpKey = "C-h";
  476. key.escapeKey = "C-q";
  477. key.macroStartKey = "";
  478. key.macroEndKey = "";
  479. key.universalArgumentKey = "C-u";
  480. key.negativeArgument1Key = "C--";
  481. key.negativeArgument2Key = "C-M--";
  482. key.negativeArgument3Key = "M--";
  483. key.suspendKey = "Not defined";
  484. // ================================= Hooks ================================= //
  485. hook.setHook('KeySnailInitialized', function () {
  486. ext.exec("shiitake-enable-style");
  487. });
  488. hook.setHook('KeyBoardQuit', function (aEvent) {
  489. command.closeFindBar();
  490. if (util.isCaretEnabled()) {
  491. command.resetMark(aEvent);
  492. } else {
  493. goDoCommand("cmd_selectNone");
  494. }
  495. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  496. });
  497. hook.addToHook('KeyBoardQuit', function (aEvent) {
  498. ext.exec("hide-sidebar");
  499. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  500. gBrowser.focus();
  501. content.focus();
  502. });
  503. hook.setHook('Unload', function () {
  504. util.getBrowserWindows().some(function (win) {
  505. if (win === window) {
  506. return false;
  507. }
  508. const ks = win.KeySnail;
  509. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  510. ks.setUpPluginUpdaterDelegator();
  511. return true;
  512. });
  513. });
  514. // ============================= Key bindings ============================== //
  515. key.setGlobalKey('C-<right>', function () {
  516. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  517. }, 'ひとつ右のタブへ');
  518. key.setGlobalKey('C-<left>', function () {
  519. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  520. }, 'ひとつ左のタブへ');
  521. key.setGlobalKey('C-<up>', function () {
  522. var browser = getBrowser();
  523. if (browser.mCurrentTab.previousSibling) {
  524. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  525. } else {
  526. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  527. }
  528. }, '選択中のタブを右へ');
  529. key.setGlobalKey('C-<down>', function () {
  530. var browser = getBrowser();
  531. if (browser.mCurrentTab.nextSibling) {
  532. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  533. } else {
  534. browser.moveTabTo(browser.mCurrentTab, 0);
  535. }
  536. }, '選択中のタブを左へ');
  537. key.setGlobalKey('M-:', function (ev) {
  538. command.interpreter();
  539. }, 'JavaScript のコードを評価');
  540. key.setViewKey('', function (ev, arg) {
  541. var n = gBrowser.mCurrentTab._tPos;
  542. BrowserCloseTabOrWindow();
  543. gBrowser.selectedTab = gBrowser.mTabs[n];
  544. }, '閉じて次のタブ');
  545. key.setViewKey('x', function (aEvent, aArg) {
  546. ext.select(aArg, aEvent);
  547. }, 'エクステ一覧');
  548. key.setViewKey(['t', 'm'], function (ev, arg) {
  549. if (window.loadURI) {
  550. loadURI("javascript:window.location='http://api.tweetmeme.com/visit?url='+window.location;");
  551. }
  552. }, 'open with tweetmeme');
  553. key.setViewKey(['t', 'w'], function (ev, arg) {
  554. ext.exec("twitter-client-tweet", arg, ev);
  555. }, 'つぶやく', true);
  556. key.setViewKey(['t', 'p'], function (ev, arg) {
  557. ext.exec("twitter-client-tweet-this-page", arg, ev);
  558. }, 'このページのタイトルと URL を使ってつぶやく', true);
  559. key.setViewKey('u', function () {
  560. undoCloseTab();
  561. }, '閉じたタブを元に戻す');
  562. key.setViewKey('g', function () {
  563. goDoCommand("cmd_scrollTop");
  564. }, 'ページ先頭へ移動');
  565. key.setViewKey('G', function () {
  566. goDoCommand("cmd_scrollBottom");
  567. }, 'ページ末尾へ移動');
  568. key.setViewKey('r', function (aEvent) {
  569. BrowserReload();
  570. }, '再読み込み');
  571. key.setViewKey('m', function (ev, arg) {
  572. _fi.toogle();
  573. }, 'fetchimiをトグル');
  574. key.setViewKey('d', function (ev, arg) {
  575. if (window.loadURI) {
  576. loadURI("javascript:(function(){f='http://www.delicious.com/save?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=6&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv6','location=1,links=0,scrollbars=0,toolbar=0,width=550,height=585'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()");
  577. }
  578. }, 'deliciousでブックマーク');
  579. key.setViewKey('p', function (ev, arg) {
  580. if (window.loadURI) {
  581. loadURI("javascript:var%20b=document.body;var%20POSTEROUS___bookmarklet_domain='http://posterous.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='http://posterous.com/javascripts/bookmarklet2.js');void(b.appendChild(z));}else{}");
  582. }
  583. }, 'posterousに投稿');
  584. key.setViewKey('SPC', function (ev, arg) {
  585. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  586. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  587. }, 'タブの選択をトグルして次のタブ');
  588. key.setViewKey('S-SPC', function (ev, arg) {
  589. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  590. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  591. }, 'タブの選択をトグルして前のタブ');
  592. key.setViewKey('z', function (ev, arg) {
  593. ext.exec("keysnail-setting-menu", arg, ev);
  594. }, 'open keysnail setting menu', true);
  595. key.setViewKey('T', function (ev, arg) {
  596. ext.exec("google-itranslate", arg, ev);
  597. }, 'google itranslate', true);
  598. key.setViewKey('C-SPC', function (ev, arg) {
  599. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  600. }, 'タブの選択をトグル');
  601. key.setViewKey('s', function (ev, arg) {
  602. var n = gBrowser.mCurrentTab._tPos;
  603. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  604. if (n != 0) {
  605. gBrowser.selectedTab = gBrowser.mTabs[n];
  606. }
  607. }, 'このタブを保持する');
  608. key.setViewKey('U', function (ev, arg) {
  609. ext.exec("list-closed-tabs", arg, ev);
  610. }, 'List closed tabs', true);
  611. key.setViewKey('e', function () {
  612. command.focusElement(command.elementsRetrieverTextarea, 0);
  613. }, '最初のインプットエリアへフォーカス', true);
  614. key.setViewKey('S', function (ev, arg) {
  615. if (window.loadURI) {
  616. 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{}");
  617. }
  618. }, 'google reader share');
  619. key.setViewKey('!', function (ev, arg) {
  620. shell.input();
  621. }, 'Command system');
  622. key.setViewKey('b', function (ev, arg) {
  623. BarTap.putOnTap(gBrowser.mCurrentTab, gBrowser);
  624. }, 'bartab put on tab');
  625. key.setViewKey('R', function () {
  626. BrowserReloadSkipCache();
  627. }, '更新(キャッシュを無視)');
  628. key.setViewKey('<backspace>', function () {
  629. BrowserBack();
  630. }, '戻る');
  631. key.setViewKey('S-<backspace>', function () {
  632. BrowserForward();
  633. }, '進む');
  634. key.setViewKey('q', function (ev, arg) {
  635. ext.exec("query-then-engine", arg, ev);
  636. }, 'enter search word and then select engine', true);
  637. key.setViewKey('D', function (ev, arg) {
  638. ext.exec("dig-url", arg, ev);
  639. }, 'keysnail diggler ', true);
  640. key.setViewKey('/', function () {
  641. command.iSearchForward();
  642. }, 'インクリメンタル検索', true);
  643. key.setViewKey('?', function (ev) {
  644. command.iSearchForwardKs(ev);
  645. }, 'Emacs ライクなインクリメンタル検索', true);
  646. key.setViewKey('a', function (ev, arg) {
  647. allTabs.open();
  648. }, 'alltabs.open');
  649. key.setViewKey('C', function (ev, arg) {
  650. ext.exec("copy-url", arg, ev);
  651. }, '選択タブと現在のタブを閉じる', true);
  652. key.setViewKey('I', function (ev, arg) {
  653. ext.exec("instapaper-add-this-page-and-close", arg, ev);
  654. }, 'instapaper add page', true);
  655. key.setViewKey('<left>', function (ev) {
  656. goDoCommand("cmd_scrollPageUp");
  657. }, '一画面分スクロールアップ');
  658. key.setViewKey('<right>', function (ev) {
  659. goDoCommand("cmd_scrollPageDown");
  660. }, '一画面スクロールダウン');
  661. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  662. return;
  663. }, 'ignore');
  664. key.setViewKey(':', function (ev, arg) {
  665. return !document.getElementById("keysnail-prompt").hidden &&
  666. document.getElementById("keysnail-prompt-textbox").focus();
  667. }, 'KeySnail のプロンプトへフォーカス', true);
  668. key.setViewKey('H', function (ev, arg) {
  669. ext.exec("open-hatebu-comment", arg, ev);
  670. }, 'hatebu', true);
  671. key.setViewKey('l', function (ev) {
  672. command.focusToById("urlbar");
  673. }, 'ロケーションバーへフォーカス', true);
  674. key.setEditKey('C-<tab>', function (ev) {
  675. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  676. }, '次のテキストエリアへフォーカス');
  677. key.setViewKey('0', function (ev) {
  678. BrowserCloseTabOrWindow();
  679. }, 'タブ / ウィンドウを閉じる');