選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

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