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

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