Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

829 строки
31 KiB

  1. // ========================== KeySnail Init File =========================== //
  2. // この領域は, GUI により設定ファイルを生成した際にも引き継がれます
  3. // 特殊キー, キーバインド定義, フック, ブラックリスト以外のコードは, この中に書くようにして下さい
  4. // ========================================================================= //
  5. //{{%PRESERVE%
  6. // prompt.rows = 12;
  7. // prompt.useMigemo = false;
  8. // prompt.migemoMinWordLength = 2;
  9. // prompt.displayDelayTime = 300;
  10. // command.kill.killRingMax = 15;
  11. // command.kill.textLengthMax = 8192;
  12. //////////////////////////////////////
  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('C-h', function (ev, arg) {
  548. return;
  549. }, 'ignore');
  550. key.setGlobalKey('<delete>', function (ev, arg) {
  551. let (elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  552. gBrowser.focus();
  553. content.focus();
  554. }, 'コンテンツへフォーカス', true);
  555. key.setGlobalKey('C-p', function (ev, arg) {
  556. return !document.getElementById("keysnail-prompt").hidden &&
  557. document.getElementById("keysnail-prompt-textbox").focus();
  558. }, 'KeySnail のプロンプトへフォーカス', true);
  559. key.setGlobalKey('<f11>', function (ev, arg) {
  560. ext.exec("strong-fullscreen", arg, ev);
  561. }, 'go fullscreen with hiding toolbar and tabbar', true);
  562. key.setViewKey('N', function (ev) {
  563. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  564. }, 'ひとつ右のタブへ');
  565. key.setViewKey('P', function (ev) {
  566. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  567. }, 'ひとつ左のタブへ');
  568. key.setViewKey('o', function (ev, arg) {
  569. ext.exec("hok-start-foreground-mode", arg, ev);
  570. }, 'Start Hit a Hint foreground mode', true);
  571. key.setViewKey('c', function (ev) {
  572. command.interpreter();
  573. }, 'JavaScript のコードを評価');
  574. key.setViewKey('D', function (ev, arg) {
  575. ext.exec("dig-url", arg, ev);
  576. }, 'dig url with selector', true);
  577. key.setViewKey('x', function (aEvent, aArg) {
  578. ext.select(aArg, aEvent);
  579. }, 'エクステ一覧');
  580. key.setViewKey(['t', 'm'], function (ev, arg) {
  581. if (window.loadURI) {
  582. loadURI("javascript:window.location='http://api.tweetmeme.com/visit?url='+window.location;");
  583. }
  584. }, 'open with tweetmeme');
  585. key.setViewKey(['t', 'w'], function (ev, arg) {
  586. ext.exec("twitter-client-tweet", arg, ev);
  587. }, 'つぶやく', true);
  588. key.setViewKey(['t', 'p'], function (ev, arg) {
  589. ext.exec("twitter-client-tweet-this-page", arg, ev);
  590. }, 'このページのタイトルと URL を使ってつぶやく', true);
  591. key.setViewKey([['u'], ['<left>']], function (ev) {
  592. goDoCommand("cmd_scrollPageUp");
  593. }, '一画面分スクロールアップ');
  594. key.setViewKey('g', function () {
  595. goDoCommand("cmd_scrollTop");
  596. }, 'ページ先頭へ移動');
  597. key.setViewKey('G', function () {
  598. goDoCommand("cmd_scrollBottom");
  599. }, 'ページ末尾へ移動');
  600. key.setViewKey('r', function (aEvent) {
  601. BrowserReload();
  602. }, '再読み込み');
  603. key.setViewKey('m', function (ev, arg) {
  604. _fi.toogle();
  605. }, 'fetchimiをトグル');
  606. key.setViewKey('SPC', function (ev, arg) {
  607. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  608. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  609. }, 'タブの選択をトグルして次のタブ');
  610. key.setViewKey('S-SPC', function (ev, arg) {
  611. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  612. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  613. }, 'タブの選択をトグルして前のタブ');
  614. key.setViewKey('z', function (ev, arg) {
  615. ext.exec("keysnail-z-menu", arg, ev);
  616. }, 'open keysnail setting menu', true);
  617. key.setViewKey('C-SPC', function (ev, arg) {
  618. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  619. }, 'タブの選択をトグル');
  620. key.setViewKey('e', function () {
  621. command.focusElement(command.elementsRetrieverTextarea, 0);
  622. }, '最初のインプットエリアへフォーカス', true);
  623. key.setViewKey('S', function (ev, arg) {
  624. if (window.loadURI) {
  625. 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{}");
  626. }
  627. }, 'google reader share');
  628. key.setViewKey('!', function (ev, arg) {
  629. shell.input();
  630. }, 'Command system');
  631. key.setViewKey('R', function () {
  632. BrowserReloadSkipCache();
  633. }, '更新(キャッシュを無視)');
  634. key.setViewKey('<backspace>', function () {
  635. BrowserBack();
  636. }, '戻る');
  637. key.setViewKey('S-<backspace>', function () {
  638. BrowserForward();
  639. }, '進む');
  640. key.setViewKey('q', function (ev, arg) {
  641. ext.exec("query-then-engine", arg, ev);
  642. }, 'enter search word and then select engine', true);
  643. key.setViewKey('/', function () {
  644. command.iSearchForward();
  645. }, 'インクリメンタル検索', true);
  646. key.setViewKey('?', function (ev) {
  647. command.iSearchForwardKs(ev);
  648. }, 'Emacs ライクなインクリメンタル検索', true);
  649. key.setViewKey('a', function (ev, arg) {
  650. allTabs.open();
  651. }, 'alltabs.open');
  652. key.setViewKey([['<right>'], ['d']], function (ev) {
  653. goDoCommand("cmd_scrollPageDown");
  654. }, '一画面スクロールダウン');
  655. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  656. return;
  657. }, 'ignore');
  658. key.setViewKey(':', function (ev, arg) {
  659. return !document.getElementById("keysnail-prompt").hidden &&
  660. document.getElementById("keysnail-prompt-textbox").focus();
  661. }, 'KeySnail のプロンプトへフォーカス', true);
  662. key.setViewKey('B', function (ev) {
  663. var browser = getBrowser();
  664. if (browser.mCurrentTab.previousSibling) {
  665. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  666. } else {
  667. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  668. }
  669. }, '選択中のタブを左へ');
  670. key.setViewKey('0', function (ev) {
  671. BrowserCloseTabOrWindow();
  672. }, 'タブ / ウィンドウを閉じる');
  673. key.setViewKey('C', function (ev, arg) {
  674. ext.exec("linksnail", arg, ev);
  675. }, 'LinkSnail', true);
  676. key.setViewKey('C-<backspace>', function (ev, arg) {
  677. ext.exec("list-tab-history", arg, ev);
  678. }, 'List tab history', true);
  679. key.setViewKey('I', function (ev, arg) {
  680. ext.exec("instapaper-post-page-with-comment", arg, ev);
  681. }, 'post page and comment', true);
  682. key.setViewKey('T', function (ev, arg) {
  683. ext.exec("mstranslator-open-prompt", arg, ev);
  684. }, 'MSTranslator - Open prompt', true);
  685. key.setViewKey('n', function (ev) {
  686. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
  687. }, '一行スクロールダウン');
  688. key.setViewKey('p', function (ev) {
  689. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
  690. }, '一行スクロールアップ');
  691. key.setViewKey('f', function (ev) {
  692. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RIGHT, true);
  693. }, '右へスクロール');
  694. key.setViewKey('b', function (ev) {
  695. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true);
  696. }, '左へスクロール');
  697. key.setViewKey('F', function (ev) {
  698. var browser = getBrowser();
  699. if (browser.mCurrentTab.nextSibling) {
  700. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  701. } else {
  702. browser.moveTabTo(browser.mCurrentTab, 0);
  703. }
  704. }, '選択中のタブを右へ');
  705. key.setViewKey('U', function (ev, arg) {
  706. ext.exec("list-closed-tabs", arg, ev);
  707. }, 'List closed tabs', true);
  708. key.setEditKey('C-<tab>', function (ev) {
  709. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  710. }, '次のテキストエリアへフォーカス');