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

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