Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

1382 řádky
44 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. // Original is at https://gist.github.com/Griever/62715
  13. ext.add("open-bookmarks-in-new-tab", function(){
  14. // this makes all clicks open in new tab.
  15. // return;
  16. // test if firefox 12
  17. if (12 > parseFloat(Cc['@mozilla.org/xre/app-info;1'].
  18. getService(Ci.nsIXULAppInfo).version)) {
  19. return;
  20. }
  21. // I cannot fully understand what happen but keysnail emit error
  22. // *after* initialization of firefox finished successfully and I assured
  23. // that new tabs open as I expect when clicking bookmarks, for example,
  24. // when I try to tweet using the twitter keysnail plugin, with error
  25. // message saying "whereToOpenLink is undefined.".
  26. // if no modifier key pressed open in new tab.
  27. try {
  28. var whereToOpenLink_org = new String(window.whereToOpenLink.toString());
  29. window.whereToOpenLink = eval(
  30. "(" +
  31. whereToOpenLink_org.replace(
  32. '{',
  33. '{ if(!e || ' +
  34. '(!e.ctrlKey && !e.shiftKey && !e.metaKey && ' +
  35. '!(e.altKKey && !ignoreAlt))) ' +
  36. 'return "tab";'
  37. ) +
  38. ")"
  39. );
  40. } catch (e if e instanceof TypeError) {
  41. return;
  42. }
  43. // This is useless because this makes reload open new tab.
  44. // window.whereToOpenLink = function(e, ib, ia){ return "tab"; };
  45. }, "open in new tab");
  46. // ext.exec("open-bookmarks-in-new-tab");
  47. //////////////////////////////////////
  48. //// sitelocalkeymap
  49. var local = {};
  50. plugins.options["site_local_keymap.local_keymap"] = local;
  51. function fake(k, i) function(){ key.feed(k, i); };
  52. function pass(k, i) [k, fake(k, i)];
  53. function ignore(k, i) [k, null];
  54. // ext.add("ext-name", function () {}, "ext description");
  55. // style.register("");
  56. // local["^http://"] = [['a', function(ev, arg){}],];
  57. ///////////////////////////////////////////
  58. //// firefox
  59. // style.register("#bookmarksPanel > hbox,#history-panel > hbox {" +
  60. // "display: none !important;}" +
  61. // " //#urlbar-container{max-width: 500px !important;}");
  62. // style.register( //not work
  63. // <><![CDATA[
  64. // input,textarea {
  65. // font-family: monospace !important;
  66. // }
  67. // ]]></>.toString()
  68. // );
  69. style.register(
  70. '@-moz-document ' +
  71. 'url-prefix(\"http://www.tumblr.com/\"), ' +
  72. 'url-prefix(\"https://www.tumblr.com/\") ' +
  73. '{ #pagination {' +
  74. 'position: fixed;' +
  75. 'bottom: 50px;' +
  76. 'right: 100px;' +
  77. 'padding-right: 0px !important' +
  78. '} }' , style.XHTML);
  79. ///////////////////////////////////
  80. //search engine
  81. plugins.options["search-url-list"] = [
  82. ["DuckDuckGo", "https://duckduckgo.com/?q=%q"],
  83. ["Bing", "http://bing.com/search?q=%q"],
  84. ["Google", "http://google.com/search?q=%q"],
  85. ["Yahoo Realtime",
  86. "http://realtime.search.yahoo.co.jp/search?rkf=1&ei=UTF-8&p=%q"],
  87. ["Twitter Search", "http://twitter.com/search?q=%q&lang=all"],
  88. ["Tospy", "http://topsy.com/s?allow_lang=ja&q=%q"],
  89. ["2ch syoboi.jp", "http://ff2ch.syoboi.jp/?q=%q"],
  90. ["2ch-ranking","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  91. //["2ch ttsearch", "http://ttsearch.net/s2.cgi?k=%q&o=r"],
  92. ["I\'m feelig lucky!", "http://www.google.co.jp/search?q=%q&btnI=kudos"],
  93. ["Uncyclopedia", "http://ja.uncyclopedia.info/wiki/%q"],
  94. ["Wikipedia", "http://ja.wikipedia.org/wiki/%q"],
  95. ["nicovideo.jp", "http://www.nicovideo.jp/search/%q"],
  96. ["alc", "http://eow.alc.co.jp/%q/UTF-8/"],
  97. ["google map",
  98. "http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  99. ["Weblio", "http://www.weblio.jp/content_find?query=%q"],
  100. ["ShoutCast", "http://www.shoutcast.com/Internet-Radio/%q"],
  101. ["Delicious 10sr", "http://delicious.com/10sr/%q"],
  102. ["Open raw", "%r"]
  103. ];
  104. plugins.options["my-keysnail-bookmarks"] = [
  105. "twitter.com"
  106. ];
  107. // sitelocal keymap
  108. //////////////////////////////////////////
  109. // 2ch chaika
  110. // change chaika port every time firefox starts
  111. util.setIntPref("extensions.chaika.server_port.firefox",
  112. 8800 + Math.floor(Math.random() * 30));
  113. local["^http://127.0.0.1:88"] = [
  114. ['k', function(ev, arg){
  115. curl = window.content.location.href;
  116. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  117. window.content.location.href = kurl;
  118. }
  119. ]
  120. ];
  121. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  122. ['k', function(ev, arg){
  123. var url = window.content.location.href;
  124. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  125. var result = url.match(pt);
  126. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/",
  127. result[1], result[2], result[3]);
  128. window.content.location.href = k;
  129. }
  130. ]
  131. ];
  132. /////////////////////////////////////////
  133. // feedly
  134. local["^https?://(www\.|cloud\.|)feedly\.com/"] = [
  135. ['d', null],
  136. ['j', null],
  137. ['k', null],
  138. ['n', null],
  139. ['p', null],
  140. ['o', null],
  141. ['b', null],
  142. ['S', null],
  143. ['s', null],
  144. ['?', null],
  145. ['r', null],
  146. ['g', null],
  147. // ['x', function(ev, arg){
  148. // ev.target.dispatchEvent(key.stringToKeyEvent("g", true));
  149. // }],
  150. // ['l', function(ev, arg){
  151. // var host = window.content.location.host;
  152. // if (host === "cloud.feedly.com" || host === "feedly.com") {
  153. // window.content.location.href = "http://" + host + "/#latest";
  154. // } else if (host === "www.feedly.com") {
  155. // window.content.location.href = "http://" + host + "/home#latest";
  156. // }
  157. // }],
  158. ['a', null],
  159. [['t', 'p'], function(ev, arg){
  160. ev.target.dispatchEvent(key.stringToKeyEvent("t", true));
  161. }],
  162. [['t', 'w'], function(ev, arg){
  163. ext.exec("twitter-client-tweet", arg, ev);
  164. }]
  165. ];
  166. /////////////////////////////////////////
  167. //nicovideo
  168. // http://dic.nicovideo.jp/id/4858151
  169. local["^http://(www|tw|es|de|)\.nicovideo\.jp\/(watch|playlist)"] = [
  170. // ["i", function(ev, arg){ ext.exec("nicoinfo", arg); }],
  171. ["SPC", function(ev, arg){ ext.exec("nicopause", arg); }],
  172. ["f", function(ev, arg){ ext.exec("nicosize", arg); }],
  173. ["F", function(ev, arg){ ext.exec("nicosize", arg); }],
  174. // ["o", function(ev, arg){ ext.exec("nicommentvisible", arg); }],
  175. // ["m", function(ev, arg){ ext.exec("nicomute", arg); }],
  176. // [".", function(ev, arg){ ext.exec("nicovolumeIncrement", arg); }],
  177. // [",", function(ev, arg){ ext.exec("nicovolumeDecrement", arg); }],
  178. // ['f', function(ev, arg){
  179. // curl = window.content.location.href;
  180. // kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  181. // window.content.location.href = kurl;
  182. // }]
  183. ];
  184. /////////////////////////////////////////
  185. // tumblr/dashboard
  186. local["^http://www.tumblr.com/dashboard"] = [
  187. // ["C-<left>", function(ev, arg){
  188. // gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  189. // }],
  190. // ["C-<right>", function(ev, arg){
  191. // gBrowser.mTabContainer.advanceSelectedTab(1, true);
  192. // }],
  193. ["<left>", function(ev, arg){
  194. window.content.location.href = "http://www.tumblr.com/dashboard";
  195. }],
  196. ["<right>", null],
  197. ["J", function(ev, arg){
  198. if (window.loadURI) {
  199. 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;}())");
  200. }
  201. }]
  202. ];
  203. ///////////////////////////////////////////
  204. // plugin option
  205. plugins.options["builtin_commands_ext.ext_list"] = [
  206. "focus-to-prompt",
  207. "open-url-from-clipboard",
  208. "restart-firefox"
  209. ];
  210. plugins.options["instapaper.close_after_post"] = true;
  211. plugins.options["instapaper.initial_comment_function"] = function(){
  212. var now = new Date();
  213. return "[" + now.toString() + "]";
  214. };
  215. //////////////////////////////////////////
  216. // yatc
  217. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  218. plugins.options["twitter_client.popup_new_statuses"] = false;
  219. plugins.options["twitter_client.automatically_begin"] = false;
  220. plugins.options["twitter_client.automatically_begin_list"] = false;
  221. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  222. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  223. plugins.options["twitter_client.tweet_keymap"] = {
  224. "C-RET" : "prompt-decide",
  225. "RET" : ""
  226. };
  227. plugins.options["twitter_client.jmp_id"] = "10sr";
  228. plugins.options["twitter_client.jmp_key"] =
  229. "R_c51f889a77cb4b4e993ed868f65083f5";
  230. plugins.options["twitter_client.use_jmp"] = true;
  231. ////////////////////////////////////////////
  232. // my exts and functions
  233. var autoSaveTabList = (function(){
  234. const PREF_PREFIX = "extensions.keysnail.plugins.autosavetablist.";
  235. const PREF_DSTDIR = "dstdir";
  236. const PREF_ENABLED = "enabled";
  237. // use plugin option to set
  238. // in sec
  239. var default_timer_interval = 60 * 5;
  240. // "/" for unix system
  241. const DIR_DELIM = userscript.directoryDelimitter;
  242. var __timer = null;
  243. var __last_tab_list = null;
  244. function selectDirectory(title){
  245. // open dialog and return nsILocalFile object
  246. // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile
  247. // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker
  248. // this function blocks.
  249. var nsIFilePicker = Components.interfaces.nsIFilePicker;
  250. var fp = Components.classes["@mozilla.org/filepicker;1"].
  251. createInstance(nsIFilePicker);
  252. fp.init(window, title, nsIFilePicker.modeGetFolder);
  253. // block
  254. var res = fp.show();
  255. if (res !== nsIFilePicker.returnOK) {
  256. return null;
  257. }
  258. return fp.file;
  259. }
  260. function selectFile(title){
  261. // open dialog and return nsILocalFile object
  262. // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile
  263. // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker
  264. // this function blocks.
  265. var nsIFilePicker = Components.interfaces.nsIFilePicker;
  266. var fp = Components.classes["@mozilla.org/filepicker;1"].
  267. createInstance(nsIFilePicker);
  268. fp.init(window, title, nsIFilePicker.modeOpen);
  269. // block
  270. var res = fp.show();
  271. if (res !== nsIFilePicker.returnOK) {
  272. return null;
  273. }
  274. return fp.file;
  275. }
  276. function setup(){
  277. // set destination directory
  278. var dstdir = selectDirectory("Select Directory to Save Tab List");
  279. if (! dstdir) { return; }
  280. if (! dstdir.isWritable()) {
  281. display.notify("Directory is not writable");
  282. return;
  283. }
  284. util.setUnicharPref(PREF_PREFIX + PREF_DSTDIR, dstdir.path);
  285. }
  286. function genFileName(){
  287. function formatCurrent(){
  288. var d = new Date();
  289. function pad(n){
  290. return n < 10 ? '0' + n.toString() : n.toString()
  291. }
  292. return [
  293. d.getFullYear().toString(),
  294. pad(d.getMonth() + 1),
  295. pad(d.getDate()),
  296. "-",
  297. pad(d.getHours()),
  298. pad(d.getMinutes()),
  299. pad(d.getSeconds())
  300. ].join("");
  301. }
  302. return "tablist." + formatCurrent() + ".lst";
  303. }
  304. function getTabList(){
  305. // returns list of urls of current tabs.
  306. return [(function(){
  307. var browser = tab.linkedBrowser;
  308. var win = browser.contentWindow;
  309. // var title = tab.label;
  310. var url = win.location.href;
  311. return url;
  312. })() for each (tab in Array.slice(gBrowser.mTabContainer.childNodes))];
  313. // Array.slice is required?
  314. }
  315. function saveCurrentList(){
  316. var dstdir = util.getUnicharPref(PREF_PREFIX + PREF_DSTDIR);
  317. if (! dstdir) {
  318. display.showPopup("AutoSaveTabList",
  319. "Dest dir is not set yet. Run astl-setup first");
  320. return;
  321. }
  322. var filename = genFileName();
  323. var tab_list = getTabList().join("\n") + "\n"
  324. if (tab_list !== __last_tab_list) {
  325. util.writeTextFile(
  326. tab_list,
  327. dstdir + userscript.directoryDelimiter + filename
  328. );
  329. display.showPopup("AutoSaveTabList",
  330. "Tab List saved: " + filename);
  331. __last_tab_list = tab_list;
  332. }
  333. }
  334. function openFromFile(){
  335. var file = selectFile();
  336. if (file) {
  337. openFromLFSplittedString(util.readTextFile(file.path));
  338. }
  339. }
  340. function openFromClipboard(){
  341. openFromLFSplittedString(command.getClipboardText());
  342. }
  343. function openFromLFSplittedString(str){
  344. var urls = str.split("\n");
  345. for (var i = 0; i < urls.length; i++) {
  346. if (urls[i].match(/^http/)) {
  347. window.openUILinkIn(urls[i], "tab");
  348. }
  349. }
  350. }
  351. function enableTimer(ev, sec){
  352. disableTimer();
  353. sec = sec || default_timer_interval;
  354. __timer = window.setInterval(saveCurrentList, sec * 1000);
  355. display.showPopup("AutoSaveTabList",
  356. "Auto save enabled for every " + sec.toString() + " sec");
  357. }
  358. function disableTimer(){
  359. if (__timer) {
  360. window.clearInterval(__timer);
  361. __timer = null;
  362. display.showPopup("AutoSaveTabList",
  363. "Auto save disabled");
  364. } else {
  365. display.showPopup("AutoSaveTabList",
  366. "Auto save timer is not set yet !");
  367. }
  368. }
  369. return {
  370. selectDirectory: selectDirectory,
  371. setup: setup,
  372. getTabList: getTabList,
  373. saveCurrentList: saveCurrentList,
  374. openFromClipboard: openFromClipboard,
  375. openFromFile: openFromFile,
  376. enableTimer: enableTimer,
  377. disableTimer: disableTimer
  378. };
  379. })();
  380. ext.add("astl-setup", autoSaveTabList.setup, "Auto save tab list - Setup");
  381. ext.add("astl-open-from-clipboard", autoSaveTabList.openFromClipboard, "Auto save tab list - Open tabs from clipboard");
  382. ext.add("astl-open-from-file", autoSaveTabList.openFromFile, "Auto save tab list - Open tabs from local file");
  383. ext.add("astl-save-current", autoSaveTabList.saveCurrentList,
  384. "Auto save tab list - Save current list");
  385. ext.add("astl-enable-timer", autoSaveTabList.enableTimer, "Auto save tab list - Enable periodic timer");
  386. ext.add("astl-disable-timer", autoSaveTabList.disableTimer, "Auto save tab list - disable periodic timer");
  387. ext.exec("astl-enable-timer");
  388. var echoTabInfo = (function(){
  389. var currenttab;
  390. function _display(msg){
  391. display.prettyPrint(msg, {
  392. timeout: 1500,
  393. style: {
  394. "font-size": "18px",
  395. "font-family": "monospace"
  396. }
  397. });
  398. }
  399. function __display(msg){
  400. display.echoStatusBar(msg);
  401. }
  402. function echo(){
  403. var newtab = getBrowser().mCurrentTab;
  404. if (currenttab === newtab) {
  405. return;
  406. }
  407. currenttab = newtab;
  408. var len = getBrowser().tabs.length;
  409. var idx = currenttab._tPos;
  410. var title = window.content.document.title;
  411. var url = window.content.location.href;
  412. var doc = content ? content.document : document;
  413. var dBody = doc.body;
  414. if (dBody && !util.isFrameSetWindow(content)) {
  415. // if page has been prepared
  416. _display(
  417. "[" +
  418. (idx + 1).toString() + "/" +
  419. len.toString() + "] " +
  420. title + " <" +
  421. decodeURIComponent(url) + ">"
  422. );
  423. }
  424. }
  425. return {
  426. echo: echo
  427. };
  428. })();
  429. ext.add("open-remote-init-file", function(ev, arg){
  430. const URL = "https://raw.github.com/10sr/dotfiles/master/_keysnail.js";
  431. window.openUILinkIn(URL, "tab");
  432. }, "Open remote initialization file");
  433. var updateInitFile = (function(){
  434. const URL = "https://raw.github.com/10sr/dotfiles/master/_keysnail.js";
  435. // content/modules/userscript.js
  436. // copy file from aFile
  437. function placeFile(aFile, force) {
  438. var dstdir = util.getUnicharPref("extensions.keysnail.userscript.location");
  439. if (dstdir === "") {
  440. throw util.getLocaleString("failedToInstallFile", [aFile.leafName]) + " :: " + x;
  441. }
  442. try
  443. {
  444. // calc dir from path
  445. let destinationDir = util.openFile(dstdir);
  446. let destinationFile = util.openFile(dstdir);
  447. destinationFile.append(aFile.leafName);
  448. if (destinationFile.exists())
  449. {
  450. if (util.hashFile(aFile) === util.hashFile(destinationFile))
  451. {
  452. // no need to install this file
  453. return destinationFile;
  454. }
  455. let confirmed = force ||
  456. util.confirm(
  457. util.getLocaleString("overWriteConfirmationTitle"),
  458. util.getLocaleString("overWriteConfirmation",
  459. [destinationFile.path])
  460. );
  461. if (!confirmed) {
  462. throw util.getLocaleString("canceledByUser");
  463. }
  464. }
  465. aFile.moveTo(destinationDir, "");
  466. return destinationFile;
  467. }
  468. catch (x)
  469. {
  470. throw util.getLocaleString("failedToInstallFile",
  471. [aFile.leafName]) +
  472. " :: " + x;
  473. }
  474. }
  475. function updateFile() {
  476. util.httpGet(URL, false, function (req) {
  477. if (req.status !== 200) {
  478. util.message(req.responseText);
  479. }
  480. try {
  481. let name = util.getLeafNameFromURL(URL);
  482. let file = userscript.writeTextTmp(name, req.responseText);
  483. let installed = placeFile(file);
  484. util.message(installed.path + " installed");
  485. display.showPopup("update-init-file",
  486. installed.path + " installed")
  487. } catch (x) {
  488. util.message(
  489. "An error occured while installing required scripts :: " +
  490. x.message
  491. );
  492. display.showPopup(
  493. "update-init-file",
  494. "An error occured while installing required scripts :: " +
  495. x.message
  496. );
  497. }
  498. });
  499. }
  500. return {
  501. updateFile: updateFile
  502. };
  503. })();
  504. ext.add("update-init-file", updateInitFile.updateFile, "update init file");
  505. var importExportBookmarks = (function(){
  506. function getOrganizer(){
  507. // [How to call for Firefox bookmark dialog? - Stack Overflow]
  508. // (http://stackoverflow.com/questions/9158187/how-to-call-for-firefox-bookmark-dialog)
  509. Components.utils.import("resource://gre/modules/Services.jsm");
  510. var organizer = Services.wm.getMostRecentWindow("Places:Organizer");
  511. if (!organizer) {
  512. // No currently open places window,
  513. // so open one with the specified mode.
  514. openDialog("chrome://browser/content/places/places.xul",
  515. "",
  516. "chrome,toolbar=yes,dialog=no,resizable",
  517. "AllBookmarks");
  518. return null;
  519. } else {
  520. return organizer;
  521. }
  522. }
  523. ext.add("export-bookmarks", function(ev, arg){
  524. var organizer = getOrganizer();
  525. if (organizer) {
  526. organizer.PlacesOrganizer.exportBookmarks();
  527. }
  528. }, "export bookmarks");
  529. ext.add("import-bookmarks", function(ev, arg){
  530. var organizer = getOrganizer();
  531. if (organizer) {
  532. organizer.PlacesOrganizer.importBookmarks();
  533. }
  534. }, "import bookmarks");
  535. return {
  536. getOrganizer: getOrganizer
  537. };
  538. })();
  539. ext.add("my-index-html", function(ev, arg){
  540. homepath = util.getEnv("HOME");
  541. file = ".index.html";
  542. if (homepath) {
  543. path = "file://" + homepath + "/" + file;
  544. window.openUILinkIn(path, "tab");
  545. }
  546. }, "open my index.html");
  547. ext.add("strong-fullscreen", function(){
  548. var elemids = [
  549. "navigator-toolbox"
  550. ];
  551. BrowserFullScreen();
  552. var isfullscreen = window.fullScreen;
  553. for(var i = 0; i < elemids.length; i++){
  554. var elem = document.getElementById(elemids[i]);
  555. if(elem){
  556. if(isfullscreen){
  557. elem.style.display = "none";
  558. }else{
  559. elem.style.display = null;
  560. }
  561. }
  562. }
  563. var tabs = document.getElementById("verticaltabs-box");
  564. if(tabs){
  565. var pref_key = "extensions.verticaltabs.width";
  566. var pref_key_bak = pref_key + "_bak";
  567. if(isfullscreen){
  568. var width_orig = util.getIntPref(pref_key);
  569. util.setIntPref(pref_key_bak, width_orig);
  570. util.setIntPref(pref_key, 0);
  571. tabs.setAttribute("width", "0");
  572. }else if(parseInt(tabs.getAttribute("width") || "") === 0){
  573. var width_bak = util.getIntPref(pref_key_bak);
  574. util.setIntPref(pref_key, width_bak);
  575. tabs.setAttribute("width", width_bak.toString());
  576. }
  577. }
  578. }, "go fullscreen with hiding toolbar and tabbar");
  579. ext.add("bookmark-delicious", function(){
  580. f= 'http://www.delicious.com/save?url=' +
  581. encodeURIComponent(window.content.location.href) +
  582. '&title=' + encodeURIComponent(document.title) +
  583. '&notes=' + encodeURIComponent(
  584. '' + (window.getSelection ?
  585. window.getSelection() : (
  586. document.getSelection ?
  587. document.getSelection() :
  588. document.selection.createRange().text))) + '&v=6&';
  589. a = function(){
  590. if(! window.open(
  591. f + 'noui=1&jump=doclose',
  592. 'deliciousuiv6',
  593. 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){
  594. location.href = f + 'jump=yes';
  595. }
  596. };
  597. if(/Firefox/.test(navigator.userAgent)){
  598. setTimeout(a,0);
  599. }else{
  600. a();
  601. }
  602. }, "bookmark delicious");
  603. ext.add('view-page-source', function(){
  604. window.content.location.href = "view-source:" +
  605. window.content.location.href;
  606. }, 'view page source');
  607. ext.add('my-setpref', function(){
  608. util.setPrefs(
  609. {
  610. "browser.bookmarks.max_backups":0,
  611. "browser.cache.memory.capacity":16384,
  612. "browser.download.manager.closeWhenDone":true,
  613. "browser.download.useDownloadDir":false,
  614. "browser.fullscreen.autohide":false,
  615. "browser.search.openintab":true,
  616. "browser.sessionhistory.max_total_viewers":8,
  617. "browser.sessionstore.restore_on_demand":true,
  618. "browser.tabs.closeWindowWithLastTab":false,
  619. "browser.tabs.loadDivertedInBackground": true,
  620. "browser.urlbar.autocomplete.enabled":false,
  621. "browser.urlbar.trimURLs":false,
  622. "browser.fixup.alternate.enabled": false,
  623. "dom.disable_window_open_feature.location": false,
  624. "dom.max_script_run_time": 30,
  625. "extensions.chaika.bbsmenu.open_new_tab":true,
  626. "extensions.chaika.bbsmenu.open_single_click":false,
  627. "extensions.chaika.board.open_new_tab":true,
  628. "extensions.chaika.board.open_single_click":false,
  629. "extensions.foxage2ch.openThreadInTab":true,
  630. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  631. "extensions.saveimageinfolder.general-fileprefixvalue":
  632. "%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  633. "extensions.saveimageinfolder.usecache":true,
  634. "extensions.tabutils.openTabNext":1,
  635. "extensions.tabutils.openUrlInTab":false,
  636. "extensions.tabutils.styles.current":
  637. "{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  638. "extensions.tabutils.styles.unread":
  639. "{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}",
  640. "extensions.tabutils.TFS_Enable":false,
  641. // Always select right tab on close
  642. "extensions.tabutils.selectOnClose":10,
  643. "extensions.yass.edgetype":0,
  644. "extensions.yass.selectedpreset":"red",
  645. "font.default.x-western":"sans-serif",
  646. "gecko.handlerService.schemes.mailto.1.name":"Gmail",
  647. "general.warnOnAboutConfig":false,
  648. "keyword.URL":"http://www.bing.com/search?q=",
  649. "browser.search.defaultenginename":"Bing",
  650. "browser.search.defaulturl":"http://www.bing.com/search?q=",
  651. "network.dns.disableIPv6":true,
  652. "refcontrol.actions":
  653. "@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL",
  654. "scrapbook.tabs.open":true
  655. }
  656. );
  657. if(/^Linux/.test(navigator.platform)){
  658. util.setPrefs(
  659. {
  660. "browser.cache.disk.parent_directory":"/tmp",
  661. "browser.cache.disk.capacity":524288
  662. }
  663. );
  664. }
  665. display.showPopup("Keysnail", "My prefs done.");
  666. }, 'my setpref');
  667. ext.add('auto-install-plugins', function(ev, arg){
  668. var urls = [
  669. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  670. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  671. 'https://raw.github.com/mooz/keysnail/master/plugins/hok.ks.js',
  672. 'https://github.com/mooz/keysnail/raw/master/plugins/builtin-commands-ext.ks.js',
  673. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  674. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  675. 'https://raw.githubusercontent.com/azu/keysnail-plugin/master/nicontroller.ks.js',
  676. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  677. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  678. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  679. 'https://raw.github.com/10sr/keysnail-plugin/master/pixiv_autojump.ks.js',
  680. 'https://raw.github.com/10sr/keysnail-plugin/master/list-current-urls.ks.js',
  681. 'https://gist.githubusercontent.com/10sr/1976942/raw/firefox-addon-manager.ks.js',
  682. 'https://gist.githubusercontent.com/958/1450594/raw/mstranslator.ks.js'
  683. ];
  684. function inst(a){
  685. if(a.length == 0){
  686. display.showPopup("auto-install-plugins",
  687. "All installation finished.");
  688. }else{
  689. var url = a.shift();
  690. var path = userscript.pluginDir +
  691. userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  692. if(plugins.context[path] === undefined){
  693. userscript.installPluginFromURL(url, function(){inst(a);});
  694. }else{
  695. inst(a);
  696. }
  697. }
  698. }
  699. inst(urls);
  700. }, 'Install plugins automatically if not installed yet.');
  701. ext.add('put-aside-this-page', function (ev, arg) {
  702. var n = getBrowser().mCurrentTab._tPos;
  703. getBrowser().moveTabTo(getBrowser().mCurrentTab, 0);
  704. if (n != 0) {
  705. getBrowser().selectedTab = getBrowser().mTabs[n];
  706. }
  707. }, 'put aside this page');
  708. ext.add('send-escape', function (ev, arg) {
  709. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  710. }, 'escape');
  711. ext.add("open-hatebu-comment", function (ev, arg) {
  712. var url = window.content.location.href.replace(/^[^/]*\/\//, "");
  713. window.content.location.href = "http://b.hatena.ne.jp/entry/" + url;
  714. }, 'hatebu');
  715. // ext.add("focus-on-content", function(){
  716. // let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  717. // gBrowser.focus();
  718. // content.focus();
  719. // }, "forcus on content");
  720. ext.add("hide-sidebar", function(){
  721. var sidebarBox = document.getElementById("sidebar-box");
  722. if (!sidebarBox.hidden) {
  723. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  724. }
  725. }, "hide-sidebar");
  726. ext.add("close-and-next-tab", function (ev, arg) {
  727. var n = getBrowser().mCurrentTab._tPos;
  728. getBrowser().removeCurrentTab();
  729. getBrowser().selectedTab = getBrowser().mTabs[n];
  730. }, "close and focus to next tab");
  731. //////////////////////////////////////
  732. //
  733. ext.add("restart-firefox-add-menu", function(){
  734. const XUL_NS =
  735. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  736. var cmdelm = document.createElementNS(XUL_NS, "command");
  737. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs");
  738. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  739. var commandset = document.getElementById("mainCommandSet");
  740. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  741. commandset.appendChild(cmdelm);
  742. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  743. menuelm.setAttribute("label", "Restart Firefox");
  744. menuelm.setAttribute("id", "my_menu_restartFirefoxKs");
  745. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  746. var menu = document.getElementById("menu_FilePopup");
  747. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  748. menu.appendChild(menuelm);
  749. }, "add restart firefox menu");
  750. /////////////////////////////////////////
  751. // feed url
  752. ext.add("feed-add-to-feedly", function(){
  753. var url = window.content.location.href;
  754. window.content.location.href =
  755. "http://cloud.feedly.com/#subscription%2Ffeed%2F" +
  756. encodeURIComponent(url);
  757. }, "Add current feed to feedly");
  758. var feedUtils = (function(){
  759. var feedhandler = "http://cloud.feedly.com/#subscription%2Ffeed%2F%s";
  760. function getFeeds(){
  761. const doc = content.document;
  762. var feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  763. for ([, e] in Iterator(doc.querySelectorAll([
  764. 'link[type="application/rss+xml"]',
  765. 'link[type="application/atom+xml"]'
  766. ])))];
  767. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,
  768. "$1");
  769. for (i = 0; i < feeds.length; i++)
  770. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  771. // feeds.unshift([window.content.document.title,
  772. // window.content.location.href]);
  773. return feeds;
  774. };
  775. ext.add("copy-feed-url", function () {
  776. var feeds = getFeeds();
  777. if (! feeds.length) {
  778. display.echoStatusBar("No feed found.");
  779. return;
  780. }
  781. prompt.selector({
  782. message : "Select Feed",
  783. collection : feeds,
  784. callback : function (i) {
  785. if (i >= 0) {
  786. command.setClipboardText(feeds[i][1]);
  787. }
  788. }
  789. });
  790. }, "Copy url or feed url of current page");
  791. ext.add("open-feed", function () {
  792. var feeds = getFeeds();
  793. if (! feeds.length) {
  794. display.echoStatusBar("No feed found.");
  795. return;
  796. }
  797. prompt.selector({
  798. message : "Select Feed",
  799. collection : feeds,
  800. callback : function (i) {
  801. if (i < 0) {
  802. return;
  803. }
  804. var feedurl = feeds[i][1];
  805. if (feedhandler) {
  806. window.openUILinkIn(
  807. feedhandler.replace("%s", feedurl),
  808. "tab"
  809. );
  810. } else {
  811. window.openUILinkIn(feedurl, "tab");
  812. }
  813. }
  814. });
  815. }, "Copy url or feed url of current page");
  816. return {
  817. getFeeds: getFeeds
  818. };
  819. })();
  820. ///////////////////////////////////////
  821. // keysnail z menu
  822. ext.add("keysnail-setting-dialog", function(){
  823. KeySnail.openPreference();
  824. }, "keysnail setting dialog");
  825. ext.add("keysnail-plugin-manager", function(){
  826. userscript.openPluginManager();
  827. }, "keysnail plugin manager");
  828. ext.add("firefox-open-addon-manager", function(){
  829. BrowserOpenAddonsMgr();
  830. }, "firefox addon manager");
  831. ext.add("keysnail-reload-init-file", function(){
  832. userscript.reload();
  833. }, "keysnail reload init file");
  834. ext.add("keysnail-z-menu",function(){
  835. var list = [["keysnail-setting-dialog"],
  836. ["keysnail-plugin-manager"],
  837. ["firefox-open-addon-manager"],
  838. ["keysnail-reload-init-file"],
  839. // ["check-for-plugins-update"],
  840. ["restart-firefox"]
  841. ];
  842. prompt.selector(
  843. {
  844. message : "open setting dialog",
  845. collection : list,
  846. callback : function (i) {
  847. ext.exec(list[i][0]);
  848. }
  849. });
  850. },"open keysnail z menu");
  851. ///////////////////////////////////
  852. // search web
  853. ext.add("query-then-engine", function () {
  854. prompt.reader({
  855. message : "Search Word?:",
  856. group : "query_word",
  857. // completer : completer.matcher.header(share.friendsCache || []),
  858. initialInput : content.document.getSelection() || "",
  859. callback : function (q) {
  860. if (q) {
  861. prompt.selector({
  862. message : "search \"" + q + "\" with?",
  863. collection : plugins.options["search-url-list"],
  864. width : [20,80],
  865. callback : function (i) {
  866. getBrowser().selectedTab =
  867. getBrowser().addTab(
  868. plugins.options["search-url-list"][i][1].
  869. replace("%r",q).replace(
  870. "%q",encodeURIComponent(q)
  871. )
  872. )
  873. ;
  874. }
  875. });
  876. };
  877. }
  878. });
  879. }, "enter search word and then select engine");
  880. /////////////////////////////////////
  881. // closed tab list
  882. ext.add("list-closed-tabs", function () {
  883. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  884. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(
  885. Ci.nsISessionStore
  886. );
  887. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  888. var closedTabs = [[tab.image || fav, tab.title, tab.url]
  889. for each (tab in json.decode(ss.getClosedTabData(window)))
  890. ];
  891. if (!closedTabs.length)
  892. return void display.echoStatusBar("No recently closed tab.", 2000);
  893. prompt.selector(
  894. {
  895. message : "select tab to undo:",
  896. collection : closedTabs,
  897. flags : [ICON | IGNORE, 0, 0],
  898. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  899. });
  900. }, "List closed tabs");
  901. ///////////////////////////////
  902. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  903. ext.add("list-tab-history", function () {
  904. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  905. var tabHistory = [];
  906. var sessionHistory = getBrowser().webNavigation.sessionHistory;
  907. if (sessionHistory.count < 1)
  908. return void display.echoStatusBar("Tab history not exist", 2000);
  909. var curIdx = sessionHistory.index;
  910. for (var i = 0; i < sessionHistory.count; i++) {
  911. var entry = sessionHistory.getEntryAtIndex(i, false);
  912. if (!entry)
  913. continue;
  914. try {
  915. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  916. .getService(Ci.nsIFaviconService)
  917. .getFaviconForPage(entry.URI).spec;
  918. } catch (ex) {}
  919. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  920. }
  921. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  922. if (tabHistory[thIdx][3] == curIdx) break;
  923. }
  924. prompt.selector(
  925. {
  926. message : "select history in tab",
  927. collection : tabHistory,
  928. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  929. header : ["Title", "URL"],
  930. initialIndex : thIdx,
  931. callback : function(i) {
  932. if (i >= 0)
  933. getBrowser().webNavigation.gotoIndex(tabHistory[i][3]);
  934. }
  935. });
  936. }, 'List tab history');
  937. //}}%PRESERVE%
  938. // ========================================================================= //
  939. // ========================= Special key settings ========================== //
  940. key.quitKey = "ESC";
  941. key.helpKey = "<f1>";
  942. key.escapeKey = "C-q";
  943. key.macroStartKey = "";
  944. key.macroEndKey = "";
  945. key.universalArgumentKey = "C-u";
  946. key.negativeArgument1Key = "C--";
  947. key.negativeArgument2Key = "C-M--";
  948. key.negativeArgument3Key = "M--";
  949. key.suspendKey = "Not defined";
  950. // ================================= Hooks ================================= //
  951. hook.setHook('KeyBoardQuit', function (aEvent) {
  952. // ext.exec("hide-sidebar");
  953. let(elem = document.commandDispatcher.focusedElement) {elem && elem.blur()};
  954. getBrowser().focus();
  955. content.focus();
  956. command.closeFindBar();
  957. if (util.isCaretEnabled()) {
  958. command.resetMark(aEvent);
  959. } else {
  960. goDoCommand("cmd_selectNone");
  961. }
  962. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  963. });
  964. hook.setHook('Unload', function () {
  965. util.getBrowserWindows().some(function (win) {
  966. if (win === window) {
  967. return false;
  968. }
  969. const ks = win.KeySnail;
  970. share.pluginUpdater = ks.getPluginUpdater(
  971. share.pluginUpdater.pluginsWithUpdate);
  972. ks.setUpPluginUpdaterDelegator();
  973. return true;
  974. });
  975. });
  976. hook.setHook('LocationChange', function (aNsURI) {
  977. echoTabInfo.echo();
  978. });
  979. // ============================= Key bindings ============================== //
  980. key.setGlobalKey('C-<up>', function () {
  981. var browser = getBrowser();
  982. if (browser.mCurrentTab.previousSibling) {
  983. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  984. } else {
  985. browser.moveTabTo(browser.mCurrentTab,
  986. browser.mTabContainer.childNodes.length - 1);
  987. }
  988. }, '選択中のタブを右へ');
  989. key.setGlobalKey('C-<down>', function () {
  990. var browser = getBrowser();
  991. if (browser.mCurrentTab.nextSibling) {
  992. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  993. } else {
  994. browser.moveTabTo(browser.mCurrentTab, 0);
  995. }
  996. }, '選択中のタブを左へ');
  997. key.setGlobalKey('<delete>', function (ev, arg) {
  998. let (elem = document.commandDispatcher.focusedElement) {elem && elem.blur()};
  999. getBrowser().focus();
  1000. content.focus();
  1001. }, 'コンテンツへフォーカス', true);
  1002. key.setGlobalKey('<f11>', function (ev, arg) {
  1003. ext.exec("strong-fullscreen", arg, ev);
  1004. }, 'go fullscreen with hiding toolbar and tabbar', true);
  1005. key.setGlobalKey('<end>', function (ev) {
  1006. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  1007. }, 'ひとつ右のタブへ');
  1008. key.setGlobalKey('<home>', function (ev) {
  1009. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  1010. }, 'ひとつ左のタブへ');
  1011. key.setGlobalKey('<next>', function (ev) {
  1012. let browser = getBrowser();
  1013. if (browser.mCurrentTab.nextSibling) {
  1014. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  1015. } else {
  1016. browser.moveTabTo(browser.mCurrentTab, 0);
  1017. }
  1018. }, '選択中のタブを右へ');
  1019. key.setGlobalKey('<prior>', function (ev) {
  1020. let browser = getBrowser();
  1021. if (browser.mCurrentTab.previousSibling) {
  1022. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  1023. } else {
  1024. browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
  1025. }
  1026. }, '選択中のタブを左へ');
  1027. key.setViewKey('0', function (ev) {
  1028. BrowserCloseTabOrWindow();
  1029. }, 'タブ / ウィンドウを閉じる');
  1030. key.setViewKey('l', function (ev) {
  1031. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  1032. }, 'ひとつ右のタブへ');
  1033. key.setViewKey('h', function (ev) {
  1034. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  1035. }, 'ひとつ左のタブへ');
  1036. key.setViewKey('o', function (ev, arg) {
  1037. ext.exec("hok-start-foreground-mode", arg, ev);
  1038. }, 'Start Hit a Hint foreground mode', true);
  1039. key.setViewKey('c', function (ev) {
  1040. command.interpreter();
  1041. }, 'JavaScript のコードを評価');
  1042. key.setViewKey('D', function (ev, arg) {
  1043. ext.exec("dig-url", arg, ev);
  1044. }, 'dig url with selector', true);
  1045. key.setViewKey('x', function (aEvent, aArg) {
  1046. ext.select(aArg, aEvent);
  1047. }, 'エクステ一覧');
  1048. key.setViewKey(['t', 'w'], function (ev, arg) {
  1049. ext.exec("twitter-client-tweet", arg, ev);
  1050. }, 'つぶやく', true);
  1051. key.setViewKey(['t', 'p'], function (ev, arg) {
  1052. ext.exec("twitter-client-tweet-this-page", arg, ev);
  1053. }, 'このページのタイトルと URL を使ってつぶやく', true);
  1054. key.setViewKey([['u'], ['S-SPC']], function (ev) {
  1055. goDoCommand("cmd_scrollPageUp");
  1056. }, '一画面分スクロールアップ');
  1057. key.setViewKey('g', function () {
  1058. goDoCommand("cmd_scrollTop");
  1059. }, 'ページ先頭へ移動');
  1060. key.setViewKey('G', function () {
  1061. goDoCommand("cmd_scrollBottom");
  1062. }, 'ページ末尾へ移動');
  1063. key.setViewKey('r', function (aEvent) {
  1064. BrowserReload();
  1065. }, '再読み込み');
  1066. key.setViewKey('z', function (ev, arg) {
  1067. ext.exec("keysnail-z-menu", arg, ev);
  1068. }, 'open keysnail setting menu', true);
  1069. key.setViewKey('e', function () {
  1070. command.focusElement(command.elementsRetrieverTextarea, 0);
  1071. }, '最初のインプットエリアへフォーカス', true);
  1072. key.setViewKey('S', function (ev, arg) {
  1073. if (window.loadURI) {
  1074. 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{}");
  1075. }
  1076. }, 'google reader share');
  1077. key.setViewKey('!', function (ev, arg) {
  1078. shell.input();
  1079. }, 'Command system');
  1080. key.setViewKey('R', function () {
  1081. BrowserReloadSkipCache();
  1082. }, '更新(キャッシュを無視)');
  1083. key.setViewKey('<backspace>', function () {
  1084. BrowserBack();
  1085. }, '戻る');
  1086. key.setViewKey('S-<backspace>', function () {
  1087. BrowserForward();
  1088. }, '進む');
  1089. key.setViewKey('q', function (ev, arg) {
  1090. ext.exec("query-then-engine", arg, ev);
  1091. }, 'enter search word and then select engine', true);
  1092. key.setViewKey('/', function () {
  1093. command.iSearchForward();
  1094. }, 'インクリメンタル検索', true);
  1095. key.setViewKey('?', function (ev) {
  1096. command.iSearchForwardKs(ev);
  1097. }, 'Emacs ライクなインクリメンタル検索', true);
  1098. key.setViewKey('a', function (ev, arg) {
  1099. allTabs.open();
  1100. }, 'alltabs.open');
  1101. key.setViewKey([['d'], ['SPC']], function (ev) {
  1102. goDoCommand("cmd_scrollPageDown");
  1103. }, '一画面スクロールダウン');
  1104. key.setViewKey(':', function (ev, arg) {
  1105. return !document.getElementById("keysnail-prompt").hidden &&
  1106. document.getElementById("keysnail-prompt-textbox").focus();
  1107. }, 'KeySnail のプロンプトへフォーカス', true);
  1108. key.setViewKey('B', function (ev) {
  1109. var browser = getBrowser();
  1110. if (browser.mCurrentTab.previousSibling) {
  1111. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  1112. } else {
  1113. browser.moveTabTo(browser.mCurrentTab,
  1114. browser.mTabContainer.childNodes.length - 1);
  1115. }
  1116. }, '選択中のタブを左へ');
  1117. key.setViewKey('C', function (ev, arg) {
  1118. ext.exec("linksnail", arg, ev);
  1119. }, 'LinkSnail', true);
  1120. key.setViewKey('C-<backspace>', function (ev, arg) {
  1121. ext.exec("list-tab-history", arg, ev);
  1122. }, 'List tab history', true);
  1123. key.setViewKey('I', function (ev, arg) {
  1124. ext.exec("instapaper-post-page-with-comment", arg, ev);
  1125. }, 'post page and comment', true);
  1126. key.setViewKey('T', function (ev, arg) {
  1127. ext.exec("mstranslator-open-prompt", arg, ev);
  1128. }, 'MSTranslator - Open prompt', true);
  1129. key.setViewKey('f', function (ev, arg) {
  1130. ext.exec('strong-fullscreen', arg, ev);
  1131. }, 'go fullscreen with hiding toolbar and tabbar', true);
  1132. key.setViewKey('F', function (ev) {
  1133. var browser = getBrowser();
  1134. if (browser.mCurrentTab.nextSibling) {
  1135. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  1136. } else {
  1137. browser.moveTabTo(browser.mCurrentTab, 0);
  1138. }
  1139. }, '選択中のタブを右へ');
  1140. key.setViewKey('U', function (ev, arg) {
  1141. ext.exec("list-closed-tabs", arg, ev);
  1142. }, 'List closed tabs', true);
  1143. key.setViewKey('j', function (ev) {
  1144. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
  1145. }, '一行スクロールダウン');
  1146. key.setViewKey('k', function (ev) {
  1147. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
  1148. }, '一行スクロールアップ');
  1149. key.setViewKey('p', function (ev, arg) {
  1150. ext.exec('pocket-add-current', arg, ev);
  1151. }, 'Add current page', true);
  1152. key.setViewKey('P', function (ev, arg) {
  1153. ext.exec('pocket-open-latest', arg, ev);
  1154. }, 'Open last saved page', true);
  1155. key.setEditKey('C-<tab>', function (ev) {
  1156. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  1157. }, '次のテキストエリアへフォーカス');
  1158. key.setEditKey('C-a', function (ev) {
  1159. command.beginLine(ev);
  1160. }, '行頭へ移動');
  1161. key.setEditKey('C-e', function (ev) {
  1162. command.endLine(ev);
  1163. }, '行末へ');
  1164. key.setEditKey('C-d', function (ev) {
  1165. goDoCommand("cmd_deleteCharForward");
  1166. }, '次の一文字削除');
  1167. key.setEditKey('C-b', function (ev) {
  1168. command.previousChar(ev);
  1169. }, '一文字左へ移動');
  1170. key.setEditKey('C-f', function (ev) {
  1171. command.nextChar(ev);
  1172. }, '一文字右へ移動');
  1173. key.setEditKey('C-h', function (ev) {
  1174. goDoCommand("cmd_deleteCharBackward");
  1175. }, '前の一文字を削除');
  1176. key.setEditKey('C-k', function (ev) {
  1177. command.killLine(ev);
  1178. }, 'カーソルから先を一行カット (Kill line)');
  1179. key.setEditKey('C-l', function (ev) {
  1180. command.recenter(ev);
  1181. }, 'カーソル位置が画面の中央へ来るようスクロール', true);
  1182. key.setEditKey('C-n', function (ev) {
  1183. command.nextLine(ev);
  1184. }, '一行下へ');
  1185. key.setEditKey('C-p', function (ev) {
  1186. command.previousLine(ev);
  1187. }, '一行上へ');
  1188. key.setEditKey('C-o', function (ev) {
  1189. command.openLine(ev);
  1190. }, '行を開く (Open line)');
  1191. key.setGlobalKey('C-<right>', function (ev) {
  1192. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  1193. }, 'ひとつ右のタブへ');
  1194. key.setGlobalKey('C-<left>', function (ev) {
  1195. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  1196. }, 'ひとつ左のタブへ');