Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

_keysnail.js 29 KiB

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