No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

779 líneas
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-setpref2", function(){
  143. // navigator.platform
  144. util.setPrefs(
  145. {
  146. "browser.cache.disk.parent_directory":"/tmp"
  147. }
  148. );
  149. }, "my setpref2");
  150. ext.add('my-setpref', function(){
  151. util.setPrefs(
  152. {
  153. "browser.bookmarks.max_backups":0,
  154. "browser.cache.memory.capacity":16384,
  155. "browser.download.manager.closeWhenDone":true,
  156. "browser.download.useDownloadDir":false,
  157. "browser.fullscreen.autohide":false,
  158. "browser.search.openintab":true,
  159. "browser.sessionhistory.max_total_viewers":8,
  160. "browser.sessionstore.restore_on_demand":true,
  161. "browser.tabs.closeWindowWithLastTab":false,
  162. "browser.tabs.loadDivertedInBackground": true,
  163. "browser.urlbar.autocomplete.enabled":false,
  164. "browser.urlbar.trimURLs":false,
  165. "dom.disable_window_open_feature.location": false,
  166. "dom.max_script_run_time": 30,
  167. "extensions.chaika.bbsmenu.open_new_tab":true,
  168. "extensions.chaika.bbsmenu.open_single_click":false,
  169. "extensions.chaika.board.open_new_tab":true,
  170. "extensions.chaika.board.open_single_click":false,
  171. "extensions.foxage2ch.openThreadInTab":true,
  172. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  173. "extensions.saveimageinfolder.general-fileprefixvalue":"%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  174. "extensions.saveimageinfolder.usecache":true,
  175. "extensions.tabutils.openTabNext":1,
  176. "extensions.tabutils.styles.current":"{\"bold\":false,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#EEEEEE\",\"bgColor\":true,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  177. "extensions.yass.edgetype":0,
  178. "extensions.yass.selectedpreset":"red",
  179. "font.default.x-western":"sans-serif",
  180. "general.warnOnAboutConfig":false,
  181. "keyword.URL":"http://www.bing.com/search?q=",
  182. "network.dns.disableIPv6":true,
  183. "refcontrol.actions":"@DEFAULT=@FORGE",
  184. "scrapbook.tabs.open":true
  185. }
  186. );
  187. display.showPopup("Keysnail", "My prefs done.");
  188. }, 'my setpref');
  189. ext.add('auto-install-plugins', function(ev, arg){
  190. var urls = [
  191. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  192. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  193. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  194. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  195. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  196. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  197. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  198. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  199. 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js',
  200. 'https://raw.github.com/gist/1450594/mstranslator.ks.js'
  201. ];
  202. function inst(a){
  203. if(a.length == 0){
  204. display.showPopup("auto-install-plugins", "All installation finished.");
  205. }else{
  206. var url = a.shift();
  207. var path = userscript.pluginDir + userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  208. if(plugins.context[path] === undefined){
  209. userscript.installPluginFromURL(url, function(){inst(a);});
  210. }else{
  211. inst(a);
  212. }
  213. }
  214. }
  215. inst(urls);
  216. }, 'Install plugins automatically if not installed yet.');
  217. ext.add('put-aside-this-page', function (ev, arg) {
  218. var n = gBrowser.mCurrentTab._tPos;
  219. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  220. if (n != 0) {
  221. gBrowser.selectedTab = gBrowser.mTabs[n];
  222. }
  223. }, 'put aside this page');
  224. ext.add('send-escape', function (ev, arg) {
  225. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  226. }, 'escape');
  227. ext.add("open-hatebu-comment", function (ev, arg) {
  228. if (window.loadURI) {
  229. loadURI("javascript:location.href='http://b.hatena.ne.jp/entry?mode=more&url='+escape(location.href);");
  230. }
  231. }, 'hatebu');
  232. ext.add("fullscreen-page",function (ev) {
  233. getBrowser().selectedTab = getBrowser().addTab("http://home.tiscali.nl/annejan/swf/timeline.swf");
  234. BrowserFullScreen();
  235. }, "fullscreen page");
  236. ext.add("focus-on-content", function(){
  237. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  238. gBrowser.focus();
  239. content.focus();
  240. }, "forcus on content");
  241. ext.add("hide-sidebar", function(){
  242. var sidebarBox = document.getElementById("sidebar-box");
  243. if (!sidebarBox.hidden) {
  244. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  245. }
  246. }, "hide-sidebar");
  247. ext.add("close-and-next-tab", function (ev, arg) {
  248. var n = gBrowser.mCurrentTab._tPos;
  249. BrowserCloseTabOrWindow();
  250. gBrowser.selectedTab = gBrowser.mTabs[n];
  251. }, "close and focus to next tab");
  252. /////////////////////////////////////
  253. // google itranslate
  254. // use mstranslator instead
  255. (function(){
  256. let targetLang = "ja"; // target lang to translate into
  257. let alternativeLang = "en"; // if given word is in targetLang, use this instead as a target lang
  258. function translate(word, target, next) {
  259. next("", "", " getting...");
  260. const base = "https://www.googleapis.com/language/translate/v2?key=%s&q=%s&target=%s";
  261. const apikey = "AIzaSyBq48p8NhFgaJ1DfUJ5ltbwLxeXpjEL86A";
  262. let ep = util.format(base, apikey, encodeURIComponent(word), target);
  263. util.httpGet(ep, false, function (res) {
  264. if (res.status === 200) {
  265. let json = decodeJSON(res.responseText);
  266. let srclang = json.data.translations[0].detectedSourceLanguage;
  267. if (target == srclang) {
  268. lookupword(word, alternativeLang);
  269. } else {
  270. let result = json.data.translations[0].translatedText;
  271. next(srclang, target, result);
  272. }
  273. } else {
  274. next("", "", "ERROR!");
  275. }
  276. });
  277. };
  278. function echo(srclang, from, tglang, to){
  279. display.echoStatusBar(srclang + " : " + from + " -> " + tglang + " : " + to);
  280. };
  281. function decodeJSON(json) {
  282. return util.safeEval("(" + json + ")");
  283. };
  284. function lookupword(word, target){
  285. translate(word, target, function (src, tg, translated) {
  286. echo(src, word, tg, translated);
  287. });
  288. };
  289. function read (aInitialInput) {
  290. let prevText = "";
  291. prompt.reader({
  292. message : "word or sentence to translate:",
  293. initialinput : aInitialInput,
  294. onChange: function (arg) {
  295. let word = arg.textbox.value;
  296. if (word !== prevText) {
  297. prevText = word;
  298. lookupword(word, targetLang);
  299. }
  300. },
  301. callback: function (s){},
  302. });
  303. };
  304. ext.add("google-itranslate",function(){read(content.document.getSelection() || "");},"google itranslate");
  305. })();
  306. //////////////////////////////////////
  307. //
  308. ext.add("restart-firefox-add-menu", function(){
  309. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  310. var cmdelm = document.createElementNS(XUL_NS, "command");
  311. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs")
  312. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  313. var commandset = document.getElementById("mainCommandSet");
  314. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  315. commandset.appendChild(cmdelm);
  316. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  317. menuelm.setAttribute("label", "Restart Firefox");
  318. menuelm.setAttribute("id", "my_menu_restartFirefoxKs")
  319. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  320. var menu = document.getElementById("menu_FilePopup");
  321. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  322. menu.appendChild(menuelm);
  323. }, "add restart firefox menu");
  324. //////////////////////////////////////
  325. // restart firefox
  326. // http://keysnail.g.hatena.ne.jp/Shinnya/20100723/1279878815
  327. ext.add("restart-firefox",function (ev) {
  328. const nsIAppStartup = Components.interfaces.nsIAppStartup;
  329. // Notify all windows that an application quit has been requested.
  330. var os = Components.classes["@mozilla.org/observer-service;1"]
  331. .getService(Components.interfaces.nsIObserverService);
  332. var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
  333. .createInstance(Components.interfaces.nsISupportsPRBool);
  334. os.notifyObservers(cancelQuit, "quit-application-requested", null);
  335. // Something aborted the quit process.
  336. if (cancelQuit.data)
  337. return;
  338. // Notify all windows that an application quit has been granted.
  339. os.notifyObservers(null, "quit-application-granted", null);
  340. // Enumerate all windows and call shutdown handlers
  341. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  342. .getService(Components.interfaces.nsIWindowMediator);
  343. var windows = wm.getEnumerator(null);
  344. while (windows.hasMoreElements()) {
  345. var win = windows.getNext();
  346. if (("tryToClose" in win) && !win.tryToClose())
  347. return;
  348. }
  349. Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
  350. .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
  351. }, "restart firefox");
  352. /////////////////////////////////////////
  353. // copy feed url
  354. ext.add("copy-url", function () {
  355. const doc = content.document;
  356. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  357. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  358. 'link[type="application/atom+xml"]'])))];
  359. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  360. for (i = 0; i < feeds.length; i++)
  361. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  362. feeds.unshift([window.content.document.title,window.content.location.href]);
  363. prompt.selector(
  364. {
  365. message : "Select Feed",
  366. collection : feeds,
  367. callback : function (i) {
  368. if (i >= 0)
  369. command.setClipboardText(feeds[i][1]);
  370. }
  371. }
  372. );
  373. }, "Copy url or feed url of current page");
  374. ///////////////////////////////////////
  375. // 評価しちゃうっぽい とりあえずこんな感じで
  376. ext.add("keysnail-setting-menu",function(){
  377. var settingmenulist = [["keysnail setting dialogue", function(){return function(){KeySnail.openPreference();};}],
  378. ["keysnail plugin manager", function(){return function(){userscript.openPluginManager();}}],
  379. ["firefox addon manager", function(){return function(){BrowserOpenAddonsMgr();};}],
  380. ["reload .keysnail.js", function(){return function() {userscript.reload();};}],
  381. // ["check for plugins update", function(){return function(){ext.exec("check-for-plugins-update");};}],
  382. ["restart firefox", function(){return function(){ext.exec("restart-firefox");};}],
  383. ];
  384. prompt.selector(
  385. {
  386. message : "open setting dialog",
  387. collection : settingmenulist,
  388. callback : function (i) { settingmenulist[i][1]()(); },
  389. });
  390. },"open keysnail setting menu");
  391. ////////////////////////
  392. //マルチプルタブハンドラ
  393. ext.add("multiple-tab-handler-close-selected-and-current-tabs", function () {
  394. BrowserCloseTabOrWindow();
  395. // if (MultipleTabService) {
  396. // //BrowserCloseTabOrWindow();
  397. // //MultipleTabService.setSelection(gBrowser.mCurrentTab, true);
  398. MultipleTabService.closeTabs(MultipleTabService.getSelectedTabs());
  399. // } else {
  400. // BrowserCloseTabOrWindow();}
  401. }, '選択タブと現在のタブを閉じる');
  402. ext.add("if-mth-exist", function() {
  403. if (MultipleTabService === undefined) display.echoStatusBar("mth not exist.");
  404. },'if mth exist');
  405. // search web
  406. ext.add("query-then-engine", function () {
  407. prompt.reader({message : "Search Word?:",
  408. callback : function (q) {
  409. if (q) {
  410. prompt.selector({ message : "search \"" + q + "\" with?",
  411. collection : plugins.options["search-url-list"],
  412. width : [20,80],
  413. callback : function (i) { getBrowser().selectedTab = getBrowser().addTab(plugins.options["search-url-list"][i][1].replace("%r",q).replace("%q",encodeURIComponent(q))); },
  414. });
  415. };
  416. },
  417. initialInput : content.document.getSelection() || "",
  418. });
  419. }, "enter search word and then select engine");
  420. /////////////////////////////////////
  421. // 閉じたタブリスト
  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("最近閉じたタブが見つかりませんでした", 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 = "<delete>";
  483. key.helpKey = "C-h";
  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('KeySnailInitialized', function () {
  494. ext.exec("shiitake-enable-style");
  495. });
  496. hook.setHook('KeyBoardQuit', function (aEvent) {
  497. ext.exec("hide-sidebar");
  498. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  499. gBrowser.focus();
  500. content.focus();
  501. command.closeFindBar();
  502. if (util.isCaretEnabled()) {
  503. command.resetMark(aEvent);
  504. } else {
  505. goDoCommand("cmd_selectNone");
  506. }
  507. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  508. });
  509. hook.setHook('Unload', function () {
  510. util.getBrowserWindows().some(function (win) {
  511. if (win === window) {
  512. return false;
  513. }
  514. const ks = win.KeySnail;
  515. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  516. ks.setUpPluginUpdaterDelegator();
  517. return true;
  518. });
  519. });
  520. // ============================= Key bindings ============================== //
  521. key.setGlobalKey('C-<right>', function () {
  522. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  523. }, 'ひとつ右のタブへ');
  524. key.setGlobalKey('C-<left>', function () {
  525. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  526. }, 'ひとつ左のタブへ');
  527. key.setGlobalKey('C-<up>', function () {
  528. var browser = getBrowser();
  529. if (browser.mCurrentTab.previousSibling) {
  530. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  531. } else {
  532. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  533. }
  534. }, '選択中のタブを右へ');
  535. key.setGlobalKey('C-<down>', function () {
  536. var browser = getBrowser();
  537. if (browser.mCurrentTab.nextSibling) {
  538. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  539. } else {
  540. browser.moveTabTo(browser.mCurrentTab, 0);
  541. }
  542. }, '選択中のタブを左へ');
  543. key.setGlobalKey('M-:', function (ev) {
  544. command.interpreter();
  545. }, 'JavaScript のコードを評価');
  546. key.setViewKey('D', function (ev, arg) {
  547. ext.exec("dig-url", arg, ev);
  548. }, 'dig url with selector', true);
  549. key.setViewKey('x', function (aEvent, aArg) {
  550. ext.select(aArg, aEvent);
  551. }, 'エクステ一覧');
  552. key.setViewKey(['t', 'm'], function (ev, arg) {
  553. if (window.loadURI) {
  554. loadURI("javascript:window.location='http://api.tweetmeme.com/visit?url='+window.location;");
  555. }
  556. }, 'open with tweetmeme');
  557. key.setViewKey(['t', 'w'], function (ev, arg) {
  558. ext.exec("twitter-client-tweet", arg, ev);
  559. }, 'つぶやく', true);
  560. key.setViewKey(['t', 'p'], function (ev, arg) {
  561. ext.exec("twitter-client-tweet-this-page", arg, ev);
  562. }, 'このページのタイトルと URL を使ってつぶやく', true);
  563. key.setViewKey('u', function () {
  564. undoCloseTab();
  565. }, '閉じたタブを元に戻す');
  566. key.setViewKey('g', function () {
  567. goDoCommand("cmd_scrollTop");
  568. }, 'ページ先頭へ移動');
  569. key.setViewKey('G', function () {
  570. goDoCommand("cmd_scrollBottom");
  571. }, 'ページ末尾へ移動');
  572. key.setViewKey('r', function (aEvent) {
  573. BrowserReload();
  574. }, '再読み込み');
  575. key.setViewKey('m', function (ev, arg) {
  576. _fi.toogle();
  577. }, 'fetchimiをトグル');
  578. key.setViewKey('d', function (ev, arg) {
  579. if (window.loadURI) {
  580. 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()}})()");
  581. }
  582. }, 'deliciousでブックマーク');
  583. key.setViewKey('p', function (ev, arg) {
  584. if (window.loadURI) {
  585. 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{}");
  586. }
  587. }, 'posterousに投稿');
  588. key.setViewKey('SPC', function (ev, arg) {
  589. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  590. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  591. }, 'タブの選択をトグルして次のタブ');
  592. key.setViewKey('S-SPC', function (ev, arg) {
  593. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  594. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  595. }, 'タブの選択をトグルして前のタブ');
  596. key.setViewKey('z', function (ev, arg) {
  597. ext.exec("keysnail-setting-menu", arg, ev);
  598. }, 'open keysnail setting menu', true);
  599. key.setViewKey('C-SPC', function (ev, arg) {
  600. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  601. }, 'タブの選択をトグル');
  602. key.setViewKey('U', function (ev, arg) {
  603. ext.exec("list-closed-tabs", arg, ev);
  604. }, 'List closed tabs', true);
  605. key.setViewKey('e', function () {
  606. command.focusElement(command.elementsRetrieverTextarea, 0);
  607. }, '最初のインプットエリアへフォーカス', true);
  608. key.setViewKey('S', function (ev, arg) {
  609. if (window.loadURI) {
  610. 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{}");
  611. }
  612. }, 'google reader share');
  613. key.setViewKey('!', function (ev, arg) {
  614. shell.input();
  615. }, 'Command system');
  616. key.setViewKey('b', function (ev, arg) {
  617. BarTap.putOnTap(gBrowser.mCurrentTab, gBrowser);
  618. }, 'bartab put on tab');
  619. key.setViewKey('R', function () {
  620. BrowserReloadSkipCache();
  621. }, '更新(キャッシュを無視)');
  622. key.setViewKey('<backspace>', function () {
  623. BrowserBack();
  624. }, '戻る');
  625. key.setViewKey('S-<backspace>', function () {
  626. BrowserForward();
  627. }, '進む');
  628. key.setViewKey('q', function (ev, arg) {
  629. ext.exec("query-then-engine", arg, ev);
  630. }, 'enter search word and then select engine', true);
  631. key.setViewKey('/', function () {
  632. command.iSearchForward();
  633. }, 'インクリメンタル検索', true);
  634. key.setViewKey('?', function (ev) {
  635. command.iSearchForwardKs(ev);
  636. }, 'Emacs ライクなインクリメンタル検索', true);
  637. key.setViewKey('a', function (ev, arg) {
  638. allTabs.open();
  639. }, 'alltabs.open');
  640. key.setViewKey('<left>', function (ev) {
  641. goDoCommand("cmd_scrollPageUp");
  642. }, '一画面分スクロールアップ');
  643. key.setViewKey('<right>', function (ev) {
  644. goDoCommand("cmd_scrollPageDown");
  645. }, '一画面スクロールダウン');
  646. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  647. return;
  648. }, 'ignore');
  649. key.setViewKey(':', function (ev, arg) {
  650. return !document.getElementById("keysnail-prompt").hidden &&
  651. document.getElementById("keysnail-prompt-textbox").focus();
  652. }, 'KeySnail のプロンプトへフォーカス', true);
  653. key.setViewKey('H', function (ev, arg) {
  654. ext.exec("open-hatebu-comment", arg, ev);
  655. }, 'hatebu', true);
  656. key.setViewKey('l', function (ev) {
  657. command.focusToById("urlbar");
  658. }, 'ロケーションバーへフォーカス', true);
  659. key.setViewKey('0', function (ev) {
  660. BrowserCloseTabOrWindow();
  661. }, 'タブ / ウィンドウを閉じる');
  662. key.setViewKey('C', function (ev, arg) {
  663. ext.exec("linksnail", arg, ev);
  664. }, 'LinkSnail', true);
  665. key.setViewKey('C-<backspace>', function (ev, arg) {
  666. ext.exec("list-tab-history", arg, ev);
  667. }, 'List tab history', true);
  668. key.setViewKey('I', function (ev, arg) {
  669. ext.exec("instapaper-post-page-with-comment", arg, ev);
  670. }, 'post page and comment', true);
  671. key.setEditKey('C-<tab>', function (ev) {
  672. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  673. }, '次のテキストエリアへフォーカス');
  674. key.setViewKey('T', function (ev, arg) {
  675. ext.exec('mstranslator-open-prompt', arg, ev);
  676. }, 'MSTranslator - Open prompt', true);