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.
 
 
 
 
 
 

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