Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

_keysnail.js 44 KiB

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