您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

731 行
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. ///////////////////////////////////
  26. //search engine
  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 keymap
  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. // my ext
  142. ext.add('view-page-source', function(){
  143. window.content.location.href = "view-source:" + window.content.location.href;
  144. }, 'view page source');
  145. ext.add('my-setpref', function(){
  146. util.setPrefs(
  147. {
  148. "browser.bookmarks.max_backups":0,
  149. "browser.cache.memory.capacity":16384,
  150. "browser.download.manager.closeWhenDone":true,
  151. "browser.download.useDownloadDir":false,
  152. "browser.fullscreen.autohide":false,
  153. "browser.search.openintab":true,
  154. "browser.sessionhistory.max_total_viewers":8,
  155. "browser.sessionstore.restore_on_demand":true,
  156. "browser.tabs.closeWindowWithLastTab":false,
  157. "browser.tabs.loadDivertedInBackground": true,
  158. "browser.urlbar.autocomplete.enabled":false,
  159. "browser.urlbar.trimURLs":false,
  160. "dom.disable_window_open_feature.location": false,
  161. "dom.max_script_run_time": 30,
  162. "extensions.chaika.bbsmenu.open_new_tab":true,
  163. "extensions.chaika.bbsmenu.open_single_click":false,
  164. "extensions.chaika.board.open_new_tab":true,
  165. "extensions.chaika.board.open_single_click":false,
  166. "extensions.foxage2ch.openThreadInTab":true,
  167. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  168. "extensions.saveimageinfolder.general-fileprefixvalue":"%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  169. "extensions.saveimageinfolder.usecache":true,
  170. "extensions.tabutils.openTabNext":1,
  171. "extensions.tabutils.styles.current":"{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  172. "extensions.tabutils.styles.unread":"{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}",
  173. "extensions.yass.edgetype":0,
  174. "extensions.yass.selectedpreset":"red",
  175. "font.default.x-western":"sans-serif",
  176. "general.warnOnAboutConfig":false,
  177. "keyword.URL":"http://www.bing.com/search?q=",
  178. "network.dns.disableIPv6":true,
  179. "refcontrol.actions":"@DEFAULT=@FORGE",
  180. "scrapbook.tabs.open":true
  181. }
  182. );
  183. if(/^Linux/.test(navigator.platform)){
  184. util.setPrefs(
  185. {
  186. "browser.cache.disk.parent_directory":"/tmp",
  187. "browser.cache.disk.capacity":524288
  188. }
  189. );
  190. }
  191. display.showPopup("Keysnail", "My prefs done.");
  192. }, 'my setpref');
  193. ext.add('auto-install-plugins', function(ev, arg){
  194. var urls = [
  195. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  196. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  197. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  198. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  199. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  200. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  201. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  202. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  203. 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js',
  204. 'https://raw.github.com/gist/1450594/mstranslator.ks.js'
  205. ];
  206. function inst(a){
  207. if(a.length == 0){
  208. display.showPopup("auto-install-plugins", "All installation finished.");
  209. }else{
  210. var url = a.shift();
  211. var path = userscript.pluginDir + userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  212. if(plugins.context[path] === undefined){
  213. userscript.installPluginFromURL(url, function(){inst(a);});
  214. }else{
  215. inst(a);
  216. }
  217. }
  218. }
  219. inst(urls);
  220. }, 'Install plugins automatically if not installed yet.');
  221. ext.add('put-aside-this-page', function (ev, arg) {
  222. var n = gBrowser.mCurrentTab._tPos;
  223. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  224. if (n != 0) {
  225. gBrowser.selectedTab = gBrowser.mTabs[n];
  226. }
  227. }, 'put aside this page');
  228. ext.add('send-escape', function (ev, arg) {
  229. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  230. }, 'escape');
  231. ext.add("open-hatebu-comment", function (ev, arg) {
  232. if (window.loadURI) {
  233. loadURI("javascript:location.href='http://b.hatena.ne.jp/entry?mode=more&url='+escape(location.href);");
  234. }
  235. }, 'hatebu');
  236. ext.add("fullscreen-page",function (ev) {
  237. getBrowser().selectedTab = getBrowser().addTab("http://home.tiscali.nl/annejan/swf/timeline.swf");
  238. BrowserFullScreen();
  239. }, "fullscreen page");
  240. ext.add("focus-on-content", function(){
  241. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  242. gBrowser.focus();
  243. content.focus();
  244. }, "forcus on content");
  245. ext.add("hide-sidebar", function(){
  246. var sidebarBox = document.getElementById("sidebar-box");
  247. if (!sidebarBox.hidden) {
  248. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  249. }
  250. }, "hide-sidebar");
  251. ext.add("close-and-next-tab", function (ev, arg) {
  252. var n = gBrowser.mCurrentTab._tPos;
  253. BrowserCloseTabOrWindow();
  254. gBrowser.selectedTab = gBrowser.mTabs[n];
  255. }, "close and focus to next tab");
  256. //////////////////////////////////////
  257. //
  258. ext.add("restart-firefox-add-menu", function(){
  259. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  260. var cmdelm = document.createElementNS(XUL_NS, "command");
  261. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs")
  262. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  263. var commandset = document.getElementById("mainCommandSet");
  264. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  265. commandset.appendChild(cmdelm);
  266. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  267. menuelm.setAttribute("label", "Restart Firefox");
  268. menuelm.setAttribute("id", "my_menu_restartFirefoxKs")
  269. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  270. var menu = document.getElementById("menu_FilePopup");
  271. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  272. menu.appendChild(menuelm);
  273. }, "add restart firefox menu");
  274. //////////////////////////////////////
  275. // restart firefox
  276. // http://keysnail.g.hatena.ne.jp/Shinnya/20100723/1279878815
  277. ext.add("restart-firefox",function (ev) {
  278. const nsIAppStartup = Components.interfaces.nsIAppStartup;
  279. // Notify all windows that an application quit has been requested.
  280. var os = Components.classes["@mozilla.org/observer-service;1"]
  281. .getService(Components.interfaces.nsIObserverService);
  282. var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
  283. .createInstance(Components.interfaces.nsISupportsPRBool);
  284. os.notifyObservers(cancelQuit, "quit-application-requested", null);
  285. // Something aborted the quit process.
  286. if (cancelQuit.data)
  287. return;
  288. // Notify all windows that an application quit has been granted.
  289. os.notifyObservers(null, "quit-application-granted", null);
  290. // Enumerate all windows and call shutdown handlers
  291. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  292. .getService(Components.interfaces.nsIWindowMediator);
  293. var windows = wm.getEnumerator(null);
  294. while (windows.hasMoreElements()) {
  295. var win = windows.getNext();
  296. if (("tryToClose" in win) && !win.tryToClose())
  297. return;
  298. }
  299. Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
  300. .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
  301. }, "restart firefox");
  302. /////////////////////////////////////////
  303. // copy feed url
  304. ext.add("copy-url", function () {
  305. const doc = content.document;
  306. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  307. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  308. 'link[type="application/atom+xml"]'])))];
  309. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  310. for (i = 0; i < feeds.length; i++)
  311. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  312. feeds.unshift([window.content.document.title,window.content.location.href]);
  313. prompt.selector(
  314. {
  315. message : "Select Feed",
  316. collection : feeds,
  317. callback : function (i) {
  318. if (i >= 0)
  319. command.setClipboardText(feeds[i][1]);
  320. }
  321. }
  322. );
  323. }, "Copy url or feed url of current page");
  324. ///////////////////////////////////////
  325. // keysnail z menu
  326. ext.add("keysnail-setting-menu",function(){
  327. var settingmenulist = [["keysnail setting dialogue", function(){return function(){KeySnail.openPreference();};}],
  328. ["keysnail plugin manager", function(){return function(){userscript.openPluginManager();};}],
  329. ["firefox addon manager", function(){return function(){BrowserOpenAddonsMgr();};}],
  330. ["reload .keysnail.js", function(){return function() {userscript.reload();};}],
  331. // ["check for plugins update", function(){return function(){ext.exec("check-for-plugins-update");};}],
  332. ["restart firefox", function(){return function(){ext.exec("restart-firefox");};}]
  333. ];
  334. prompt.selector(
  335. {
  336. message : "open setting dialog",
  337. collection : settingmenulist,
  338. callback : function (i) { settingmenulist[i][1]()(); }
  339. });
  340. },"open keysnail setting menu");
  341. ////////////////////////
  342. // multiple tab handler
  343. ext.add("multiple-tab-handler-close-selected-and-current-tabs", function () {
  344. BrowserCloseTabOrWindow();
  345. // if (MultipleTabService) {
  346. // //BrowserCloseTabOrWindow();
  347. // //MultipleTabService.setSelection(gBrowser.mCurrentTab, true);
  348. MultipleTabService.closeTabs(MultipleTabService.getSelectedTabs());
  349. // } else {
  350. // BrowserCloseTabOrWindow();}
  351. }, '選択タブと現在のタブを閉じる');
  352. ext.add("if-mth-exist", function() {
  353. if (MultipleTabService === undefined) display.echoStatusBar("mth not exist.");
  354. },'if mth exist');
  355. // search web
  356. ext.add("query-then-engine", function () {
  357. prompt.reader({message : "Search Word?:",
  358. callback : function (q) {
  359. if (q) {
  360. prompt.selector({ message : "search \"" + q + "\" with?",
  361. collection : plugins.options["search-url-list"],
  362. width : [20,80],
  363. callback : function (i) { getBrowser().selectedTab = getBrowser().addTab(plugins.options["search-url-list"][i][1].replace("%r",q).replace("%q",encodeURIComponent(q))); },
  364. });
  365. };
  366. },
  367. initialInput : content.document.getSelection() || "",
  368. });
  369. }, "enter search word and then select engine");
  370. /////////////////////////////////////
  371. // closed tab list
  372. ext.add("list-closed-tabs", function () {
  373. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  374. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  375. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  376. var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  377. if (!closedTabs.length)
  378. return void display.echoStatusBar("最近閉じたタブが見つかりませんでした", 2000);
  379. prompt.selector(
  380. {
  381. message : "select tab to undo:",
  382. collection : closedTabs,
  383. flags : [ICON | IGNORE, 0, 0],
  384. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  385. });
  386. }, "List closed tabs");
  387. ext.add("echo-closed-tabs", function () {
  388. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  389. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  390. // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  391. var lasttab = json.decode(ss.getClosedTabData(window))[0];
  392. dump = ""
  393. for (var i in lasttab) { dump += lasttab[i] + "\n"; }
  394. confirm(dump);
  395. }, "List closed tabs");
  396. ///////////////////////////////
  397. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  398. ext.add("list-tab-history", function () {
  399. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  400. var tabHistory = [];
  401. var sessionHistory = gBrowser.webNavigation.sessionHistory;
  402. if (sessionHistory.count < 1)
  403. return void display.echoStatusBar("Tab history not exist", 2000);
  404. var curIdx = sessionHistory.index;
  405. for (var i = 0; i < sessionHistory.count; i++) {
  406. var entry = sessionHistory.getEntryAtIndex(i, false);
  407. if (!entry)
  408. continue;
  409. try {
  410. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  411. .getService(Ci.nsIFaviconService)
  412. .getFaviconForPage(entry.URI).spec;
  413. } catch (ex) {}
  414. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  415. }
  416. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  417. if (tabHistory[thIdx][3] == curIdx) break;
  418. }
  419. prompt.selector(
  420. {
  421. message : "select history in tab",
  422. collection : tabHistory,
  423. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  424. header : ["Title", "URL"],
  425. initialIndex : thIdx,
  426. callback : function(i) { if (i >= 0) gBrowser.webNavigation.gotoIndex(tabHistory[i][3]); }
  427. });
  428. }, 'List tab history');
  429. //}}%PRESERVE%
  430. // ========================================================================= //
  431. // ========================= Special key settings ========================== //
  432. key.quitKey = "<delete>";
  433. key.helpKey = "<f1>";
  434. key.escapeKey = "C-q";
  435. key.macroStartKey = "";
  436. key.macroEndKey = "";
  437. key.universalArgumentKey = "C-u";
  438. key.negativeArgument1Key = "C--";
  439. key.negativeArgument2Key = "C-M--";
  440. key.negativeArgument3Key = "M--";
  441. key.suspendKey = "Not defined";
  442. // ================================= Hooks ================================= //
  443. hook.setHook('KeySnailInitialized', function () {
  444. ext.exec("shiitake-enable-style");
  445. });
  446. hook.setHook('KeyBoardQuit', function (aEvent) {
  447. ext.exec("hide-sidebar");
  448. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  449. gBrowser.focus();
  450. content.focus();
  451. command.closeFindBar();
  452. if (util.isCaretEnabled()) {
  453. command.resetMark(aEvent);
  454. } else {
  455. goDoCommand("cmd_selectNone");
  456. }
  457. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  458. });
  459. hook.setHook('Unload', function () {
  460. util.getBrowserWindows().some(function (win) {
  461. if (win === window) {
  462. return false;
  463. }
  464. const ks = win.KeySnail;
  465. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  466. ks.setUpPluginUpdaterDelegator();
  467. return true;
  468. });
  469. });
  470. // ============================= Key bindings ============================== //
  471. key.setGlobalKey('C-<right>', function () {
  472. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  473. }, 'ひとつ右のタブへ');
  474. key.setGlobalKey('C-<left>', function () {
  475. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  476. }, 'ひとつ左のタブへ');
  477. key.setGlobalKey('C-<up>', function () {
  478. var browser = getBrowser();
  479. if (browser.mCurrentTab.previousSibling) {
  480. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  481. } else {
  482. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  483. }
  484. }, '選択中のタブを右へ');
  485. key.setGlobalKey('C-<down>', function () {
  486. var browser = getBrowser();
  487. if (browser.mCurrentTab.nextSibling) {
  488. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  489. } else {
  490. browser.moveTabTo(browser.mCurrentTab, 0);
  491. }
  492. }, '選択中のタブを左へ');
  493. key.setGlobalKey('M-:', function (ev) {
  494. command.interpreter();
  495. }, 'JavaScript のコードを評価');
  496. key.setGlobalKey('C-h', function (ev, arg) {
  497. return;
  498. }, 'ignore');
  499. key.setViewKey('D', function (ev, arg) {
  500. ext.exec("dig-url", arg, ev);
  501. }, 'dig url with selector', true);
  502. key.setViewKey('x', function (aEvent, aArg) {
  503. ext.select(aArg, aEvent);
  504. }, 'エクステ一覧');
  505. key.setViewKey(['t', 'm'], function (ev, arg) {
  506. if (window.loadURI) {
  507. loadURI("javascript:window.location='http://api.tweetmeme.com/visit?url='+window.location;");
  508. }
  509. }, 'open with tweetmeme');
  510. key.setViewKey(['t', 'w'], function (ev, arg) {
  511. ext.exec("twitter-client-tweet", arg, ev);
  512. }, 'つぶやく', true);
  513. key.setViewKey(['t', 'p'], function (ev, arg) {
  514. ext.exec("twitter-client-tweet-this-page", arg, ev);
  515. }, 'このページのタイトルと URL を使ってつぶやく', true);
  516. key.setViewKey('u', function () {
  517. undoCloseTab();
  518. }, '閉じたタブを元に戻す');
  519. key.setViewKey('g', function () {
  520. goDoCommand("cmd_scrollTop");
  521. }, 'ページ先頭へ移動');
  522. key.setViewKey('G', function () {
  523. goDoCommand("cmd_scrollBottom");
  524. }, 'ページ末尾へ移動');
  525. key.setViewKey('r', function (aEvent) {
  526. BrowserReload();
  527. }, '再読み込み');
  528. key.setViewKey('m', function (ev, arg) {
  529. _fi.toogle();
  530. }, 'fetchimiをトグル');
  531. key.setViewKey('d', function (ev, arg) {
  532. if (window.loadURI) {
  533. 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()}})()");
  534. }
  535. }, 'deliciousでブックマーク');
  536. key.setViewKey('p', function (ev, arg) {
  537. if (window.loadURI) {
  538. 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{}");
  539. }
  540. }, 'posterousに投稿');
  541. key.setViewKey('SPC', function (ev, arg) {
  542. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  543. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  544. }, 'タブの選択をトグルして次のタブ');
  545. key.setViewKey('S-SPC', function (ev, arg) {
  546. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  547. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  548. }, 'タブの選択をトグルして前のタブ');
  549. key.setViewKey('z', function (ev, arg) {
  550. ext.exec("keysnail-setting-menu", arg, ev);
  551. }, 'open keysnail setting menu', true);
  552. key.setViewKey('C-SPC', function (ev, arg) {
  553. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  554. }, 'タブの選択をトグル');
  555. key.setViewKey('U', function (ev, arg) {
  556. ext.exec("list-closed-tabs", arg, ev);
  557. }, 'List closed tabs', true);
  558. key.setViewKey('e', function () {
  559. command.focusElement(command.elementsRetrieverTextarea, 0);
  560. }, '最初のインプットエリアへフォーカス', true);
  561. key.setViewKey('S', function (ev, arg) {
  562. if (window.loadURI) {
  563. 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{}");
  564. }
  565. }, 'google reader share');
  566. key.setViewKey('!', function (ev, arg) {
  567. shell.input();
  568. }, 'Command system');
  569. key.setViewKey('b', function (ev, arg) {
  570. BarTap.putOnTap(gBrowser.mCurrentTab, gBrowser);
  571. }, 'bartab put on tab');
  572. key.setViewKey('R', function () {
  573. BrowserReloadSkipCache();
  574. }, '更新(キャッシュを無視)');
  575. key.setViewKey('<backspace>', function () {
  576. BrowserBack();
  577. }, '戻る');
  578. key.setViewKey('S-<backspace>', function () {
  579. BrowserForward();
  580. }, '進む');
  581. key.setViewKey('q', function (ev, arg) {
  582. ext.exec("query-then-engine", arg, ev);
  583. }, 'enter search word and then select engine', true);
  584. key.setViewKey('/', function () {
  585. command.iSearchForward();
  586. }, 'インクリメンタル検索', true);
  587. key.setViewKey('?', function (ev) {
  588. command.iSearchForwardKs(ev);
  589. }, 'Emacs ライクなインクリメンタル検索', true);
  590. key.setViewKey('a', function (ev, arg) {
  591. allTabs.open();
  592. }, 'alltabs.open');
  593. key.setViewKey('<left>', function (ev) {
  594. goDoCommand("cmd_scrollPageUp");
  595. }, '一画面分スクロールアップ');
  596. key.setViewKey('<right>', function (ev) {
  597. goDoCommand("cmd_scrollPageDown");
  598. }, '一画面スクロールダウン');
  599. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  600. return;
  601. }, 'ignore');
  602. key.setViewKey([[':'], ['P']], function (ev, arg) {
  603. return !document.getElementById("keysnail-prompt").hidden &&
  604. document.getElementById("keysnail-prompt-textbox").focus();
  605. }, 'KeySnail のプロンプトへフォーカス', true);
  606. key.setViewKey('H', function (ev, arg) {
  607. ext.exec("open-hatebu-comment", arg, ev);
  608. }, 'hatebu', true);
  609. key.setViewKey('l', function (ev) {
  610. command.focusToById("urlbar");
  611. }, 'ロケーションバーへフォーカス', true);
  612. key.setViewKey('0', function (ev) {
  613. BrowserCloseTabOrWindow();
  614. }, 'タブ / ウィンドウを閉じる');
  615. key.setViewKey('C', function (ev, arg) {
  616. ext.exec("linksnail", arg, ev);
  617. }, 'LinkSnail', true);
  618. key.setViewKey('C-<backspace>', function (ev, arg) {
  619. ext.exec("list-tab-history", arg, ev);
  620. }, 'List tab history', true);
  621. key.setViewKey('I', function (ev, arg) {
  622. ext.exec("instapaper-post-page-with-comment", arg, ev);
  623. }, 'post page and comment', true);
  624. key.setViewKey('T', function (ev, arg) {
  625. ext.exec("mstranslator-open-prompt", arg, ev);
  626. }, 'MSTranslator - Open prompt', true);
  627. key.setEditKey('C-<tab>', function (ev) {
  628. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  629. }, '次のテキストエリアへフォーカス');