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.
 
 
 
 
 
 

779 rivejä
30 KiB

  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. //}}%PRESERVE%
  467. // ========================================================================= //
  468. // ========================= Special key settings ========================== //
  469. key.quitKey = "<delete>";
  470. key.helpKey = "C-h";
  471. key.escapeKey = "C-q";
  472. key.macroStartKey = "";
  473. key.macroEndKey = "";
  474. key.universalArgumentKey = "C-u";
  475. key.negativeArgument1Key = "C--";
  476. key.negativeArgument2Key = "C-M--";
  477. key.negativeArgument3Key = "M--";
  478. key.suspendKey = "Not defined";
  479. // ================================= Hooks ================================= //
  480. hook.setHook('KeySnailInitialized', function () {
  481. ext.exec("shiitake-enable-style");
  482. });
  483. hook.setHook('KeyBoardQuit', function (aEvent) {
  484. command.closeFindBar();
  485. if (util.isCaretEnabled()) {
  486. command.resetMark(aEvent);
  487. } else {
  488. goDoCommand("cmd_selectNone");
  489. }
  490. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  491. });
  492. hook.addToHook('KeyBoardQuit', function (aEvent) {
  493. ext.exec("hide-sidebar");
  494. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  495. gBrowser.focus();
  496. content.focus();
  497. });
  498. hook.setHook('Unload', function () {
  499. util.getBrowserWindows().some(function (win) {
  500. if (win === window) {
  501. return false;
  502. }
  503. const ks = win.KeySnail;
  504. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  505. ks.setUpPluginUpdaterDelegator();
  506. return true;
  507. });
  508. });
  509. // ============================= Key bindings ============================== //
  510. key.setGlobalKey('C-<right>', function () {
  511. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  512. }, 'ひとつ右のタブへ');
  513. key.setGlobalKey('C-<left>', function () {
  514. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  515. }, 'ひとつ左のタブへ');
  516. key.setGlobalKey('C-<up>', function () {
  517. var browser = getBrowser();
  518. if (browser.mCurrentTab.previousSibling) {
  519. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  520. } else {
  521. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  522. }
  523. }, '選択中のタブを右へ');
  524. key.setGlobalKey('C-<down>', function () {
  525. var browser = getBrowser();
  526. if (browser.mCurrentTab.nextSibling) {
  527. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  528. } else {
  529. browser.moveTabTo(browser.mCurrentTab, 0);
  530. }
  531. }, '選択中のタブを左へ');
  532. key.setGlobalKey('M-:', function (ev) {
  533. command.interpreter();
  534. }, 'JavaScript のコードを評価');
  535. key.setViewKey('0', function (ev, arg) {
  536. var n = gBrowser.mCurrentTab._tPos;
  537. BrowserCloseTabOrWindow();
  538. gBrowser.selectedTab = gBrowser.mTabs[n];
  539. }, '閉じて次のタブ');
  540. key.setViewKey('x', function (aEvent, aArg) {
  541. ext.select(aArg, aEvent);
  542. }, 'エクステ一覧');
  543. key.setViewKey(['t', 'm'], function (ev, arg) {
  544. if (window.loadURI) {
  545. loadURI("javascript:window.location='http://api.tweetmeme.com/visit?url='+window.location;");
  546. }
  547. }, 'open with tweetmeme');
  548. key.setViewKey(['t', 'w'], function (ev, arg) {
  549. ext.exec("twitter-client-tweet", arg, ev);
  550. }, 'つぶやく', true);
  551. key.setViewKey(['t', 'p'], function (ev, arg) {
  552. ext.exec("twitter-client-tweet-this-page", arg, ev);
  553. }, 'このページのタイトルと URL を使ってつぶやく', true);
  554. key.setViewKey('u', function () {
  555. undoCloseTab();
  556. }, '閉じたタブを元に戻す');
  557. key.setViewKey('g', function () {
  558. goDoCommand("cmd_scrollTop");
  559. }, 'ページ先頭へ移動');
  560. key.setViewKey('G', function () {
  561. goDoCommand("cmd_scrollBottom");
  562. }, 'ページ末尾へ移動');
  563. key.setViewKey('r', function (aEvent) {
  564. BrowserReload();
  565. }, '再読み込み');
  566. key.setViewKey('m', function (ev, arg) {
  567. _fi.toogle();
  568. }, 'fetchimiをトグル');
  569. key.setViewKey('d', function (ev, arg) {
  570. if (window.loadURI) {
  571. 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()}})()");
  572. }
  573. }, 'deliciousでブックマーク');
  574. key.setViewKey('p', function (ev, arg) {
  575. if (window.loadURI) {
  576. 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{}");
  577. }
  578. }, 'posterousに投稿');
  579. key.setViewKey('SPC', function (ev, arg) {
  580. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  581. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  582. }, 'タブの選択をトグルして次のタブ');
  583. key.setViewKey('S-SPC', function (ev, arg) {
  584. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  585. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  586. }, 'タブの選択をトグルして前のタブ');
  587. key.setViewKey('z', function (ev, arg) {
  588. ext.exec("keysnail-setting-menu", arg, ev);
  589. }, 'open keysnail setting menu', true);
  590. key.setViewKey('T', function (ev, arg) {
  591. ext.exec("google-itranslate", arg, ev);
  592. }, 'google itranslate', true);
  593. key.setViewKey('C-SPC', function (ev, arg) {
  594. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  595. }, 'タブの選択をトグル');
  596. key.setViewKey('s', function (ev, arg) {
  597. var n = gBrowser.mCurrentTab._tPos;
  598. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  599. if (n != 0) {
  600. gBrowser.selectedTab = gBrowser.mTabs[n];
  601. }
  602. }, 'このタブを保持する');
  603. key.setViewKey('U', function (ev, arg) {
  604. ext.exec("list-closed-tabs", arg, ev);
  605. }, 'List closed tabs', true);
  606. key.setViewKey('e', function () {
  607. command.focusElement(command.elementsRetrieverTextarea, 0);
  608. }, '最初のインプットエリアへフォーカス', true);
  609. key.setViewKey('S', function (ev, arg) {
  610. if (window.loadURI) {
  611. 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{}");
  612. }
  613. }, 'google reader share');
  614. key.setViewKey('!', function (ev, arg) {
  615. shell.input();
  616. }, 'Command system');
  617. key.setViewKey('b', function (ev, arg) {
  618. BarTap.putOnTap(gBrowser.mCurrentTab, gBrowser);
  619. }, 'bartab put on tab');
  620. key.setViewKey('R', function () {
  621. BrowserReloadSkipCache();
  622. }, '更新(キャッシュを無視)');
  623. key.setViewKey('<backspace>', function () {
  624. BrowserBack();
  625. }, '戻る');
  626. key.setViewKey('S-<backspace>', function () {
  627. BrowserForward();
  628. }, '進む');
  629. key.setViewKey('q', function (ev, arg) {
  630. ext.exec("query-then-engine", arg, ev);
  631. }, 'enter search word and then select engine', true);
  632. key.setViewKey('D', function (ev, arg) {
  633. ext.exec("dig-url", arg, ev);
  634. }, 'keysnail diggler ', true);
  635. key.setViewKey('/', function () {
  636. command.iSearchForward();
  637. }, 'インクリメンタル検索', true);
  638. key.setViewKey('?', function (ev) {
  639. command.iSearchForwardKs(ev);
  640. }, 'Emacs ライクなインクリメンタル検索', true);
  641. key.setViewKey('a', function (ev, arg) {
  642. allTabs.open();
  643. }, 'alltabs.open');
  644. key.setViewKey('C', function (ev, arg) {
  645. ext.exec("copy-url", arg, ev);
  646. }, '選択タブと現在のタブを閉じる', true);
  647. key.setViewKey('I', function (ev, arg) {
  648. ext.exec("instapaper-add-this-page-and-close", arg, ev);
  649. }, 'instapaper add page', true);
  650. key.setViewKey('<left>', function (ev) {
  651. goDoCommand("cmd_scrollPageUp");
  652. }, '一画面分スクロールアップ');
  653. key.setViewKey('<right>', function (ev) {
  654. goDoCommand("cmd_scrollPageDown");
  655. }, '一画面スクロールダウン');
  656. key.setViewKey('C-w', function (ev) {
  657. command.copyRegion(ev);
  658. }, '選択中のテキストをコピー');
  659. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  660. return;
  661. }, 'ignore');
  662. key.setViewKey(':', function (ev, arg) {
  663. return !document.getElementById("keysnail-prompt").hidden &&
  664. document.getElementById("keysnail-prompt-textbox").focus();
  665. }, 'KeySnail のプロンプトへフォーカス', true);
  666. key.setViewKey('H', function (ev, arg) {
  667. ext.exec("open-hatebu-comment", arg, ev);
  668. }, 'hatebu', true);
  669. key.setEditKey('C-<tab>', function (ev) {
  670. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  671. }, '次のテキストエリアへフォーカス');
  672. key.setViewKey('l', function (ev) {
  673. command.focusToById("urlbar");
  674. }, 'ロケーションバーへフォーカス', true);