You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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