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

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