Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

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