選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

864 行
32 KiB

  1. // ========================== KeySnail Init File =========================== //
  2. // この領域は, GUI により設定ファイルを生成した際にも引き継がれます
  3. // 特殊キー, キーバインド定義, フック, ブラックリスト以外のコードは, この中に書くようにして下さい
  4. // ========================================================================= //
  5. //{{%PRESERVE%
  6. // prompt.rows = 12;
  7. // prompt.useMigemo = false;
  8. // prompt.migemoMinWordLength = 2;
  9. // prompt.displayDelayTime = 300;
  10. // command.kill.killRingMax = 15;
  11. // command.kill.textLengthMax = 8192;
  12. //////////////////////////////////////
  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. style.register( //not work
  26. <><![CDATA[
  27. input,textarea {
  28. font-family: monospace !important;
  29. }
  30. ]]></>.toString()
  31. );
  32. ///////////////////////////////////
  33. //search engine
  34. plugins.options["search-url-list"] = [
  35. ["bing","http://bing.com/search?q=%q"],
  36. ["yatwitter search","http://yats-data.com/yats/search?query=%q"],
  37. ["twitter search","http://search.twitter.com/search?q=%q&lang=all"],
  38. ["tospy", "http://topsy.com/s?allow_lang=ja&q=%q"],
  39. ["2ch","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  40. ["I\'m feelig lucky!","http://www.google.co.jp/search?q=%q&btnI=kudos"],
  41. ["uncyclopedia","http://ja.uncyclopedia.info/wiki/%q"],
  42. ["wikipedia","http://ja.wikipedia.org/wiki/%q"],
  43. ["nicovideo.jp","http://www.nicovideo.jp/search/%q"],
  44. ["alc","http://eow.alc.co.jp/%q/UTF-8/"],
  45. ["google map","http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  46. ["weblio","http://www.weblio.jp/content_find?query=%q"],
  47. ["shoutcast","http://www.shoutcast.com/Internet-Radio/%q"],
  48. ["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"],
  49. ["delicious 10sr","http://delicious.com/10sr?addtag=%q&setcount=50&opennew=1"],
  50. ["open raw","%r"],
  51. ];
  52. plugins.options["my-keysnail-bookmarks"] = [
  53. "twitter.com"
  54. ];
  55. // sitelocal keymap
  56. //////////////////////////////////////////
  57. // 2ch chaika
  58. // change chaika port every time firefox starts
  59. util.setIntPref("extensions.chaika.server_port.firefox",
  60. 8800 + Math.floor(Math.random() * 30));
  61. local["^http://127.0.0.1:88"] = [
  62. ['k', function (ev, arg) {
  63. curl = window.content.location.href;
  64. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  65. window.content.location.href = kurl;
  66. }
  67. ]
  68. ];
  69. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  70. ['k', function (ev, arg) {
  71. var url = window.content.location.href;
  72. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  73. var result = url.match(pt);
  74. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/", result[1], result[2], result[3]);
  75. window.content.location.href = k;
  76. }
  77. ]
  78. ];
  79. /////////////////////////////////////////
  80. // feedly
  81. local["^http://www.feedly.com/"] = [
  82. ['d', null],
  83. ['j', null],
  84. ['k', null],
  85. ['n', null],
  86. ['p', null],
  87. ['o', null],
  88. ['b', null],
  89. ['S', null],
  90. ['s', null],
  91. ['?', null],
  92. ['r', null],
  93. ['g', null],
  94. // ['x', function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("g", true));}],
  95. ['l', function (ev, arg) {window.content.location.href = "http://www.feedly.com/home#latest";}],
  96. [['t', 'p'], function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("t", true));}],
  97. [['t', 'w'], function (ev, arg) {ext.exec("twitter-client-tweet", arg, ev);}]
  98. ];
  99. /////////////////////////////////////////
  100. //nicovideo
  101. local["http://(www|tw|es|de|)\.nicovideo\.jp\/(watch|playlist)/*"] = [
  102. ["i", function (ev, arg) { ext.exec("nicoinfo", arg); }],
  103. ["p", function (ev, arg) { ext.exec("nicopause", arg); }],
  104. // ["o", function (ev, arg) { ext.exec("nicommentvisible", arg); }],
  105. ["m", function (ev, arg) { ext.exec("nicomute", arg); }],
  106. [".", function (ev, arg) { ext.exec("nicovolumeIncrement", arg); }],
  107. [",", function (ev, arg) { ext.exec("nicovolumeDecrement", arg); }],
  108. ['f', function (ev, arg) {
  109. curl = window.content.location.href;
  110. kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  111. window.content.location.href = kurl;
  112. }
  113. ]
  114. ];
  115. /////////////////////////////////////////
  116. // tumblr/dashboard
  117. local["^http://www.tumblr.com/dashboard"] = [
  118. // ["C-<left>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(-1, true); }],
  119. // ["C-<right>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(1, true); }],
  120. ["<left>", function (ev, arg) { window.content.location.href = "http://www.tumblr.com/dashboard"; }],
  121. ["<right>", null],
  122. ["J", function (ev, arg) {
  123. if (window.loadURI) {
  124. 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;}())");
  125. }
  126. }]
  127. ];
  128. ///////////////////////////////////////////
  129. // plugin option
  130. plugins.options["builtin_commands_ext.ext_list"] = [
  131. "focus-to-prompt",
  132. "open-url-from-clipboard",
  133. "restart-firefox"
  134. ];
  135. plugins.options["instapaper.close_after_post"] = true;
  136. plugins.options["instapaper.initial_comment_function"] = function(){
  137. var now = new Date();
  138. return "[" + now.toString() + "]";
  139. };
  140. //////////////////////////////////////////
  141. // yatc
  142. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  143. plugins.options["twitter_client.popup_new_statuses"] = false;
  144. plugins.options["twitter_client.automatically_begin"] = false;
  145. plugins.options["twitter_client.automatically_begin_list"] = false;
  146. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  147. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  148. plugins.options["twitter_client.tweet_keymap"] = {
  149. "C-RET" : "prompt-decide",
  150. "RET" : ""
  151. };
  152. plugins.options["twitter_client.jmp_id"] = "10sr";
  153. plugins.options["twitter_client.jmp_key"] = "R_c51f889a77cb4b4e993ed868f65083f5";
  154. plugins.options["twitter_client.use_jmp"] = true;
  155. ////////////////////////////////////////////
  156. // my ext
  157. ext.add('post-to-posterous', function (ev, arg) {
  158. if (window.loadURI) {
  159. loadURI("javascript:var%20b=document.body;var%20POSTEROUS___bookmarklet_domain='http://posterous.com';var%20d=new%20Date();var%20e=(new%20Date(d.getFullYear(),d.getMonth(),d.getDate())).getTime();if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='http://posterous.com/javascripts/bookmarklet2.js?'+e);void(b.appendChild(z));}else{}");
  160. }
  161. }, 'post to posterous');
  162. ext.add("echo-tab-info", function(){
  163. var all = gBrowser.tabs.length;
  164. var ix = gBrowser.mCurrentTab._tPos;
  165. var title = window.document.title;
  166. var url = window.content.location.href;
  167. display.echoStatusBar((ix + 1).toString() + " / " +
  168. all.toString() + " : " +
  169. title + " <" +
  170. url + ">");
  171. }, "echo tab info");
  172. ext.add("strong-fullscreen", function(){
  173. var elemids = [
  174. "navigator-toolbox"
  175. ];
  176. BrowserFullScreen();
  177. var isfullscreen = window.fullScreen;
  178. for(var i = 0; i < elemids.length; i++){
  179. var elem = document.getElementById(elemids[i]);
  180. if(elem){
  181. if(isfullscreen){
  182. elem.style.display = "none";
  183. }else{
  184. elem.style.display = null;
  185. }
  186. }
  187. }
  188. var tabs = document.getElementById("verticaltabs-box");
  189. if(tabs){
  190. var pref_key = "extensions.verticaltabs.width";
  191. var pref_key_bak = pref_key + "_bak"
  192. if(isfullscreen){
  193. var width_orig = util.getIntPref(pref_key);
  194. util.setIntPref(pref_key_bak, width_orig);
  195. util.setIntPref(pref_key, 0);
  196. tabs.setAttribute("width", "0");
  197. }else if(parseInt(tabs.getAttribute("width") || "") === 0){
  198. var width_bak = util.getIntPref(pref_key_bak);
  199. util.setIntPref(pref_key, width_bak);
  200. tabs.setAttribute("width", width_bak.toString());
  201. }
  202. }
  203. }, "go fullscreen with hiding toolbar and tabbar");
  204. ext.add("bookmark-delicious", function(){
  205. f= 'http://www.delicious.com/save?url=' + encodeURIComponent(window.content.location.href) +
  206. '&title=' + encodeURIComponent(document.title) +
  207. '&notes=' + encodeURIComponent('' + (window.getSelection ?
  208. window.getSelection() : document.getSelection ?
  209. document.getSelection() : document.selection.createRange().text)) + '&v=6&';
  210. a = function(){
  211. if(! window.open(f + 'noui=1&jump=doclose', 'deliciousuiv6', 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){
  212. location.href = f + 'jump=yes';
  213. }
  214. };
  215. if(/Firefox/.test(navigator.userAgent)){
  216. setTimeout(a,0);
  217. }else{
  218. a();
  219. }
  220. }, "bookmark delicious");
  221. ext.add('view-page-source', function(){
  222. window.content.location.href = "view-source:" + window.content.location.href;
  223. }, 'view page source');
  224. ext.add('my-setpref', function(){
  225. util.setPrefs(
  226. {
  227. "browser.bookmarks.max_backups":0,
  228. "browser.cache.memory.capacity":16384,
  229. "browser.download.manager.closeWhenDone":true,
  230. "browser.download.useDownloadDir":false,
  231. "browser.fullscreen.autohide":false,
  232. "browser.search.openintab":true,
  233. "browser.sessionhistory.max_total_viewers":8,
  234. "browser.sessionstore.restore_on_demand":true,
  235. "browser.tabs.closeWindowWithLastTab":false,
  236. "browser.tabs.loadDivertedInBackground": true,
  237. "browser.urlbar.autocomplete.enabled":false,
  238. "browser.urlbar.trimURLs":false,
  239. "dom.disable_window_open_feature.location": false,
  240. "dom.max_script_run_time": 30,
  241. "extensions.chaika.bbsmenu.open_new_tab":true,
  242. "extensions.chaika.bbsmenu.open_single_click":false,
  243. "extensions.chaika.board.open_new_tab":true,
  244. "extensions.chaika.board.open_single_click":false,
  245. "extensions.foxage2ch.openThreadInTab":true,
  246. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  247. "extensions.saveimageinfolder.general-fileprefixvalue":"%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  248. "extensions.saveimageinfolder.usecache":true,
  249. "extensions.tabutils.openTabNext":1,
  250. "extensions.tabutils.styles.current":"{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  251. "extensions.tabutils.styles.unread":"{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}",
  252. "extensions.yass.edgetype":0,
  253. "extensions.yass.selectedpreset":"red",
  254. "font.default.x-western":"sans-serif",
  255. "gecko.handlerService.schemes.mailto.1.name":"Gmail",
  256. "general.warnOnAboutConfig":false,
  257. "keyword.URL":"http://www.bing.com/search?q=",
  258. "network.dns.disableIPv6":true,
  259. "refcontrol.actions":"@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL",
  260. "scrapbook.tabs.open":true
  261. }
  262. );
  263. if(/^Linux/.test(navigator.platform)){
  264. util.setPrefs(
  265. {
  266. "browser.cache.disk.parent_directory":"/tmp",
  267. "browser.cache.disk.capacity":524288
  268. }
  269. );
  270. }
  271. display.showPopup("Keysnail", "My prefs done.");
  272. }, 'my setpref');
  273. ext.add('auto-install-plugins', function(ev, arg){
  274. var urls = [
  275. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  276. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  277. 'https://raw.github.com/mooz/keysnail/master/plugins/hok.ks.js',
  278. 'https://github.com/mooz/keysnail/raw/master/plugins/builtin-commands-ext.ks.js',
  279. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  280. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  281. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  282. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  283. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  284. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  285. 'https://raw.github.com/10sr/keysnail-plugin/master/pixiv_autojump.ks.js',
  286. 'https://raw.github.com/10sr/keysnail-plugin/master/list-current-urls.ks.js',
  287. 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js',
  288. 'https://raw.github.com/gist/1450594/mstranslator.ks.js'
  289. ];
  290. function inst(a){
  291. if(a.length == 0){
  292. display.showPopup("auto-install-plugins", "All installation finished.");
  293. }else{
  294. var url = a.shift();
  295. var path = userscript.pluginDir + userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  296. if(plugins.context[path] === undefined){
  297. userscript.installPluginFromURL(url, function(){inst(a);});
  298. }else{
  299. inst(a);
  300. }
  301. }
  302. }
  303. inst(urls);
  304. }, 'Install plugins automatically if not installed yet.');
  305. ext.add('put-aside-this-page', function (ev, arg) {
  306. var n = gBrowser.mCurrentTab._tPos;
  307. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  308. if (n != 0) {
  309. gBrowser.selectedTab = gBrowser.mTabs[n];
  310. }
  311. }, 'put aside this page');
  312. ext.add('send-escape', function (ev, arg) {
  313. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  314. }, 'escape');
  315. ext.add("open-hatebu-comment", function (ev, arg) {
  316. if (window.loadURI) {
  317. loadURI("javascript:location.href='http://b.hatena.ne.jp/entry?mode=more&url='+encodeURIComponent(location.href);");
  318. }
  319. }, 'hatebu');
  320. // ext.add("focus-on-content", function(){
  321. // let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  322. // gBrowser.focus();
  323. // content.focus();
  324. // }, "forcus on content");
  325. ext.add("hide-sidebar", function(){
  326. var sidebarBox = document.getElementById("sidebar-box");
  327. if (!sidebarBox.hidden) {
  328. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  329. }
  330. }, "hide-sidebar");
  331. ext.add("close-and-next-tab", function (ev, arg) {
  332. var n = gBrowser.mCurrentTab._tPos;
  333. gBrowser.removeCurrentTab();
  334. gBrowser.selectedTab = gBrowser.mTabs[n];
  335. }, "close and focus to next tab");
  336. //////////////////////////////////////
  337. //
  338. ext.add("restart-firefox-add-menu", function(){
  339. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  340. var cmdelm = document.createElementNS(XUL_NS, "command");
  341. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs");
  342. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  343. var commandset = document.getElementById("mainCommandSet");
  344. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  345. commandset.appendChild(cmdelm);
  346. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  347. menuelm.setAttribute("label", "Restart Firefox");
  348. menuelm.setAttribute("id", "my_menu_restartFirefoxKs");
  349. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  350. var menu = document.getElementById("menu_FilePopup");
  351. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  352. menu.appendChild(menuelm);
  353. }, "add restart firefox menu");
  354. /////////////////////////////////////////
  355. // copy feed url
  356. ext.add("copy-url", function () {
  357. const doc = content.document;
  358. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  359. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  360. 'link[type="application/atom+xml"]'])))];
  361. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  362. for (i = 0; i < feeds.length; i++)
  363. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  364. feeds.unshift([window.content.document.title,window.content.location.href]);
  365. prompt.selector(
  366. {
  367. message : "Select Feed",
  368. collection : feeds,
  369. callback : function (i) {
  370. if (i >= 0)
  371. command.setClipboardText(feeds[i][1]);
  372. }
  373. }
  374. );
  375. }, "Copy url or feed url of current page");
  376. ///////////////////////////////////////
  377. // keysnail z menu
  378. ext.add("keysnail-setting-dialog", function(){
  379. KeySnail.openPreference();
  380. }, "keysnail setting dialog");
  381. ext.add("keysnail-plugin-manager", function(){
  382. userscript.openPluginManager();
  383. }, "keysnail plugin manager");
  384. ext.add("firefox-open-addon-manager", function(){
  385. BrowserOpenAddonsMgr();
  386. }, "firefox addon manager");
  387. ext.add("keysnail-reload-init-file", function(){
  388. userscript.reload();
  389. }, "keysnail reload init file");
  390. ext.add("keysnail-z-menu",function(){
  391. var list = [["keysnail-setting-dialog"],
  392. ["keysnail-plugin-manager"],
  393. ["firefox-open-addon-manager"],
  394. ["keysnail-reload-init-file"],
  395. // ["check-for-plugins-update"],
  396. ["restart-firefox"]
  397. ];
  398. prompt.selector(
  399. {
  400. message : "open setting dialog",
  401. collection : list,
  402. callback : function (i) {
  403. ext.exec(list[i][0]);
  404. }
  405. });
  406. },"open keysnail z menu");
  407. ///////////////////////////////////
  408. // search web
  409. ext.add("query-then-engine", function () {
  410. prompt.reader({message : "Search Word?:",
  411. group : "query_word",
  412. completer : completer.matcher.header(share.friendsCache || []),
  413. callback : function (q) {
  414. if (q) {
  415. prompt.selector({ message : "search \"" + q + "\" with?",
  416. collection : plugins.options["search-url-list"],
  417. width : [20,80],
  418. callback : function (i) {
  419. getBrowser().selectedTab = getBrowser().addTab(plugins.options["search-url-list"][i][1].replace("%r",q).replace("%q",encodeURIComponent(q)));
  420. },
  421. });
  422. };
  423. },
  424. initialInput : content.document.getSelection() || "",
  425. });
  426. }, "enter search word and then select engine");
  427. /////////////////////////////////////
  428. // closed tab list
  429. ext.add("list-closed-tabs", function () {
  430. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  431. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  432. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  433. var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  434. if (!closedTabs.length)
  435. return void display.echoStatusBar("No recently closed tab.", 2000);
  436. prompt.selector(
  437. {
  438. message : "select tab to undo:",
  439. collection : closedTabs,
  440. flags : [ICON | IGNORE, 0, 0],
  441. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  442. });
  443. }, "List closed tabs");
  444. // ext.add("echo-closed-tabs", function () {
  445. // var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  446. // var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  447. // // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  448. // var lasttab = json.decode(ss.getClosedTabData(window))[0];
  449. // dump = ""
  450. // for (var i in lasttab) { dump += lasttab[i] + "\n"; }
  451. // confirm(dump);
  452. // }, "List closed tabs");
  453. ///////////////////////////////
  454. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  455. ext.add("list-tab-history", function () {
  456. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  457. var tabHistory = [];
  458. var sessionHistory = gBrowser.webNavigation.sessionHistory;
  459. if (sessionHistory.count < 1)
  460. return void display.echoStatusBar("Tab history not exist", 2000);
  461. var curIdx = sessionHistory.index;
  462. for (var i = 0; i < sessionHistory.count; i++) {
  463. var entry = sessionHistory.getEntryAtIndex(i, false);
  464. if (!entry)
  465. continue;
  466. try {
  467. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  468. .getService(Ci.nsIFaviconService)
  469. .getFaviconForPage(entry.URI).spec;
  470. } catch (ex) {}
  471. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  472. }
  473. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  474. if (tabHistory[thIdx][3] == curIdx) break;
  475. }
  476. prompt.selector(
  477. {
  478. message : "select history in tab",
  479. collection : tabHistory,
  480. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  481. header : ["Title", "URL"],
  482. initialIndex : thIdx,
  483. callback : function(i) { if (i >= 0) gBrowser.webNavigation.gotoIndex(tabHistory[i][3]); }
  484. });
  485. }, 'List tab history');
  486. //}}%PRESERVE%
  487. // ========================================================================= //
  488. // ========================= Special key settings ========================== //
  489. key.quitKey = "ESC";
  490. key.helpKey = "<f1>";
  491. key.escapeKey = "C-q";
  492. key.macroStartKey = "";
  493. key.macroEndKey = "";
  494. key.universalArgumentKey = "C-u";
  495. key.negativeArgument1Key = "C--";
  496. key.negativeArgument2Key = "C-M--";
  497. key.negativeArgument3Key = "M--";
  498. key.suspendKey = "Not defined";
  499. // ================================= Hooks ================================= //
  500. hook.setHook('KeyBoardQuit', function (aEvent) {
  501. ext.exec("hide-sidebar");
  502. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  503. gBrowser.focus();
  504. content.focus();
  505. command.closeFindBar();
  506. if (util.isCaretEnabled()) {
  507. command.resetMark(aEvent);
  508. } else {
  509. goDoCommand("cmd_selectNone");
  510. }
  511. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  512. });
  513. hook.setHook('Unload', function () {
  514. util.getBrowserWindows().some(function (win) {
  515. if (win === window) {
  516. return false;
  517. }
  518. const ks = win.KeySnail;
  519. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  520. ks.setUpPluginUpdaterDelegator();
  521. return true;
  522. });
  523. });
  524. // ============================= Key bindings ============================== //
  525. key.setGlobalKey('C-<right>', function () {
  526. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  527. }, 'ひとつ右のタブへ');
  528. key.setGlobalKey('C-<left>', function () {
  529. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  530. }, 'ひとつ左のタブへ');
  531. key.setGlobalKey('C-<up>', function () {
  532. var browser = getBrowser();
  533. if (browser.mCurrentTab.previousSibling) {
  534. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  535. } else {
  536. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  537. }
  538. }, '選択中のタブを右へ');
  539. key.setGlobalKey('C-<down>', function () {
  540. var browser = getBrowser();
  541. if (browser.mCurrentTab.nextSibling) {
  542. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  543. } else {
  544. browser.moveTabTo(browser.mCurrentTab, 0);
  545. }
  546. }, '選択中のタブを左へ');
  547. key.setGlobalKey('<delete>', function (ev, arg) {
  548. let (elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  549. gBrowser.focus();
  550. content.focus();
  551. }, 'コンテンツへフォーカス', true);
  552. key.setGlobalKey('<f11>', function (ev, arg) {
  553. ext.exec("strong-fullscreen", arg, ev);
  554. }, 'go fullscreen with hiding toolbar and tabbar', true);
  555. key.setViewKey('N', function (ev) {
  556. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  557. }, 'ひとつ右のタブへ');
  558. key.setViewKey('P', function (ev) {
  559. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  560. }, 'ひとつ左のタブへ');
  561. key.setViewKey('o', function (ev, arg) {
  562. ext.exec("hok-start-foreground-mode", arg, ev);
  563. }, 'Start Hit a Hint foreground mode', true);
  564. key.setViewKey('c', function (ev) {
  565. command.interpreter();
  566. }, 'JavaScript のコードを評価');
  567. key.setViewKey('D', function (ev, arg) {
  568. ext.exec("dig-url", arg, ev);
  569. }, 'dig url with selector', true);
  570. key.setViewKey('x', function (aEvent, aArg) {
  571. ext.select(aArg, aEvent);
  572. }, 'エクステ一覧');
  573. key.setViewKey(['t', 'm'], function (ev, arg) {
  574. if (window.loadURI) {
  575. loadURI("javascript:window.location='http://api.tweetmeme.com/visit?url='+window.location;");
  576. }
  577. }, 'open with tweetmeme');
  578. key.setViewKey(['t', 'w'], function (ev, arg) {
  579. ext.exec("twitter-client-tweet", arg, ev);
  580. }, 'つぶやく', true);
  581. key.setViewKey(['t', 'p'], function (ev, arg) {
  582. ext.exec("twitter-client-tweet-this-page", arg, ev);
  583. }, 'このページのタイトルと URL を使ってつぶやく', true);
  584. key.setViewKey([['u'], ['<left>']], function (ev) {
  585. goDoCommand("cmd_scrollPageUp");
  586. }, '一画面分スクロールアップ');
  587. key.setViewKey('g', function () {
  588. goDoCommand("cmd_scrollTop");
  589. }, 'ページ先頭へ移動');
  590. key.setViewKey('G', function () {
  591. goDoCommand("cmd_scrollBottom");
  592. }, 'ページ末尾へ移動');
  593. key.setViewKey('r', function (aEvent) {
  594. BrowserReload();
  595. }, '再読み込み');
  596. key.setViewKey('m', function (ev, arg) {
  597. _fi.toogle();
  598. }, 'fetchimiをトグル');
  599. key.setViewKey('SPC', function (ev, arg) {
  600. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  601. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  602. }, 'タブの選択をトグルして次のタブ');
  603. key.setViewKey('S-SPC', function (ev, arg) {
  604. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  605. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  606. }, 'タブの選択をトグルして前のタブ');
  607. key.setViewKey('z', function (ev, arg) {
  608. ext.exec("keysnail-z-menu", arg, ev);
  609. }, 'open keysnail setting menu', true);
  610. key.setViewKey('C-SPC', function (ev, arg) {
  611. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  612. }, 'タブの選択をトグル');
  613. key.setViewKey('e', function () {
  614. command.focusElement(command.elementsRetrieverTextarea, 0);
  615. }, '最初のインプットエリアへフォーカス', true);
  616. key.setViewKey('S', function (ev, arg) {
  617. if (window.loadURI) {
  618. 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{}");
  619. }
  620. }, 'google reader share');
  621. key.setViewKey('!', function (ev, arg) {
  622. shell.input();
  623. }, 'Command system');
  624. key.setViewKey('R', function () {
  625. BrowserReloadSkipCache();
  626. }, '更新(キャッシュを無視)');
  627. key.setViewKey('<backspace>', function () {
  628. BrowserBack();
  629. }, '戻る');
  630. key.setViewKey('S-<backspace>', function () {
  631. BrowserForward();
  632. }, '進む');
  633. key.setViewKey('q', function (ev, arg) {
  634. ext.exec("query-then-engine", arg, ev);
  635. }, 'enter search word and then select engine', true);
  636. key.setViewKey('/', function () {
  637. command.iSearchForward();
  638. }, 'インクリメンタル検索', true);
  639. key.setViewKey('?', function (ev) {
  640. command.iSearchForwardKs(ev);
  641. }, 'Emacs ライクなインクリメンタル検索', true);
  642. key.setViewKey('a', function (ev, arg) {
  643. allTabs.open();
  644. }, 'alltabs.open');
  645. key.setViewKey([['<right>'], ['d']], function (ev) {
  646. goDoCommand("cmd_scrollPageDown");
  647. }, '一画面スクロールダウン');
  648. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  649. return;
  650. }, 'ignore');
  651. key.setViewKey(':', function (ev, arg) {
  652. return !document.getElementById("keysnail-prompt").hidden &&
  653. document.getElementById("keysnail-prompt-textbox").focus();
  654. }, 'KeySnail のプロンプトへフォーカス', true);
  655. key.setViewKey('B', function (ev) {
  656. var browser = getBrowser();
  657. if (browser.mCurrentTab.previousSibling) {
  658. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  659. } else {
  660. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  661. }
  662. }, '選択中のタブを左へ');
  663. key.setViewKey('0', function (ev) {
  664. BrowserCloseTabOrWindow();
  665. }, 'タブ / ウィンドウを閉じる');
  666. key.setViewKey('C', function (ev, arg) {
  667. ext.exec("linksnail", arg, ev);
  668. }, 'LinkSnail', true);
  669. key.setViewKey('C-<backspace>', function (ev, arg) {
  670. ext.exec("list-tab-history", arg, ev);
  671. }, 'List tab history', true);
  672. key.setViewKey('I', function (ev, arg) {
  673. ext.exec("instapaper-post-page-with-comment", arg, ev);
  674. }, 'post page and comment', true);
  675. key.setViewKey('T', function (ev, arg) {
  676. ext.exec("mstranslator-open-prompt", arg, ev);
  677. }, 'MSTranslator - Open prompt', true);
  678. key.setViewKey('n', function (ev) {
  679. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
  680. }, '一行スクロールダウン');
  681. key.setViewKey('p', function (ev) {
  682. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
  683. }, '一行スクロールアップ');
  684. key.setViewKey('f', function (ev) {
  685. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RIGHT, true);
  686. }, '右へスクロール');
  687. key.setViewKey('b', function (ev) {
  688. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true);
  689. }, '左へスクロール');
  690. key.setViewKey('F', function (ev) {
  691. var browser = getBrowser();
  692. if (browser.mCurrentTab.nextSibling) {
  693. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  694. } else {
  695. browser.moveTabTo(browser.mCurrentTab, 0);
  696. }
  697. }, '選択中のタブを右へ');
  698. key.setViewKey('U', function (ev, arg) {
  699. ext.exec("list-closed-tabs", arg, ev);
  700. }, 'List closed tabs', true);
  701. key.setEditKey('C-<tab>', function (ev) {
  702. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  703. }, '次のテキストエリアへフォーカス');
  704. key.setEditKey('C-a', function (ev) {
  705. command.beginLine(ev);
  706. }, '行頭へ移動');
  707. key.setEditKey('C-e', function (ev) {
  708. command.endLine(ev);
  709. }, '行末へ');
  710. key.setEditKey('C-d', function (ev) {
  711. goDoCommand("cmd_deleteCharForward");
  712. }, '次の一文字削除');
  713. key.setEditKey('C-b', function (ev) {
  714. command.previousChar(ev);
  715. }, '一文字左へ移動');
  716. key.setEditKey('C-f', function (ev) {
  717. command.nextChar(ev);
  718. }, '一文字右へ移動');
  719. key.setEditKey('C-h', function (ev) {
  720. goDoCommand("cmd_deleteCharBackward");
  721. }, '前の一文字を削除');
  722. key.setEditKey('C-k', function (ev) {
  723. command.killLine(ev);
  724. }, 'カーソルから先を一行カット (Kill line)');
  725. key.setEditKey('C-l', function (ev) {
  726. command.recenter(ev);
  727. }, 'カーソル位置が画面の中央へ来るようスクロール', true);
  728. key.setEditKey('C-n', function (ev) {
  729. command.nextLine(ev);
  730. }, '一行下へ');
  731. key.setEditKey('C-p', function (ev) {
  732. command.previousLine(ev);
  733. }, '一行上へ');
  734. key.setEditKey('C-o', function (ev) {
  735. command.openLine(ev);
  736. }, '行を開く (Open line)');