Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

772 рядки
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/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  203. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  204. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  205. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  206. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  207. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  208. 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js',
  209. 'https://raw.github.com/gist/1450594/mstranslator.ks.js'
  210. ];
  211. function inst(a){
  212. if(a.length == 0){
  213. display.showPopup("auto-install-plugins", "All installation finished.");
  214. }else{
  215. var url = a.shift();
  216. var path = userscript.pluginDir + userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  217. if(plugins.context[path] === undefined){
  218. userscript.installPluginFromURL(url, function(){inst(a);});
  219. }else{
  220. inst(a);
  221. }
  222. }
  223. }
  224. inst(urls);
  225. }, 'Install plugins automatically if not installed yet.');
  226. ext.add('put-aside-this-page', function (ev, arg) {
  227. var n = gBrowser.mCurrentTab._tPos;
  228. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  229. if (n != 0) {
  230. gBrowser.selectedTab = gBrowser.mTabs[n];
  231. }
  232. }, 'put aside this page');
  233. ext.add('send-escape', function (ev, arg) {
  234. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  235. }, 'escape');
  236. ext.add("open-hatebu-comment", function (ev, arg) {
  237. if (window.loadURI) {
  238. loadURI("javascript:location.href='http://b.hatena.ne.jp/entry?mode=more&url='+escape(location.href);");
  239. }
  240. }, 'hatebu');
  241. ext.add("fullscreen-page",function (ev) {
  242. getBrowser().selectedTab = getBrowser().addTab("http://home.tiscali.nl/annejan/swf/timeline.swf");
  243. BrowserFullScreen();
  244. }, "fullscreen page");
  245. ext.add("focus-on-content", function(){
  246. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  247. gBrowser.focus();
  248. content.focus();
  249. }, "forcus on content");
  250. ext.add("hide-sidebar", function(){
  251. var sidebarBox = document.getElementById("sidebar-box");
  252. if (!sidebarBox.hidden) {
  253. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  254. }
  255. }, "hide-sidebar");
  256. ext.add("close-and-next-tab", function (ev, arg) {
  257. var n = gBrowser.mCurrentTab._tPos;
  258. BrowserCloseTabOrWindow();
  259. gBrowser.selectedTab = gBrowser.mTabs[n];
  260. }, "close and focus to next tab");
  261. //////////////////////////////////////
  262. //
  263. ext.add("restart-firefox-add-menu", function(){
  264. const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  265. var cmdelm = document.createElementNS(XUL_NS, "command");
  266. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs")
  267. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  268. var commandset = document.getElementById("mainCommandSet");
  269. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  270. commandset.appendChild(cmdelm);
  271. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  272. menuelm.setAttribute("label", "Restart Firefox");
  273. menuelm.setAttribute("id", "my_menu_restartFirefoxKs")
  274. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  275. var menu = document.getElementById("menu_FilePopup");
  276. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  277. menu.appendChild(menuelm);
  278. }, "add restart firefox menu");
  279. //////////////////////////////////////
  280. // restart firefox
  281. // http://keysnail.g.hatena.ne.jp/Shinnya/20100723/1279878815
  282. ext.add("restart-firefox",function (ev) {
  283. const nsIAppStartup = Components.interfaces.nsIAppStartup;
  284. // Notify all windows that an application quit has been requested.
  285. var os = Components.classes["@mozilla.org/observer-service;1"]
  286. .getService(Components.interfaces.nsIObserverService);
  287. var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
  288. .createInstance(Components.interfaces.nsISupportsPRBool);
  289. os.notifyObservers(cancelQuit, "quit-application-requested", null);
  290. // Something aborted the quit process.
  291. if (cancelQuit.data)
  292. return;
  293. // Notify all windows that an application quit has been granted.
  294. os.notifyObservers(null, "quit-application-granted", null);
  295. // Enumerate all windows and call shutdown handlers
  296. var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  297. .getService(Components.interfaces.nsIWindowMediator);
  298. var windows = wm.getEnumerator(null);
  299. while (windows.hasMoreElements()) {
  300. var win = windows.getNext();
  301. if (("tryToClose" in win) && !win.tryToClose())
  302. return;
  303. }
  304. Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
  305. .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
  306. }, "restart firefox");
  307. /////////////////////////////////////////
  308. // copy feed url
  309. ext.add("copy-url", function () {
  310. const doc = content.document;
  311. let feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  312. for ([, e] in Iterator(doc.querySelectorAll(['link[type="application/rss+xml"]',
  313. 'link[type="application/atom+xml"]'])))];
  314. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,"$1");
  315. for (i = 0; i < feeds.length; i++)
  316. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  317. feeds.unshift([window.content.document.title,window.content.location.href]);
  318. prompt.selector(
  319. {
  320. message : "Select Feed",
  321. collection : feeds,
  322. callback : function (i) {
  323. if (i >= 0)
  324. command.setClipboardText(feeds[i][1]);
  325. }
  326. }
  327. );
  328. }, "Copy url or feed url of current page");
  329. ///////////////////////////////////////
  330. // keysnail z menu
  331. ext.add("keysnail-setting-menu",function(){
  332. var settingmenulist = [["keysnail setting dialogue", function(){return function(){KeySnail.openPreference();};}],
  333. ["keysnail plugin manager", function(){return function(){userscript.openPluginManager();};}],
  334. ["firefox addon manager", function(){return function(){BrowserOpenAddonsMgr();};}],
  335. ["reload .keysnail.js", function(){return function() {userscript.reload();};}],
  336. // ["check for plugins update", function(){return function(){ext.exec("check-for-plugins-update");};}],
  337. ["restart firefox", function(){return function(){ext.exec("restart-firefox");};}]
  338. ];
  339. prompt.selector(
  340. {
  341. message : "open setting dialog",
  342. collection : settingmenulist,
  343. callback : function (i) { settingmenulist[i][1]()(); }
  344. });
  345. },"open keysnail setting menu");
  346. ////////////////////////
  347. // multiple tab handler
  348. ext.add("multiple-tab-handler-close-selected-and-current-tabs", function () {
  349. BrowserCloseTabOrWindow();
  350. // if (MultipleTabService) {
  351. // //BrowserCloseTabOrWindow();
  352. // //MultipleTabService.setSelection(gBrowser.mCurrentTab, true);
  353. MultipleTabService.closeTabs(MultipleTabService.getSelectedTabs());
  354. // } else {
  355. // BrowserCloseTabOrWindow();}
  356. }, '選択タブと現在のタブを閉じる');
  357. ext.add("if-mth-exist", function() {
  358. if (MultipleTabService === undefined) display.echoStatusBar("mth not exist.");
  359. },'if mth exist');
  360. // search web
  361. ext.add("query-then-engine", function () {
  362. prompt.reader({message : "Search Word?:",
  363. callback : function (q) {
  364. if (q) {
  365. prompt.selector({ message : "search \"" + q + "\" with?",
  366. collection : plugins.options["search-url-list"],
  367. width : [20,80],
  368. callback : function (i) { getBrowser().selectedTab = getBrowser().addTab(plugins.options["search-url-list"][i][1].replace("%r",q).replace("%q",encodeURIComponent(q))); },
  369. });
  370. };
  371. },
  372. initialInput : content.document.getSelection() || "",
  373. });
  374. }, "enter search word and then select engine");
  375. /////////////////////////////////////
  376. // closed tab list
  377. ext.add("list-closed-tabs", function () {
  378. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  379. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  380. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  381. var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  382. if (!closedTabs.length)
  383. return void display.echoStatusBar("最近閉じたタブが見つかりませんでした", 2000);
  384. prompt.selector(
  385. {
  386. message : "select tab to undo:",
  387. collection : closedTabs,
  388. flags : [ICON | IGNORE, 0, 0],
  389. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  390. });
  391. }, "List closed tabs");
  392. ext.add("echo-closed-tabs", function () {
  393. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
  394. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  395. // var closedTabs = [[tab.image || fav, tab.title, tab.url] for each (tab in json.decode(ss.getClosedTabData(window)))];
  396. var lasttab = json.decode(ss.getClosedTabData(window))[0];
  397. dump = ""
  398. for (var i in lasttab) { dump += lasttab[i] + "\n"; }
  399. confirm(dump);
  400. }, "List closed tabs");
  401. ///////////////////////////////
  402. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  403. ext.add("list-tab-history", function () {
  404. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  405. var tabHistory = [];
  406. var sessionHistory = gBrowser.webNavigation.sessionHistory;
  407. if (sessionHistory.count < 1)
  408. return void display.echoStatusBar("Tab history not exist", 2000);
  409. var curIdx = sessionHistory.index;
  410. for (var i = 0; i < sessionHistory.count; i++) {
  411. var entry = sessionHistory.getEntryAtIndex(i, false);
  412. if (!entry)
  413. continue;
  414. try {
  415. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  416. .getService(Ci.nsIFaviconService)
  417. .getFaviconForPage(entry.URI).spec;
  418. } catch (ex) {}
  419. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  420. }
  421. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  422. if (tabHistory[thIdx][3] == curIdx) break;
  423. }
  424. prompt.selector(
  425. {
  426. message : "select history in tab",
  427. collection : tabHistory,
  428. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  429. header : ["Title", "URL"],
  430. initialIndex : thIdx,
  431. callback : function(i) { if (i >= 0) gBrowser.webNavigation.gotoIndex(tabHistory[i][3]); }
  432. });
  433. }, 'List tab history');
  434. //}}%PRESERVE%
  435. // ========================================================================= //
  436. // ========================= Special key settings ========================== //
  437. key.quitKey = "ESC";
  438. key.helpKey = "<f1>";
  439. key.escapeKey = "C-q";
  440. key.macroStartKey = "";
  441. key.macroEndKey = "";
  442. key.universalArgumentKey = "C-u";
  443. key.negativeArgument1Key = "C--";
  444. key.negativeArgument2Key = "C-M--";
  445. key.negativeArgument3Key = "M--";
  446. key.suspendKey = "Not defined";
  447. // ================================= Hooks ================================= //
  448. hook.setHook('KeySnailInitialized', function () {
  449. ext.exec("shiitake-enable-style");
  450. });
  451. hook.setHook('KeyBoardQuit', function (aEvent) {
  452. ext.exec("hide-sidebar");
  453. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  454. gBrowser.focus();
  455. content.focus();
  456. command.closeFindBar();
  457. if (util.isCaretEnabled()) {
  458. command.resetMark(aEvent);
  459. } else {
  460. goDoCommand("cmd_selectNone");
  461. }
  462. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  463. });
  464. hook.setHook('Unload', function () {
  465. util.getBrowserWindows().some(function (win) {
  466. if (win === window) {
  467. return false;
  468. }
  469. const ks = win.KeySnail;
  470. share.pluginUpdater = ks.getPluginUpdater(share.pluginUpdater.pluginsWithUpdate);
  471. ks.setUpPluginUpdaterDelegator();
  472. return true;
  473. });
  474. });
  475. // ============================= Key bindings ============================== //
  476. key.setGlobalKey('C-<right>', function () {
  477. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  478. }, 'ひとつ右のタブへ');
  479. key.setGlobalKey('C-<left>', function () {
  480. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  481. }, 'ひとつ左のタブへ');
  482. key.setGlobalKey('C-<up>', function () {
  483. var browser = getBrowser();
  484. if (browser.mCurrentTab.previousSibling) {
  485. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  486. } else {
  487. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  488. }
  489. }, '選択中のタブを右へ');
  490. key.setGlobalKey('C-<down>', function () {
  491. var browser = getBrowser();
  492. if (browser.mCurrentTab.nextSibling) {
  493. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  494. } else {
  495. browser.moveTabTo(browser.mCurrentTab, 0);
  496. }
  497. }, '選択中のタブを左へ');
  498. key.setGlobalKey('C-h', function (ev, arg) {
  499. return;
  500. }, 'ignore');
  501. key.setGlobalKey('<delete>', function (ev, arg) {
  502. let (elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  503. gBrowser.focus();
  504. content.focus();
  505. }, 'コンテンツへフォーカス', true);
  506. key.setGlobalKey('C-p', function (ev, arg) {
  507. return !document.getElementById("keysnail-prompt").hidden &&
  508. document.getElementById("keysnail-prompt-textbox").focus();
  509. }, 'KeySnail のプロンプトへフォーカス', true);
  510. key.setViewKey('J', function (ev) {
  511. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  512. }, 'ひとつ右のタブへ');
  513. key.setViewKey('K', function (ev) {
  514. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  515. }, 'ひとつ左のタブへ');
  516. key.setViewKey('o', function (ev, arg) {
  517. ext.exec("hok-start-foreground-mode", arg, ev);
  518. }, 'Start Hit a Hint foreground mode', true);
  519. key.setViewKey('c', function (ev) {
  520. command.interpreter();
  521. }, 'JavaScript のコードを評価');
  522. key.setViewKey('D', function (ev, arg) {
  523. ext.exec("dig-url", arg, ev);
  524. }, 'dig url with selector', true);
  525. key.setViewKey('x', function (aEvent, aArg) {
  526. ext.select(aArg, aEvent);
  527. }, 'エクステ一覧');
  528. key.setViewKey(['t', 'm'], function (ev, arg) {
  529. if (window.loadURI) {
  530. loadURI("javascript:window.location='http://api.tweetmeme.com/visit?url='+window.location;");
  531. }
  532. }, 'open with tweetmeme');
  533. key.setViewKey(['t', 'w'], function (ev, arg) {
  534. ext.exec("twitter-client-tweet", arg, ev);
  535. }, 'つぶやく', true);
  536. key.setViewKey(['t', 'p'], function (ev, arg) {
  537. ext.exec("twitter-client-tweet-this-page", arg, ev);
  538. }, 'このページのタイトルと URL を使ってつぶやく', true);
  539. key.setViewKey([['u'], ['<left>']], function (ev) {
  540. goDoCommand("cmd_scrollPageUp");
  541. }, '一画面分スクロールアップ');
  542. key.setViewKey('g', function () {
  543. goDoCommand("cmd_scrollTop");
  544. }, 'ページ先頭へ移動');
  545. key.setViewKey('G', function () {
  546. goDoCommand("cmd_scrollBottom");
  547. }, 'ページ末尾へ移動');
  548. key.setViewKey('r', function (aEvent) {
  549. BrowserReload();
  550. }, '再読み込み');
  551. key.setViewKey('m', function (ev, arg) {
  552. _fi.toogle();
  553. }, 'fetchimiをトグル');
  554. key.setViewKey('p', function (ev, arg) {
  555. if (window.loadURI) {
  556. 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{}");
  557. }
  558. }, 'posterousに投稿');
  559. key.setViewKey('SPC', function (ev, arg) {
  560. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  561. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  562. }, 'タブの選択をトグルして次のタブ');
  563. key.setViewKey('S-SPC', function (ev, arg) {
  564. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  565. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  566. }, 'タブの選択をトグルして前のタブ');
  567. key.setViewKey('z', function (ev, arg) {
  568. ext.exec("keysnail-setting-menu", arg, ev);
  569. }, 'open keysnail setting menu', true);
  570. key.setViewKey('C-SPC', function (ev, arg) {
  571. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  572. }, 'タブの選択をトグル');
  573. key.setViewKey('e', function () {
  574. command.focusElement(command.elementsRetrieverTextarea, 0);
  575. }, '最初のインプットエリアへフォーカス', true);
  576. key.setViewKey('S', function (ev, arg) {
  577. if (window.loadURI) {
  578. 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{}");
  579. }
  580. }, 'google reader share');
  581. key.setViewKey('!', function (ev, arg) {
  582. shell.input();
  583. }, 'Command system');
  584. key.setViewKey('R', function () {
  585. BrowserReloadSkipCache();
  586. }, '更新(キャッシュを無視)');
  587. key.setViewKey('<backspace>', function () {
  588. BrowserBack();
  589. }, '戻る');
  590. key.setViewKey('S-<backspace>', function () {
  591. BrowserForward();
  592. }, '進む');
  593. key.setViewKey('q', function (ev, arg) {
  594. ext.exec("query-then-engine", arg, ev);
  595. }, 'enter search word and then select engine', true);
  596. key.setViewKey('/', function () {
  597. command.iSearchForward();
  598. }, 'インクリメンタル検索', true);
  599. key.setViewKey('?', function (ev) {
  600. command.iSearchForwardKs(ev);
  601. }, 'Emacs ライクなインクリメンタル検索', true);
  602. key.setViewKey('a', function (ev, arg) {
  603. allTabs.open();
  604. }, 'alltabs.open');
  605. key.setViewKey([['<right>'], ['d']], function (ev) {
  606. goDoCommand("cmd_scrollPageDown");
  607. }, '一画面スクロールダウン');
  608. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  609. return;
  610. }, 'ignore');
  611. key.setViewKey(':', function (ev, arg) {
  612. return !document.getElementById("keysnail-prompt").hidden &&
  613. document.getElementById("keysnail-prompt-textbox").focus();
  614. }, 'KeySnail のプロンプトへフォーカス', true);
  615. key.setViewKey('H', function (ev) {
  616. var browser = getBrowser();
  617. if (browser.mCurrentTab.previousSibling) {
  618. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  619. } else {
  620. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  621. }
  622. }, '選択中のタブを左へ');
  623. key.setViewKey('0', function (ev) {
  624. BrowserCloseTabOrWindow();
  625. }, 'タブ / ウィンドウを閉じる');
  626. key.setViewKey('C', function (ev, arg) {
  627. ext.exec("linksnail", arg, ev);
  628. }, 'LinkSnail', true);
  629. key.setViewKey('C-<backspace>', function (ev, arg) {
  630. ext.exec("list-tab-history", arg, ev);
  631. }, 'List tab history', true);
  632. key.setViewKey('I', function (ev, arg) {
  633. ext.exec("instapaper-post-page-with-comment", arg, ev);
  634. }, 'post page and comment', true);
  635. key.setViewKey('T', function (ev, arg) {
  636. ext.exec("mstranslator-open-prompt", arg, ev);
  637. }, 'MSTranslator - Open prompt', true);
  638. key.setViewKey('j', function (ev) {
  639. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
  640. }, '一行スクロールダウン');
  641. key.setViewKey('k', function (ev) {
  642. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
  643. }, '一行スクロールアップ');
  644. key.setViewKey('l', function (ev) {
  645. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RIGHT, true);
  646. }, '右へスクロール');
  647. key.setViewKey('h', function (ev) {
  648. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true);
  649. }, '左へスクロール');
  650. key.setViewKey('L', function (ev) {
  651. var browser = getBrowser();
  652. if (browser.mCurrentTab.nextSibling) {
  653. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  654. } else {
  655. browser.moveTabTo(browser.mCurrentTab, 0);
  656. }
  657. }, '選択中のタブを右へ');
  658. key.setViewKey('U', function (ev) {
  659. undoCloseTab();
  660. }, '閉じたタブを元に戻す');
  661. key.setEditKey('C-<tab>', function (ev) {
  662. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  663. }, '次のテキストエリアへフォーカス');