Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

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