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.
 
 
 
 
 
 

781 rinda
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\":\"#EEEEEE\",\"bgColor\":true,\"bgColorCode\":\"#000000\",\"outline\":true,\"outlineColorCode\":\"#000000\"}",
  169. "extensions.yass.edgetype":0,
  170. "extensions.yass.selectedpreset":"red",
  171. "font.default.x-western":"sans-serif",
  172. "general.warnOnAboutConfig":false,
  173. "keyword.URL":"http://www.bing.com/search?q=",
  174. "network.dns.disableIPv6":true,
  175. "refcontrol.actions":"@DEFAULT=@FORGE",
  176. "scrapbook.tabs.open":true
  177. }
  178. );
  179. display.showPopup("Keysnail", "My prefs done.");
  180. }, 'my setpref');
  181. ext.add('auto-install-plugins', function(ev, arg){
  182. var urls = [
  183. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  184. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  185. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  186. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  187. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  188. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  189. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  190. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  191. 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js'
  192. ];
  193. function inst(a){
  194. if(a.length == 0){
  195. display.showPopup("auto-install-plugins", "All installation finished.");
  196. }else{
  197. var url = a.shift();
  198. var path = userscript.pluginDir + userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  199. if(plugins.context[path] === undefined){
  200. userscript.installPluginFromURL(url, function(){inst(a);});
  201. }else{
  202. inst(a);
  203. }
  204. }
  205. }
  206. inst(urls);
  207. }, 'Install plugins automatically if not installed yet.');
  208. ext.add('put-aside-this-page', function (ev, arg) {
  209. var n = gBrowser.mCurrentTab._tPos;
  210. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  211. if (n != 0) {
  212. gBrowser.selectedTab = gBrowser.mTabs[n];
  213. }
  214. }, 'put aside this page');
  215. ext.add('send-escape', function (ev, arg) {
  216. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  217. }, 'escape');
  218. ext.add("open-hatebu-comment", function (ev, arg) {
  219. if (window.loadURI) {
  220. loadURI("javascript:location.href='http://b.hatena.ne.jp/entry?mode=more&url='+escape(location.href);");
  221. }
  222. }, 'hatebu');
  223. ext.add("fullscreen-page",function (ev) {
  224. getBrowser().selectedTab = getBrowser().addTab("http://home.tiscali.nl/annejan/swf/timeline.swf");
  225. BrowserFullScreen();
  226. }, "fullscreen page");
  227. ext.add("focus-on-content", function(){
  228. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  229. gBrowser.focus();
  230. content.focus();
  231. }, "forcus on content");
  232. ext.add("hide-sidebar", function(){
  233. var sidebarBox = document.getElementById("sidebar-box");
  234. if (!sidebarBox.hidden) {
  235. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  236. }
  237. }, "hide-sidebar");
  238. ext.add("close-and-next-tab", function (ev, arg) {
  239. var n = gBrowser.mCurrentTab._tPos;
  240. BrowserCloseTabOrWindow();
  241. gBrowser.selectedTab = gBrowser.mTabs[n];
  242. }, "close and focus to next tab");
  243. /////////////////////////////////////
  244. // google itranslate
  245. (function(){
  246. let targetLang = "ja"; // target lang to translate into
  247. let alternativeLang = "en"; // if given word is in targetLang, use this instead as a target lang
  248. function translate(word, target, next) {
  249. next("", "", " getting...");
  250. const base = "https://www.googleapis.com/language/translate/v2?key=%s&q=%s&target=%s";
  251. const apikey = "AIzaSyBq48p8NhFgaJ1DfUJ5ltbwLxeXpjEL86A";
  252. let ep = util.format(base, apikey, encodeURIComponent(word), target);
  253. util.httpGet(ep, false, function (res) {
  254. if (res.status === 200) {
  255. let json = decodeJSON(res.responseText);
  256. let srclang = json.data.translations[0].detectedSourceLanguage;
  257. if (target == srclang) {
  258. lookupword(word, alternativeLang);
  259. } else {
  260. let result = json.data.translations[0].translatedText;
  261. next(srclang, target, result);
  262. }
  263. } else {
  264. next("", "", "ERROR!");
  265. }
  266. });
  267. };
  268. function echo(srclang, from, tglang, to){
  269. display.echoStatusBar(srclang + " : " + from + " -> " + tglang + " : " + to);
  270. };
  271. function decodeJSON(json) {
  272. return util.safeEval("(" + json + ")");
  273. };
  274. function lookupword(word, target){
  275. translate(word, target, function (src, tg, translated) {
  276. echo(src, word, tg, translated);
  277. });
  278. };
  279. function read (aInitialInput) {
  280. let prevText = "";
  281. prompt.reader({
  282. message : "word or sentence to translate:",
  283. initialinput : aInitialInput,
  284. onChange: function (arg) {
  285. let word = arg.textbox.value;
  286. if (word !== prevText) {
  287. prevText = word;
  288. lookupword(word, targetLang);
  289. }
  290. },
  291. callback: function (s){},
  292. });
  293. };
  294. ext.add("google-itranslate",function(){read(content.document.getSelection() || "");},"google itranslate");
  295. })();
  296. //////////////////////////////////////
  297. //
  298. ext.add("restart-firefox-add-menu", function(){
  299. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  300. var cmdelm = document.createElementNS(XUL_NS, "command");
  301. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs")
  302. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  303. var commandset = document.getElementById("mainCommandSet");
  304. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  305. commandset.appendChild(cmdelm);
  306. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  307. menuelm.setAttribute("label", "Restart Firefox");
  308. menuelm.setAttribute("id", "my_menu_restartFirefoxKs")
  309. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  310. var menu = document.getElementById("menu_FilePopup");
  311. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  312. menu.appendChild(menuelm);
  313. }, "add restart firefox menu");
  314. //////////////////////////////////////
  315. // restart firefox
  316. // http://keysnail.g.hatena.ne.jp/Shinnya/20100723/1279878815
  317. ext.add("restart-firefox",function (ev) {
  318. const nsIAppStartup = Components.interfaces.nsIAppStartup;
  319. // Notify all windows that an application quit has been requested.
  320. var os = Components.classes["@mozilla.org/observer-service;1"]
  321. .getService(Components.interfaces.nsIObserverService);
  322. var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
  323. .createInstance(Components.interfaces.nsISupportsPRBool);
  324. os.notifyObservers(cancelQuit, "quit-application-requested", null);
  325. // Something aborted the quit process.
  326. if (cancelQuit.data)
  327. return;
  328. // Notify all windows that an application quit has been granted.
  329. os.notifyObservers(null, "quit-application-granted", null);
  330. // Enumerate all windows and call shutdown handlers
  331. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  332. .getService(Components.interfaces.nsIWindowMediator);
  333. var windows = wm.getEnumerator(null);
  334. while (windows.hasMoreElements()) {
  335. var win = windows.getNext();
  336. if (("tryToClose" in win) && !win.tryToClose())
  337. return;
  338. }
  339. Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
  340. .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
  341. }, "restart firefox");
  342. /////////////////////////////////////////
  343. // copy feed url
  344. ext.add("copy-url", function () {
  345. const doc = content.document;
  346. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  347. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  348. 'link[type="application/atom+xml"]'])))];
  349. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  350. for (i = 0; i < feeds.length; i++)
  351. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  352. feeds.unshift([window.content.document.title,window.content.location.href]);
  353. prompt.selector(
  354. {
  355. message : "Select Feed",
  356. collection : feeds,
  357. callback : function (i) {
  358. if (i >= 0)
  359. command.setClipboardText(feeds[i][1]);
  360. }
  361. }
  362. );
  363. }, "Copy url or feed url of current page");
  364. ///////////////////////////////////////
  365. // 評価しちゃうっぽい とりあえずこんな感じで
  366. ext.add("keysnail-setting-menu",function(){
  367. var settingmenulist = [["keysnail setting dialogue", function(){return function(){KeySnail.openPreference();};}],
  368. ["keysnail plugin manager", function(){return function(){userscript.openPluginManager();}}],
  369. ["firefox addon manager", function(){return function(){BrowserOpenAddonsMgr();};}],
  370. ["reload .keysnail.js", function(){return function() {userscript.reload();};}],
  371. // ["check for plugins update", function(){return function(){ext.exec("check-for-plugins-update");};}],
  372. ["restart firefox", function(){return function(){ext.exec("restart-firefox");};}],
  373. ];
  374. prompt.selector(
  375. {
  376. message : "open setting dialog",
  377. collection : settingmenulist,
  378. callback : function (i) { settingmenulist[i][1]()(); },
  379. });
  380. },"open keysnail setting menu");
  381. ////////////////////////
  382. //マルチプルタブハンドラ
  383. ext.add("multiple-tab-handler-close-selected-and-current-tabs", function () {
  384. BrowserCloseTabOrWindow();
  385. // if (MultipleTabService) {
  386. // //BrowserCloseTabOrWindow();
  387. // //MultipleTabService.setSelection(gBrowser.mCurrentTab, true);
  388. MultipleTabService.closeTabs(MultipleTabService.getSelectedTabs());
  389. // } else {
  390. // BrowserCloseTabOrWindow();}
  391. }, '選択タブと現在のタブを閉じる');
  392. ext.add("if-mth-exist", function() {
  393. if (MultipleTabService === undefined) display.echoStatusBar("mth not exist.");
  394. },'if mth exist');
  395. // search web
  396. ext.add("query-then-engine", function () {
  397. prompt.reader({message : "Search Word?:",
  398. callback : function (q) {
  399. if (q) {
  400. prompt.selector({ message : "search \"" + q + "\" with?",
  401. collection : plugins.options["search-url-list"],
  402. width : [20,80],
  403. callback : function (i) { getBrowser().selectedTab = getBrowser().addTab(plugins.options["search-url-list"][i][1].replace("%r",q).replace("%q",encodeURIComponent(q))); },
  404. });
  405. };
  406. },
  407. initialInput : content.document.getSelection() || "",
  408. });
  409. }, "enter search word and then select engine");
  410. /////////////////////////////////////
  411. // 閉じたタブリスト
  412. ext.add("list-closed-tabs", function () {
  413. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  414. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  415. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  416. var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  417. if (!closedTabs.length)
  418. return void display.echoStatusBar("最近閉じたタブが見つかりませんでした", 2000);
  419. prompt.selector(
  420. {
  421. message : "select tab to undo:",
  422. collection : closedTabs,
  423. flags : [ICON | IGNORE, 0, 0],
  424. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  425. });
  426. }, "List closed tabs");
  427. ext.add("echo-closed-tabs", function () {
  428. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  429. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  430. // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  431. var lasttab = json.decode(ss.getClosedTabData(window))[0];
  432. dump = ""
  433. for (var i in lasttab) { dump += lasttab[i] + "\n"; }
  434. confirm(dump);
  435. }, "List closed tabs");
  436. ///////////////////////////////
  437. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  438. ext.add("list-tab-history", function () {
  439. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  440. var tabHistory = [];
  441. var sessionHistory = gBrowser.webNavigation.sessionHistory;
  442. if (sessionHistory.count < 1)
  443. return void display.echoStatusBar("Tab history not exist", 2000);
  444. var curIdx = sessionHistory.index;
  445. for (var i = 0; i < sessionHistory.count; i++) {
  446. var entry = sessionHistory.getEntryAtIndex(i, false);
  447. if (!entry)
  448. continue;
  449. try {
  450. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  451. .getService(Ci.nsIFaviconService)
  452. .getFaviconForPage(entry.URI).spec;
  453. } catch (ex) {}
  454. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  455. }
  456. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  457. if (tabHistory[thIdx][3] == curIdx) break;
  458. }
  459. prompt.selector(
  460. {
  461. message : "select history in tab",
  462. collection : tabHistory,
  463. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  464. header : ["Title", "URL"],
  465. initialIndex : thIdx,
  466. callback : function(i) { if (i >= 0) gBrowser.webNavigation.gotoIndex(tabHistory[i][3]); }
  467. });
  468. }, 'List tab history');
  469. //}}%PRESERVE%
  470. // ========================================================================= //
  471. // ========================= Special key settings ========================== //
  472. key.quitKey = "<delete>";
  473. key.helpKey = "C-h";
  474. key.escapeKey = "C-q";
  475. key.macroStartKey = "";
  476. key.macroEndKey = "";
  477. key.universalArgumentKey = "C-u";
  478. key.negativeArgument1Key = "C--";
  479. key.negativeArgument2Key = "C-M--";
  480. key.negativeArgument3Key = "M--";
  481. key.suspendKey = "Not defined";
  482. // ================================= Hooks ================================= //
  483. hook.addToHook('KeySnailInitialized', function () {
  484. ext.exec("shiitake-enable-style");
  485. });
  486. hook.addToHook('KeyBoardQuit', function (aEvent) {
  487. ext.exec("hide-sidebar");
  488. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  489. gBrowser.focus();
  490. content.focus();
  491. command.closeFindBar();
  492. if (util.isCaretEnabled()) {
  493. command.resetMark(aEvent);
  494. } else {
  495. goDoCommand("cmd_selectNone");
  496. }
  497. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  498. });
  499. hook.setHook('Unload', function () {
  500. util.getBrowserWindows().some(function (win) {
  501. if (win === window) {
  502. return false;
  503. }
  504. const ks = win.KeySnail;
  505. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  506. ks.setUpPluginUpdaterDelegator();
  507. return true;
  508. });
  509. });
  510. // hook.addToHook('LocationChange', function (aNsURI) {
  511. // if(window.content.document.body){
  512. // display.prettyPrint(window.content.document.title);
  513. // }else{
  514. // window.addEventListener("load", function(){
  515. // disp = display;
  516. // disp.prettyPrint(window.content.document.title);
  517. // }, false);
  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('T', function (ev, arg) {
  600. ext.exec("google-itranslate", arg, ev);
  601. }, 'google itranslate', true);
  602. key.setViewKey('C-SPC', function (ev, arg) {
  603. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  604. }, 'タブの選択をトグル');
  605. key.setViewKey('U', function (ev, arg) {
  606. ext.exec("list-closed-tabs", arg, ev);
  607. }, 'List closed tabs', true);
  608. key.setViewKey('e', function () {
  609. command.focusElement(command.elementsRetrieverTextarea, 0);
  610. }, '最初のインプットエリアへフォーカス', true);
  611. key.setViewKey('S', function (ev, arg) {
  612. if (window.loadURI) {
  613. 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{}");
  614. }
  615. }, 'google reader share');
  616. key.setViewKey('!', function (ev, arg) {
  617. shell.input();
  618. }, 'Command system');
  619. key.setViewKey('b', function (ev, arg) {
  620. BarTap.putOnTap(gBrowser.mCurrentTab, gBrowser);
  621. }, 'bartab put on tab');
  622. key.setViewKey('R', function () {
  623. BrowserReloadSkipCache();
  624. }, '更新(キャッシュを無視)');
  625. key.setViewKey('<backspace>', function () {
  626. BrowserBack();
  627. }, '戻る');
  628. key.setViewKey('S-<backspace>', function () {
  629. BrowserForward();
  630. }, '進む');
  631. key.setViewKey('q', function (ev, arg) {
  632. ext.exec("query-then-engine", arg, ev);
  633. }, 'enter search word and then select engine', true);
  634. key.setViewKey('/', function () {
  635. command.iSearchForward();
  636. }, 'インクリメンタル検索', true);
  637. key.setViewKey('?', function (ev) {
  638. command.iSearchForwardKs(ev);
  639. }, 'Emacs ライクなインクリメンタル検索', true);
  640. key.setViewKey('a', function (ev, arg) {
  641. allTabs.open();
  642. }, 'alltabs.open');
  643. key.setViewKey('<left>', function (ev) {
  644. goDoCommand("cmd_scrollPageUp");
  645. }, '一画面分スクロールアップ');
  646. key.setViewKey('<right>', function (ev) {
  647. goDoCommand("cmd_scrollPageDown");
  648. }, '一画面スクロールダウン');
  649. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  650. return;
  651. }, 'ignore');
  652. key.setViewKey(':', function (ev, arg) {
  653. return !document.getElementById("keysnail-prompt").hidden && document.getElementById("keysnail-prompt-textbox").focus();
  654. }, 'KeySnail のプロンプトへフォーカス', true);
  655. key.setViewKey('H', function (ev, arg) {
  656. ext.exec("open-hatebu-comment", arg, ev);
  657. }, 'hatebu', true);
  658. key.setViewKey('l', function (ev) {
  659. command.focusToById("urlbar");
  660. }, 'ロケーションバーへフォーカス', true);
  661. key.setViewKey('0', function (ev) {
  662. BrowserCloseTabOrWindow();
  663. }, 'タブ / ウィンドウを閉じる');
  664. key.setViewKey('C', function (ev, arg) {
  665. ext.exec("linksnail", arg, ev);
  666. }, 'LinkSnail', true);
  667. key.setViewKey('C-<backspace>', function (ev, arg) {
  668. ext.exec("list-tab-history", arg, ev);
  669. }, 'List tab history', true);
  670. key.setEditKey('C-<tab>', function (ev) {
  671. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  672. }, '次のテキストエリアへフォーカス');
  673. key.setViewKey('I', function (ev, arg) {
  674. ext.exec('instapaper-post-page-with-comment', arg, ev);
  675. }, 'post page and comment', true);
  676. key.setViewKey('C-<backspace>', function (ev, arg) {
  677. ext.exec('list-tab-history', arg, ev);
  678. }, 'List tab history', true);