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.
 
 
 
 
 
 

822 lines
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. ///////////////////////////////////
  26. //search engine
  27. plugins.options["search-url-list"] = [
  28. ["bing","http://bing.com/search?q=%q"],
  29. ["yatwitter search","http://yats-data.com/yats/search?query=%q"],
  30. ["twitter search","http://search.twitter.com/search?q=%q&lang=all"],
  31. ["tospy", "http://topsy.com/s?allow_lang=ja&q=%q"],
  32. ["2ch","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  33. ["I\'m feelig lucky!","http://www.google.co.jp/search?q=%q&btnI=kudos"],
  34. ["uncyclopedia","http://ja.uncyclopedia.info/wiki/%q"],
  35. ["wikipedia","http://ja.wikipedia.org/wiki/%q"],
  36. ["nicovideo.jp","http://www.nicovideo.jp/search/%q"],
  37. ["alc","http://eow.alc.co.jp/%q/UTF-8/"],
  38. ["google map","http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  39. ["weblio","http://www.weblio.jp/content_find?query=%q"],
  40. ["shoutcast","http://www.shoutcast.com/Internet-Radio/%q"],
  41. ["10sr.posterous.com","http://www.google.com/search?q=%q&ie=UTF-8&oe=UTF-8&hl=ja&domains=10sr.posterous.com&sitesearch=10sr.posterous.com"],
  42. ["delicious 10sr","http://delicious.com/10sr?addtag=%q&setcount=50&opennew=1"],
  43. ["open raw","%r"],
  44. ];
  45. plugins.options["my-keysnail-bookmarks"] = [
  46. "twitter.com"
  47. ];
  48. // sitelocal keymap
  49. //////////////////////////////////////////
  50. // 2ch chaika
  51. // change chaika port every time firefox starts
  52. util.setIntPref("extensions.chaika.server_port.firefox",
  53. 8800 + Math.floor(Math.random() * 30));
  54. local["^http://127.0.0.1:88"] = [
  55. ['k', function (ev, arg) {
  56. curl = window.content.location.href;
  57. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  58. window.content.location.href = kurl;
  59. }
  60. ]
  61. ];
  62. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  63. ['k', function (ev, arg) {
  64. var url = window.content.location.href;
  65. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  66. var result = url.match(pt);
  67. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/", result[1], result[2], result[3]);
  68. window.content.location.href = k;
  69. }
  70. ]
  71. ];
  72. /////////////////////////////////////////
  73. // feedly
  74. local["^http://www.feedly.com/"] = [
  75. ['d', null],
  76. ['j', null],
  77. ['k', null],
  78. ['n', null],
  79. ['p', null],
  80. ['o', null],
  81. ['b', null],
  82. ['S', null],
  83. ['s', null],
  84. ['?', null],
  85. ['r', null],
  86. ['g', null],
  87. // ['x', function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("g", true));}],
  88. ['l', function (ev, arg) {window.content.location.href = "http://www.feedly.com/home#latest";}],
  89. [['t', 'p'], function (ev, arg) {ev.target.dispatchEvent(key.stringToKeyEvent("t", true));}],
  90. [['t', 'w'], function (ev, arg) {ext.exec("twitter-client-tweet", arg, ev);}]
  91. ];
  92. /////////////////////////////////////////
  93. //nicovideo
  94. local["http://(www|tw|es|de|)\.nicovideo\.jp\/(watch|playlist)/*"] = [
  95. ["i", function (ev, arg) { ext.exec("nicoinfo", arg); }],
  96. ["p", function (ev, arg) { ext.exec("nicopause", arg); }],
  97. // ["o", function (ev, arg) { ext.exec("nicommentvisible", arg); }],
  98. ["m", function (ev, arg) { ext.exec("nicomute", arg); }],
  99. [".", function (ev, arg) { ext.exec("nicovolumeIncrement", arg); }],
  100. [",", function (ev, arg) { ext.exec("nicovolumeDecrement", arg); }],
  101. ['f', function (ev, arg) {
  102. curl = window.content.location.href;
  103. kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  104. window.content.location.href = kurl;
  105. }
  106. ]
  107. ];
  108. /////////////////////////////////////////
  109. // tumblr/dashboard
  110. local["^http://www.tumblr.com/dashboard"] = [
  111. // ["C-<left>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(-1, true); }],
  112. // ["C-<right>", function (ev, arg) {gBrowser.mTabContainer.advanceSelectedTab(1, true); }],
  113. ["<left>", function (ev, arg) { window.content.location.href = "http://www.tumblr.com/dashboard"; }],
  114. ["<right>", null],
  115. ["J", function (ev, arg) {
  116. if (window.loadURI) {
  117. 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;}())");
  118. }
  119. }]
  120. ];
  121. ///////////////////////////////////////////
  122. // plugin option
  123. plugins.options["builtin_commands_ext.ext_list"] = [
  124. "focus-to-prompt",
  125. "open-url-from-clipboard",
  126. "restart-firefox"
  127. ];
  128. plugins.options["instapaper.close_after_post"] = true;
  129. plugins.options["instapaper.initial_comment_function"] = function(){
  130. var now = new Date();
  131. return "[" + now.toString() + "]";
  132. };
  133. //////////////////////////////////////////
  134. // yatc
  135. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  136. plugins.options["twitter_client.popup_new_statuses"] = false;
  137. plugins.options["twitter_client.automatically_begin"] = false;
  138. plugins.options["twitter_client.automatically_begin_list"] = false;
  139. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  140. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  141. plugins.options["twitter_client.tweet_keymap"] = {
  142. "C-RET" : "prompt-decide",
  143. "RET" : ""
  144. };
  145. plugins.options["twitter_client.jmp_id"] = "10sr";
  146. plugins.options["twitter_client.jmp_key"] = "R_c51f889a77cb4b4e993ed868f65083f5";
  147. plugins.options["twitter_client.use_jmp"] = true;
  148. ////////////////////////////////////////////
  149. // my ext
  150. ext.add('post-to-posterous', function (ev, arg) {
  151. if (window.loadURI) {
  152. 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{}");
  153. }
  154. }, 'post to posterous');
  155. ext.add("echo-tab-info", function(){
  156. var all = gBrowser.tabs.length;
  157. var ix = gBrowser.mCurrentTab._tPos;
  158. var title = window.document.title;
  159. var url = window.content.location.href;
  160. display.echoStatusBar((ix + 1).toString() + " / " +
  161. all.toString() + " : " +
  162. title + " <" +
  163. url + ">");
  164. }, "echo tab info");
  165. ext.add("strong-fullscreen", function(){
  166. var elemids = [
  167. "navigator-toolbox"
  168. ];
  169. BrowserFullScreen();
  170. var isfullscreen = window.fullScreen;
  171. for(var i = 0; i < elemids.length; i++){
  172. var elem = document.getElementById(elemids[i]);
  173. if(elem){
  174. if(isfullscreen){
  175. elem.style.display = "none";
  176. }else{
  177. elem.style.display = null;
  178. }
  179. }
  180. }
  181. var tabs = document.getElementById("verticaltabs-box");
  182. if(tabs){
  183. var pref_key = "extensions.verticaltabs.width";
  184. var pref_key_bak = pref_key + "_bak"
  185. if(isfullscreen){
  186. var width_orig = util.getIntPref(pref_key);
  187. util.setIntPref(pref_key_bak, width_orig);
  188. util.setIntPref(pref_key, 0);
  189. tabs.setAttribute("width", "0");
  190. }else if(parseInt(tabs.getAttribute("width") || "") === 0){
  191. var width_bak = util.getIntPref(pref_key_bak);
  192. util.setIntPref(pref_key, width_bak);
  193. tabs.setAttribute("width", width_bak.toString());
  194. }
  195. }
  196. }, "go fullscreen with hiding toolbar and tabbar");
  197. ext.add("bookmark-delicious", function(){
  198. f= 'http://www.delicious.com/save?url=' + encodeURIComponent(window.content.location.href) +
  199. '&title=' + encodeURIComponent(document.title) +
  200. '&notes=' + encodeURIComponent('' + (window.getSelection ?
  201. window.getSelection() : document.getSelection ?
  202. document.getSelection() : document.selection.createRange().text)) + '&v=6&';
  203. a = function(){
  204. if(! window.open(f + 'noui=1&jump=doclose', 'deliciousuiv6', 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){
  205. location.href = f + 'jump=yes';
  206. }
  207. };
  208. if(/Firefox/.test(navigator.userAgent)){
  209. setTimeout(a,0);
  210. }else{
  211. a();
  212. }
  213. }, "bookmark delicious");
  214. ext.add('view-page-source', function(){
  215. window.content.location.href = "view-source:" + window.content.location.href;
  216. }, 'view page source');
  217. ext.add('my-setpref', function(){
  218. util.setPrefs(
  219. {
  220. "browser.bookmarks.max_backups":0,
  221. "browser.cache.memory.capacity":16384,
  222. "browser.download.manager.closeWhenDone":true,
  223. "browser.download.useDownloadDir":false,
  224. "browser.fullscreen.autohide":false,
  225. "browser.search.openintab":true,
  226. "browser.sessionhistory.max_total_viewers":8,
  227. "browser.sessionstore.restore_on_demand":true,
  228. "browser.tabs.closeWindowWithLastTab":false,
  229. "browser.tabs.loadDivertedInBackground": true,
  230. "browser.urlbar.autocomplete.enabled":false,
  231. "browser.urlbar.trimURLs":false,
  232. "dom.disable_window_open_feature.location": false,
  233. "dom.max_script_run_time": 30,
  234. "extensions.chaika.bbsmenu.open_new_tab":true,
  235. "extensions.chaika.bbsmenu.open_single_click":false,
  236. "extensions.chaika.board.open_new_tab":true,
  237. "extensions.chaika.board.open_single_click":false,
  238. "extensions.foxage2ch.openThreadInTab":true,
  239. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  240. "extensions.saveimageinfolder.general-fileprefixvalue":"%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  241. "extensions.saveimageinfolder.usecache":true,
  242. "extensions.tabutils.openTabNext":1,
  243. "extensions.tabutils.styles.current":"{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  244. "extensions.tabutils.styles.unread":"{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}",
  245. "extensions.yass.edgetype":0,
  246. "extensions.yass.selectedpreset":"red",
  247. "font.default.x-western":"sans-serif",
  248. "gecko.handlerService.schemes.mailto.1.name":"Gmail",
  249. "general.warnOnAboutConfig":false,
  250. "keyword.URL":"http://www.bing.com/search?q=",
  251. "network.dns.disableIPv6":true,
  252. "refcontrol.actions":"@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL",
  253. "scrapbook.tabs.open":true
  254. }
  255. );
  256. if(/^Linux/.test(navigator.platform)){
  257. util.setPrefs(
  258. {
  259. "browser.cache.disk.parent_directory":"/tmp",
  260. "browser.cache.disk.capacity":524288
  261. }
  262. );
  263. }
  264. display.showPopup("Keysnail", "My prefs done.");
  265. }, 'my setpref');
  266. ext.add('auto-install-plugins', function(ev, arg){
  267. var urls = [
  268. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  269. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  270. 'https://raw.github.com/mooz/keysnail/master/plugins/hok.ks.js',
  271. 'https://github.com/mooz/keysnail/raw/master/plugins/builtin-commands-ext.ks.js',
  272. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  273. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  274. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  275. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  276. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  277. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  278. 'https://raw.github.com/10sr/keysnail-plugin/master/pixiv_autojump.ks.js',
  279. 'https://raw.github.com/10sr/keysnail-plugin/master/list-current-urls.ks.js',
  280. 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js',
  281. 'https://raw.github.com/gist/1450594/mstranslator.ks.js'
  282. ];
  283. function inst(a){
  284. if(a.length == 0){
  285. display.showPopup("auto-install-plugins", "All installation finished.");
  286. }else{
  287. var url = a.shift();
  288. var path = userscript.pluginDir + userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  289. if(plugins.context[path] === undefined){
  290. userscript.installPluginFromURL(url, function(){inst(a);});
  291. }else{
  292. inst(a);
  293. }
  294. }
  295. }
  296. inst(urls);
  297. }, 'Install plugins automatically if not installed yet.');
  298. ext.add('put-aside-this-page', function (ev, arg) {
  299. var n = gBrowser.mCurrentTab._tPos;
  300. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  301. if (n != 0) {
  302. gBrowser.selectedTab = gBrowser.mTabs[n];
  303. }
  304. }, 'put aside this page');
  305. ext.add('send-escape', function (ev, arg) {
  306. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  307. }, 'escape');
  308. ext.add("open-hatebu-comment", function (ev, arg) {
  309. if (window.loadURI) {
  310. loadURI("javascript:location.href='http://b.hatena.ne.jp/entry?mode=more&url='+encodeURIComponent(location.href);");
  311. }
  312. }, 'hatebu');
  313. // ext.add("focus-on-content", function(){
  314. // let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  315. // gBrowser.focus();
  316. // content.focus();
  317. // }, "forcus on content");
  318. ext.add("hide-sidebar", function(){
  319. var sidebarBox = document.getElementById("sidebar-box");
  320. if (!sidebarBox.hidden) {
  321. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  322. }
  323. }, "hide-sidebar");
  324. ext.add("close-and-next-tab", function (ev, arg) {
  325. var n = gBrowser.mCurrentTab._tPos;
  326. gBrowser.removeCurrentTab();
  327. gBrowser.selectedTab = gBrowser.mTabs[n];
  328. }, "close and focus to next tab");
  329. //////////////////////////////////////
  330. //
  331. ext.add("restart-firefox-add-menu", function(){
  332. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  333. var cmdelm = document.createElementNS(XUL_NS, "command");
  334. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs");
  335. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  336. var commandset = document.getElementById("mainCommandSet");
  337. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  338. commandset.appendChild(cmdelm);
  339. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  340. menuelm.setAttribute("label", "Restart Firefox");
  341. menuelm.setAttribute("id", "my_menu_restartFirefoxKs");
  342. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  343. var menu = document.getElementById("menu_FilePopup");
  344. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  345. menu.appendChild(menuelm);
  346. }, "add restart firefox menu");
  347. /////////////////////////////////////////
  348. // copy feed url
  349. ext.add("copy-url", function () {
  350. const doc = content.document;
  351. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  352. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  353. 'link[type="application/atom+xml"]'])))];
  354. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  355. for (i = 0; i < feeds.length; i++)
  356. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  357. feeds.unshift([window.content.document.title,window.content.location.href]);
  358. prompt.selector(
  359. {
  360. message : "Select Feed",
  361. collection : feeds,
  362. callback : function (i) {
  363. if (i >= 0)
  364. command.setClipboardText(feeds[i][1]);
  365. }
  366. }
  367. );
  368. }, "Copy url or feed url of current page");
  369. ///////////////////////////////////////
  370. // keysnail z menu
  371. ext.add("keysnail-setting-dialog", function(){
  372. KeySnail.openPreference();
  373. }, "keysnail setting dialog");
  374. ext.add("keysnail-plugin-manager", function(){
  375. userscript.openPluginManager();
  376. }, "keysnail plugin manager");
  377. ext.add("firefox-open-addon-manager", function(){
  378. BrowserOpenAddonsMgr();
  379. }, "firefox addon manager");
  380. ext.add("keysnail-reload-init-file", function(){
  381. userscript.reload();
  382. }, "keysnail reload init file");
  383. ext.add("keysnail-z-menu",function(){
  384. var list = [["keysnail-setting-dialog"],
  385. ["keysnail-plugin-manager"],
  386. ["firefox-open-addon-manager"],
  387. ["keysnail-reload-init-file"],
  388. // ["check-for-plugins-update"],
  389. ["restart-firefox"]
  390. ];
  391. prompt.selector(
  392. {
  393. message : "open setting dialog",
  394. collection : list,
  395. callback : function (i) {
  396. ext.exec(list[i][0]);
  397. }
  398. });
  399. },"open keysnail z menu");
  400. ///////////////////////////////////
  401. // search web
  402. ext.add("query-then-engine", function () {
  403. prompt.reader({message : "Search Word?:",
  404. group : "query_word",
  405. completer : completer.matcher.header(share.friendsCache || []),
  406. callback : function (q) {
  407. if (q) {
  408. prompt.selector({ message : "search \"" + q + "\" with?",
  409. collection : plugins.options["search-url-list"],
  410. width : [20,80],
  411. callback : function (i) {
  412. getBrowser().selectedTab = getBrowser().addTab(plugins.options["search-url-list"][i][1].replace("%r",q).replace("%q",encodeURIComponent(q)));
  413. },
  414. });
  415. };
  416. },
  417. initialInput : content.document.getSelection() || "",
  418. });
  419. }, "enter search word and then select engine");
  420. /////////////////////////////////////
  421. // closed tab list
  422. ext.add("list-closed-tabs", function () {
  423. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  424. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  425. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  426. var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  427. if (!closedTabs.length)
  428. return void display.echoStatusBar("No recently closed tab.", 2000);
  429. prompt.selector(
  430. {
  431. message : "select tab to undo:",
  432. collection : closedTabs,
  433. flags : [ICON | IGNORE, 0, 0],
  434. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  435. });
  436. }, "List closed tabs");
  437. // ext.add("echo-closed-tabs", function () {
  438. // var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  439. // var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  440. // // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  441. // var lasttab = json.decode(ss.getClosedTabData(window))[0];
  442. // dump = ""
  443. // for (var i in lasttab) { dump += lasttab[i] + "\n"; }
  444. // confirm(dump);
  445. // }, "List closed tabs");
  446. ///////////////////////////////
  447. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  448. ext.add("list-tab-history", function () {
  449. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  450. var tabHistory = [];
  451. var sessionHistory = gBrowser.webNavigation.sessionHistory;
  452. if (sessionHistory.count < 1)
  453. return void display.echoStatusBar("Tab history not exist", 2000);
  454. var curIdx = sessionHistory.index;
  455. for (var i = 0; i < sessionHistory.count; i++) {
  456. var entry = sessionHistory.getEntryAtIndex(i, false);
  457. if (!entry)
  458. continue;
  459. try {
  460. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  461. .getService(Ci.nsIFaviconService)
  462. .getFaviconForPage(entry.URI).spec;
  463. } catch (ex) {}
  464. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  465. }
  466. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  467. if (tabHistory[thIdx][3] == curIdx) break;
  468. }
  469. prompt.selector(
  470. {
  471. message : "select history in tab",
  472. collection : tabHistory,
  473. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  474. header : ["Title", "URL"],
  475. initialIndex : thIdx,
  476. callback : function(i) { if (i >= 0) gBrowser.webNavigation.gotoIndex(tabHistory[i][3]); }
  477. });
  478. }, 'List tab history');
  479. //}}%PRESERVE%
  480. // ========================================================================= //
  481. // ========================= Special key settings ========================== //
  482. key.quitKey = "ESC";
  483. key.helpKey = "<f1>";
  484. key.escapeKey = "C-q";
  485. key.macroStartKey = "";
  486. key.macroEndKey = "";
  487. key.universalArgumentKey = "C-u";
  488. key.negativeArgument1Key = "C--";
  489. key.negativeArgument2Key = "C-M--";
  490. key.negativeArgument3Key = "M--";
  491. key.suspendKey = "Not defined";
  492. // ================================= Hooks ================================= //
  493. hook.setHook('KeyBoardQuit', function (aEvent) {
  494. ext.exec("hide-sidebar");
  495. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  496. gBrowser.focus();
  497. content.focus();
  498. command.closeFindBar();
  499. if (util.isCaretEnabled()) {
  500. command.resetMark(aEvent);
  501. } else {
  502. goDoCommand("cmd_selectNone");
  503. }
  504. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  505. });
  506. hook.setHook('Unload', function () {
  507. util.getBrowserWindows().some(function (win) {
  508. if (win === window) {
  509. return false;
  510. }
  511. const ks = win.KeySnail;
  512. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  513. ks.setUpPluginUpdaterDelegator();
  514. return true;
  515. });
  516. });
  517. // ============================= Key bindings ============================== //
  518. key.setGlobalKey('C-<right>', function () {
  519. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  520. }, 'ひとつ右のタブへ');
  521. key.setGlobalKey('C-<left>', function () {
  522. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  523. }, 'ひとつ左のタブへ');
  524. key.setGlobalKey('C-<up>', function () {
  525. var browser = getBrowser();
  526. if (browser.mCurrentTab.previousSibling) {
  527. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  528. } else {
  529. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  530. }
  531. }, '選択中のタブを右へ');
  532. key.setGlobalKey('C-<down>', function () {
  533. var browser = getBrowser();
  534. if (browser.mCurrentTab.nextSibling) {
  535. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  536. } else {
  537. browser.moveTabTo(browser.mCurrentTab, 0);
  538. }
  539. }, '選択中のタブを左へ');
  540. key.setGlobalKey('C-h', function (ev, arg) {
  541. return;
  542. }, 'ignore');
  543. key.setGlobalKey('<delete>', function (ev, arg) {
  544. let (elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  545. gBrowser.focus();
  546. content.focus();
  547. }, 'コンテンツへフォーカス', true);
  548. key.setGlobalKey('C-p', function (ev, arg) {
  549. return !document.getElementById("keysnail-prompt").hidden &&
  550. document.getElementById("keysnail-prompt-textbox").focus();
  551. }, 'KeySnail のプロンプトへフォーカス', 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. }, '次のテキストエリアへフォーカス');