You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

774 lines
31 KiB

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