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