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.
 
 
 
 
 
 

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