Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

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