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.

пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 12 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 12 година
пре 13 година
пре 12 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 12 година
пре 12 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 12 година
пре 13 година
пре 12 година
пре 13 година
пре 12 година
пре 12 година
пре 12 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 12 година
пре 13 година
пре 13 година
пре 13 година
пре 12 година
пре 13 година
пре 13 година
пре 13 година
пре 12 година
пре 12 година
пре 13 година
пре 12 година
пре 12 година
пре 12 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. // ========================== KeySnail Init File =========================== //
  2. // この領域は, GUI により設定ファイルを生成した際にも引き継がれます
  3. // 特殊キー, キーバインド定義, フック, ブラックリスト以外のコードは, この中に書くようにして下さい
  4. // ========================================================================= //
  5. //{{%PRESERVE%
  6. // prompt.rows = 12;
  7. // prompt.useMigemo = false;
  8. // prompt.migemoMinWordLength = 2;
  9. // prompt.displayDelayTime = 300;
  10. // command.kill.killRingMax = 15;
  11. // command.kill.textLengthMax = 8192;
  12. //////////////////////////////////////
  13. //// sitelocalkeymap
  14. var local = {};
  15. plugins.options["site_local_keymap.local_keymap"] = local;
  16. function fake(k, i) function () { key.feed(k, i); };
  17. function pass(k, i) [k, fake(k, i)];
  18. function ignore(k, i) [k, null];
  19. // ext.add("ext-name", function () {}, "ext description");
  20. // style.register("");
  21. // local["^http://"] = [['a', function(ev, arg){}],];
  22. ///////////////////////////////////////////
  23. //// firefox
  24. // style.register("#bookmarksPanel > hbox,#history-panel > hbox {display: none !important;} //#urlbar-container{max-width: 500px !important;}");
  25. util.setPrefs(
  26. {
  27. "browser.tabs.loadDivertedInBackground": true,
  28. "dom.disable_window_open_feature.location": false,
  29. "dom.max_script_run_time": 30,
  30. "browser.bookmarks.max_backups":0,
  31. "browser.urlbar.autocomplete.enabled":false,
  32. "browser.cache.memory.capacity":16384,
  33. "browser.sessionhistory.max_total_viewers":8,
  34. "browser.download.manager.closeWhenDone":true,
  35. "browser.download.useDownloadDir":false,
  36. "browser.tabs.closeWindowWithLastTab":false,
  37. "network.dns.disableIPv6":true,
  38. "browser.urlbar.trimURLs":false,
  39. "browser.fullscreen.autohide":false,
  40. "keyword.URL":"http://www.bing.com/search?q=",
  41. }
  42. );
  43. ///////////////////////////////////
  44. //検索エンジン
  45. plugins.options["search-url-list"] = [
  46. ["bing","http://bing.com/search?q=%q"],
  47. ["yatwitter search","http://yats-data.com/yats/search?query=%q"],
  48. ["twitter search","http://search.twitter.com/search?q=%q&lang=all"],
  49. ["tospy", "http://topsy.com/s?allow_lang=ja&q=%q"],
  50. ["2ch","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  51. ["I\'m feelig lucky!","http://www.google.co.jp/search?q=%q&btnI=kudos"],
  52. ["uncyclopedia","http://ja.uncyclopedia.info/wiki/%q"],
  53. ["wikipedia","http://ja.wikipedia.org/wiki/%q"],
  54. ["nicovideo.jp","http://www.nicovideo.jp/search/%q"],
  55. ["alc","http://eow.alc.co.jp/%q/UTF-8/"],
  56. ["google map","http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  57. ["weblio","http://www.weblio.jp/content_find?query=%q"],
  58. ["shoutcast","http://www.shoutcast.com/Internet-Radio/%q"],
  59. ["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"],
  60. ["delicious 10sr","http://delicious.com/10sr?addtag=%q&setcount=50&opennew=1"],
  61. ["open raw","%r"],
  62. ];
  63. plugins.options["my-keysnail-bookmarks"] = [
  64. "twitter.com",
  65. ];
  66. // sitelocal
  67. //////////////////////////////////////////
  68. // 2ch chaika
  69. local["^http://127.0.0.1:8823/thread/"] = [
  70. ['k', function (ev, arg) {
  71. curl = window.content.location.href;
  72. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  73. window.content.location.href = kurl;
  74. }
  75. ],
  76. ];
  77. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  78. ['k', function (ev, arg) {
  79. var url = window.content.location.href;
  80. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  81. var result = url.match(pt);
  82. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/", result[1], result[2], result[3]);
  83. window.content.location.href = k;
  84. }
  85. ],
  86. ];
  87. /////////////////////////////////////////
  88. // feedly用マップ
  89. local["^http://www.feedly.com/"] = [
  90. ['d', null],
  91. ['j', null],
  92. ['k', null],
  93. ['n', null],
  94. ['p', null],
  95. ['o', null],
  96. ['b', null],
  97. ['S', null],
  98. ['s', null],
  99. ['?', null],
  100. ['r', null],
  101. ['g', null],
  102. // ['x', function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("g", true));}],
  103. ['l', function (ev, arg) {window.content.location.href = "http://www.feedly.com/home#latest";}],
  104. [['t', 'p'], function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("t", true));}],
  105. [['t', 'w'], function (ev, arg) {ext.exec("twitter-client-tweet", arg, ev);}],
  106. ];
  107. /////////////////////////////////////////
  108. //nicovideo用
  109. local["http://(www|tw|es|de|)\.nicovideo\.jp\/(watch|playlist)/*"] = [
  110. ["i", function (ev, arg) { ext.exec("nicoinfo", arg); }],
  111. ["p", function (ev, arg) { ext.exec("nicopause", arg); }],
  112. ["o", function (ev, arg) { ext.exec("nicommentvisible", arg); }],
  113. ["m", function (ev, arg) { ext.exec("nicomute", arg); }],
  114. [".", function (ev, arg) { ext.exec("nicovolumeIncrement", arg); }],
  115. [",", function (ev, arg) { ext.exec("nicovolumeDecrement", arg); }],
  116. ['f', function (ev, arg) {
  117. curl = window.content.location.href;
  118. kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  119. window.content.location.href = kurl;
  120. }
  121. ],
  122. ];
  123. /////////////////////////////////////////
  124. // tumblr/dashboard
  125. local["^http://www.tumblr.com/dashboard"] = [
  126. // ["C-<left>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(-1, true); }],
  127. // ["C-<right>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(1, true); }],
  128. ["<left>", function (ev, arg) { window.content.location.href = "http://www.tumblr.com/dashboard"; }],
  129. // ["<right>", null],
  130. ["J", function (ev, arg) {
  131. if (window.loadURI) {
  132. loadURI("javascript:(function(){b=20;s=100;t=document.getElementById('next_page_link').href.split('/')[5];max=t.substr(0,t.length-5);min=max-s;i=Math.floor(Math.random()*(max-min)+min);u=(i<b)?'http://www.tumblr.com/dashboard':'http://www.tumblr.com/dashboard/2/'+i+'00000';window.content.location.href=u;}())");
  133. }
  134. }],
  135. ];
  136. ///////////////////////////////////////////
  137. // plugin option
  138. plugins.options["instapaper.close_after_post"] = true;
  139. //////////////////////////////////////////
  140. // yatc
  141. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  142. plugins.options["twitter_client.popup_new_statuses"] = false;
  143. plugins.options["twitter_client.automatically_begin"] = false;
  144. plugins.options["twitter_client.automatically_begin_list"] = false;
  145. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  146. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  147. plugins.options["twitter_client.tweet_keymap"] = {
  148. "C-RET" : "prompt-decide",
  149. "RET" : ""
  150. };
  151. plugins.options["twitter_client.jmp_id"] = "10sr";
  152. plugins.options["twitter_client.jmp_key"] = "R_c51f889a77cb4b4e993ed868f65083f5";
  153. plugins.options["twitter_client.use_jmp"] = true;
  154. ////////////////////////////////////////////
  155. // エクステ
  156. ext.add('auto-install-plugins', function(ev, arg){
  157. var urls = [
  158. 'https://github.com/mooz/keysnail/raw/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  159. 'https://github.com/mooz/keysnail/raw/master/plugins/site-local-keymap.ks.js',
  160. 'https://github.com/azu/KeySnail-Plugins/raw/master/JSReference/js-referrence.ks.js',
  161. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  162. 'https://github.com/tkosaka/keysnail-plugin/raw/master/nicontroller.ks.js',
  163. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  164. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  165. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  166. ];
  167. function inst(a){
  168. if(a.length == 0){
  169. display.showPopup("auto-install-plugins", "All installation finished.");
  170. }else{
  171. var url = a.shift();
  172. var path = userscript.pluginDir + userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  173. if(plugins.context[path] === undefined){
  174. userscript.installPluginFromURL(url, function(){inst(a);});
  175. }else{
  176. inst(a);
  177. }
  178. }
  179. }
  180. inst(urls);
  181. }, 'Install plugins automatically if not installed yet.');
  182. ext.add('put-aside-this-page', function (ev, arg) {
  183. var n = gBrowser.mCurrentTab._tPos;
  184. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  185. if (n != 0) {
  186. gBrowser.selectedTab = gBrowser.mTabs[n];
  187. }
  188. }, 'put aside this page');
  189. ext.add('send-escape', function (ev, arg) {
  190. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  191. }, 'escape');
  192. ext.add("open-hatebu-comment", function (ev, arg) {
  193. if (window.loadURI) {
  194. loadURI("javascript:location.href='http://b.hatena.ne.jp/entry?mode=more&url='+escape(location.href);");
  195. }
  196. }, 'hatebu');
  197. ext.add("fullscreen-page",function (ev) {
  198. getBrowser().selectedTab = getBrowser().addTab("http://home.tiscali.nl/annejan/swf/timeline.swf");
  199. BrowserFullScreen();
  200. }, "fullscreen page");
  201. ext.add("focus-on-content", function(){
  202. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  203. gBrowser.focus();
  204. content.focus();
  205. }, "forcus on content");
  206. ext.add("hide-sidebar", function(){
  207. var sidebarBox = document.getElementById("sidebar-box");
  208. if (!sidebarBox.hidden) {
  209. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  210. }
  211. }, "hide-sidebar");
  212. ext.add("close-and-next-tab", function (ev, arg) {
  213. var n = gBrowser.mCurrentTab._tPos;
  214. BrowserCloseTabOrWindow();
  215. gBrowser.selectedTab = gBrowser.mTabs[n];
  216. }, "close and focus to next tab");
  217. /////////////////////////////////////
  218. // google itranslate
  219. (function(){
  220. let targetLang = "ja"; // target lang to translate into
  221. let alternativeLang = "en"; // if given word is in targetLang, use this instead as a target lang
  222. function translate(word, target, next) {
  223. next("", "", " getting...");
  224. const base = "https://www.googleapis.com/language/translate/v2?key=%s&q=%s&target=%s";
  225. const apikey = "AIzaSyBq48p8NhFgaJ1DfUJ5ltbwLxeXpjEL86A";
  226. let ep = util.format(base, apikey, encodeURIComponent(word), target);
  227. util.httpGet(ep, false, function (res) {
  228. if (res.status === 200) {
  229. let json = decodeJSON(res.responseText);
  230. let srclang = json.data.translations[0].detectedSourceLanguage;
  231. if (target == srclang) {
  232. lookupword(word, alternativeLang);
  233. } else {
  234. let result = json.data.translations[0].translatedText;
  235. next(srclang, target, result);
  236. }
  237. } else {
  238. next("", "", "ERROR!");
  239. }
  240. });
  241. };
  242. function echo(srclang, from, tglang, to){
  243. display.echoStatusBar(srclang + " : " + from + " -> " + tglang + " : " + to);
  244. };
  245. function decodeJSON(json) {
  246. return util.safeEval("(" + json + ")");
  247. };
  248. function lookupword(word, target){
  249. translate(word, target, function (src, tg, translated) {
  250. echo(src, word, tg, translated);
  251. });
  252. };
  253. function read (aInitialInput) {
  254. let prevText = "";
  255. prompt.reader({
  256. message : "word or sentence to translate:",
  257. initialinput : aInitialInput,
  258. onChange: function (arg) {
  259. let word = arg.textbox.value;
  260. if (word !== prevText) {
  261. prevText = word;
  262. lookupword(word, targetLang);
  263. }
  264. },
  265. callback: function (s){},
  266. });
  267. };
  268. ext.add("google-itranslate",function(){read(content.document.getSelection() || "");},"google itranslate");
  269. })();
  270. //////////////////////////////////////
  271. //
  272. ext.add("restart-firefox-add-menu", function(){
  273. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  274. var cmdelm = document.createElementNS(XUL_NS, "command");
  275. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs")
  276. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  277. var commandset = document.getElementById("mainCommandSet");
  278. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  279. commandset.appendChild(cmdelm);
  280. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  281. menuelm.setAttribute("label", "Restart Firefox");
  282. menuelm.setAttribute("id", "my_menu_restartFirefoxKs")
  283. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  284. var menu = document.getElementById("menu_FilePopup");
  285. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  286. menu.appendChild(menuelm);
  287. }, "add restart firefox menu");
  288. //////////////////////////////////////
  289. // restart firefox
  290. // http://keysnail.g.hatena.ne.jp/Shinnya/20100723/1279878815
  291. ext.add("restart-firefox",function (ev) {
  292. const nsIAppStartup = Components.interfaces.nsIAppStartup;
  293. // Notify all windows that an application quit has been requested.
  294. var os = Components.classes["@mozilla.org/observer-service;1"]
  295. .getService(Components.interfaces.nsIObserverService);
  296. var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
  297. .createInstance(Components.interfaces.nsISupportsPRBool);
  298. os.notifyObservers(cancelQuit, "quit-application-requested", null);
  299. // Something aborted the quit process.
  300. if (cancelQuit.data)
  301. return;
  302. // Notify all windows that an application quit has been granted.
  303. os.notifyObservers(null, "quit-application-granted", null);
  304. // Enumerate all windows and call shutdown handlers
  305. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  306. .getService(Components.interfaces.nsIWindowMediator);
  307. var windows = wm.getEnumerator(null);
  308. while (windows.hasMoreElements()) {
  309. var win = windows.getNext();
  310. if (("tryToClose" in win) && !win.tryToClose())
  311. return;
  312. }
  313. Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
  314. .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
  315. }, "restart firefox");
  316. /////////////////////////////////////////
  317. // copy feed url
  318. ext.add("copy-url", function () {
  319. const doc = content.document;
  320. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  321. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  322. 'link[type="application/atom+xml"]'])))];
  323. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  324. for (i = 0; i < feeds.length; i++)
  325. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  326. feeds.unshift([window.content.document.title,window.content.location.href]);
  327. prompt.selector(
  328. {
  329. message : "Select Feed",
  330. collection : feeds,
  331. callback : function (i) {
  332. if (i >= 0)
  333. command.setClipboardText(feeds[i][1]);
  334. }
  335. }
  336. );
  337. }, "Copy url or feed url of current page");
  338. ///////////////////////////////////////
  339. // 評価しちゃうっぽい とりあえずこんな感じで
  340. ext.add("keysnail-setting-menu",function(){
  341. var settingmenulist = [["keysnail setting dialogue", function(){return function(){KeySnail.openPreference();};}],
  342. ["keysnail plugin manager", function(){return function(){userscript.openPluginManager();}}],
  343. ["firefox addon manager", function(){return function(){BrowserOpenAddonsMgr();};}],
  344. ["reload .keysnail.js", function(){return function() {userscript.reload();};}],
  345. // ["check for plugins update", function(){return function(){ext.exec("check-for-plugins-update");};}],
  346. ["restart firefox", function(){return function(){ext.exec("restart-firefox");};}],
  347. ];
  348. prompt.selector(
  349. {
  350. message : "open setting dialog",
  351. collection : settingmenulist,
  352. callback : function (i) { settingmenulist[i][1]()(); },
  353. });
  354. },"open keysnail setting menu");
  355. ////////////////////////
  356. //マルチプルタブハンドラ
  357. ext.add("multiple-tab-handler-close-selected-and-current-tabs", function () {
  358. BrowserCloseTabOrWindow();
  359. // if (MultipleTabService) {
  360. // //BrowserCloseTabOrWindow();
  361. // //MultipleTabService.setSelection(gBrowser.mCurrentTab, true);
  362. MultipleTabService.closeTabs(MultipleTabService.getSelectedTabs());
  363. // } else {
  364. // BrowserCloseTabOrWindow();}
  365. }, '選択タブと現在のタブを閉じる');
  366. ext.add("if-mth-exist", function() {
  367. if (MultipleTabService === undefined) display.echoStatusBar("mth not exist.");
  368. },'if mth exist');
  369. // search web
  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);
  641. key.setViewKey('C-<backspace>', function (ev, arg) {
  642. ext.exec('list-tab-history', arg, ev);
  643. }, 'List tab history', true);