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

_keysnail.js 35 KiB

13 vuotta sitten
11 vuotta sitten
11 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
11 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
11 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
11 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
11 vuotta sitten
11 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
11 vuotta sitten
11 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
11 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
13 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
11 vuotta sitten
12 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
12 vuotta sitten
13 vuotta sitten
11 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
11 vuotta sitten
13 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
12 vuotta sitten
13 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  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 like "whereToOpenLink is not defined.".
  26. // if no modifier key pressed open in new tab.
  27. // var whereToOpenLink_org = window.whereToOpenLink;
  28. // eval('window.whereToOpenLink = ' + whereToOpenLink_org.toString()
  29. // .replace('{',
  30. // '{ if(!e || ' +
  31. // '(!e.ctrlKey && !e.shiftKey && !e.metaKey && ' +
  32. // '!(e.altKKey && !ignoreAlt))) ' +
  33. // 'return "tab";')
  34. // );
  35. // This is useless because reload opens new tab.
  36. // window.whereToOpenLink = function(e, ib, ia){ return "tab"; };
  37. }, "open in new tab");
  38. ext.exec("open-bookmarks-in-new-tab");
  39. //////////////////////////////////////
  40. //// sitelocalkeymap
  41. var local = {};
  42. plugins.options["site_local_keymap.local_keymap"] = local;
  43. function fake(k, i) function(){ key.feed(k, i); };
  44. function pass(k, i) [k, fake(k, i)];
  45. function ignore(k, i) [k, null];
  46. // ext.add("ext-name", function () {}, "ext description");
  47. // style.register("");
  48. // local["^http://"] = [['a', function(ev, arg){}],];
  49. ///////////////////////////////////////////
  50. //// firefox
  51. // style.register("#bookmarksPanel > hbox,#history-panel > hbox {" +
  52. // "display: none !important;}" +
  53. // " //#urlbar-container{max-width: 500px !important;}");
  54. // style.register( //not work
  55. // <><![CDATA[
  56. // input,textarea {
  57. // font-family: monospace !important;
  58. // }
  59. // ]]></>.toString()
  60. // );
  61. style.register(
  62. '@-moz-document url-prefix(\"http://www.tumblr.com/\") { #pagination {' +
  63. 'position: fixed;' +
  64. 'bottom: 50px;' +
  65. 'right: 100px;' +
  66. 'padding-right: 0px !important' +
  67. '} }' , style.XHTML);
  68. ///////////////////////////////////
  69. //search engine
  70. plugins.options["search-url-list"] = [
  71. ["bing","http://bing.com/search?q=%q"],
  72. ["yatwitter search","http://yats-data.com/yats/search?query=%q"],
  73. ["twitter search","http://twitter.com/search?q=%q&lang=all"],
  74. ["tospy", "http://topsy.com/s?allow_lang=ja&q=%q"],
  75. ["2ch","http://2ch-ranking.net/search.php?q=%q&imp=and&order=time"],
  76. ["I\'m feelig lucky!","http://www.google.co.jp/search?q=%q&btnI=kudos"],
  77. ["uncyclopedia","http://ja.uncyclopedia.info/wiki/%q"],
  78. ["wikipedia","http://ja.wikipedia.org/wiki/%q"],
  79. ["nicovideo.jp","http://www.nicovideo.jp/search/%q"],
  80. ["alc","http://eow.alc.co.jp/%q/UTF-8/"],
  81. ["google map",
  82. "http://maps.google.co.jp/maps?hl=ja&q=%q&um=1&ie=UTF-8&sa=N&tab=wl"],
  83. ["weblio","http://www.weblio.jp/content_find?query=%q"],
  84. ["shoutcast","http://www.shoutcast.com/Internet-Radio/%q"],
  85. ["delicious 10sr",
  86. "http://delicious.com/10sr?addtag=%q&setcount=50&opennew=1"],
  87. ["open raw","%r"]
  88. ];
  89. plugins.options["my-keysnail-bookmarks"] = [
  90. "twitter.com"
  91. ];
  92. // sitelocal keymap
  93. //////////////////////////////////////////
  94. // 2ch chaika
  95. // change chaika port every time firefox starts
  96. util.setIntPref("extensions.chaika.server_port.firefox",
  97. 8800 + Math.floor(Math.random() * 30));
  98. local["^http://127.0.0.1:88"] = [
  99. ['k', function(ev, arg){
  100. curl = window.content.location.href;
  101. kurl = curl.replace(/http:.*thread\/(.*\/).*/, "chaika://post/$1");
  102. window.content.location.href = kurl;
  103. }
  104. ]
  105. ];
  106. local["^http://w2.p2.2ch.net/p2/read.php"] = [
  107. ['k', function(ev, arg){
  108. var url = window.content.location.href;
  109. var pt = /host=(.*?)&bbs=(.*?)&key=(.*?)&ls=/ ;
  110. var result = url.match(pt);
  111. var k = format("chaika://post/http://%s/test/read.cgi/%s/%s/",
  112. result[1], result[2], result[3]);
  113. window.content.location.href = k;
  114. }
  115. ]
  116. ];
  117. /////////////////////////////////////////
  118. // feedly
  119. local["^http://(www|cloud)\.feedly\.com/"] = [
  120. ['d', null],
  121. ['j', null],
  122. ['k', null],
  123. ['n', null],
  124. ['p', null],
  125. ['o', null],
  126. ['b', null],
  127. ['S', null],
  128. ['s', null],
  129. ['?', null],
  130. ['r', null],
  131. ['g', null],
  132. // ['x', function(ev, arg){
  133. // ev.target.dispatchEvent(key.stringToKeyEvent("g", true));
  134. // }],
  135. ['l', function(ev, arg){
  136. var host = window.content.location.host;
  137. if (host === "cloud.feedly.com") {
  138. window.content.location.href = "http://" + host + "/#latest";
  139. } else if (host === "www.feedly.com") {
  140. window.content.location.href = "http://" + host + "/home#latest";
  141. }
  142. }],
  143. [['t', 'p'], function(ev, arg){
  144. ev.target.dispatchEvent(key.stringToKeyEvent("t", true));
  145. }],
  146. [['t', 'w'], function(ev, arg){
  147. ext.exec("twitter-client-tweet", arg, ev);
  148. }]
  149. ];
  150. /////////////////////////////////////////
  151. //nicovideo
  152. local["http://(www|tw|es|de|)\.nicovideo\.jp\/(watch|playlist)/*"] = [
  153. ["i", function(ev, arg){ ext.exec("nicoinfo", arg); }],
  154. ["p", function(ev, arg){ ext.exec("nicopause", arg); }],
  155. // ["o", function(ev, arg){ ext.exec("nicommentvisible", arg); }],
  156. ["m", function(ev, arg){ ext.exec("nicomute", arg); }],
  157. [".", function(ev, arg){ ext.exec("nicovolumeIncrement", arg); }],
  158. [",", function(ev, arg){ ext.exec("nicovolumeDecrement", arg); }],
  159. ['f', function(ev, arg){
  160. curl = window.content.location.href;
  161. kurl = curl.replace(/nicovideo.jp/, "nicovideofire.jp");
  162. window.content.location.href = kurl;
  163. }
  164. ]
  165. ];
  166. /////////////////////////////////////////
  167. // tumblr/dashboard
  168. local["^http://www.tumblr.com/dashboard"] = [
  169. // ["C-<left>", function(ev, arg){
  170. // gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  171. // }],
  172. // ["C-<right>", function(ev, arg){
  173. // gBrowser.mTabContainer.advanceSelectedTab(1, true);
  174. // }],
  175. ["<left>", function(ev, arg){
  176. window.content.location.href = "http://www.tumblr.com/dashboard";
  177. }],
  178. ["<right>", null],
  179. ["J", function(ev, arg){
  180. if (window.loadURI) {
  181. 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;}())");
  182. }
  183. }]
  184. ];
  185. ///////////////////////////////////////////
  186. // plugin option
  187. plugins.options["builtin_commands_ext.ext_list"] = [
  188. "focus-to-prompt",
  189. "open-url-from-clipboard",
  190. "restart-firefox"
  191. ];
  192. plugins.options["instapaper.close_after_post"] = true;
  193. plugins.options["instapaper.initial_comment_function"] = function(){
  194. var now = new Date();
  195. return "[" + now.toString() + "]";
  196. };
  197. //////////////////////////////////////////
  198. // yatc
  199. style.register("#keysnail-twitter-client-container{ display:none !important; }");
  200. plugins.options["twitter_client.popup_new_statuses"] = false;
  201. plugins.options["twitter_client.automatically_begin"] = false;
  202. plugins.options["twitter_client.automatically_begin_list"] = false;
  203. plugins.options["twitter_client.timeline_count_beginning"] = 0;
  204. plugins.options["twitter_client.timeline_count_every_updates"] = 0;
  205. plugins.options["twitter_client.tweet_keymap"] = {
  206. "C-RET" : "prompt-decide",
  207. "RET" : ""
  208. };
  209. plugins.options["twitter_client.jmp_id"] = "10sr";
  210. plugins.options["twitter_client.jmp_key"] =
  211. "R_c51f889a77cb4b4e993ed868f65083f5";
  212. plugins.options["twitter_client.use_jmp"] = true;
  213. ////////////////////////////////////////////
  214. // my ext
  215. (function(){
  216. function getOrganizer(){
  217. // [How to call for Firefox bookmark dialog? - Stack Overflow]
  218. // (http://stackoverflow.com/questions/9158187/how-to-call-for-firefox-bookmark-dialog)
  219. Components.utils.import("resource://gre/modules/Services.jsm");
  220. var organizer = Services.wm.getMostRecentWindow("Places:Organizer");
  221. if (!organizer) {
  222. // No currently open places window,
  223. // so open one with the specified mode.
  224. openDialog("chrome://browser/content/places/places.xul",
  225. "",
  226. "chrome,toolbar=yes,dialog=no,resizable",
  227. "AllBookmarks");
  228. return null;
  229. } else {
  230. return organizer;
  231. }
  232. }
  233. ext.add("export-bookmarks", function(ev, arg){
  234. var organizer = getOrganizer();
  235. if (organizer) {
  236. organizer.PlacesOrganizer.exportBookmarks();
  237. }
  238. }, "export bookmarks");
  239. ext.add("import-bookmarks", function(ev, arg){
  240. var organizer = getOrganizer();
  241. if (organizer) {
  242. organizer.PlacesOrganizer.importBookmarks();
  243. }
  244. }, "import bookmarks");
  245. })();
  246. ext.add("my-index-html", function(ev, arg){
  247. homepath = util.getEnv("HOME");
  248. file = ".index.html";
  249. if (homepath) {
  250. path = "file://" + homepath + "/" + file;
  251. window.openUILinkIn(path, "tab");
  252. }
  253. }, "open my index.html");
  254. ext.add("echo-tab-info", function(){
  255. var all = gBrowser.tabs.length;
  256. var ix = gBrowser.mCurrentTab._tPos;
  257. var title = window.document.title;
  258. var url = window.content.location.href;
  259. display.echoStatusBar((ix + 1).toString() + " / " +
  260. all.toString() + " : " +
  261. title + " <" +
  262. url + ">");
  263. }, "echo tab info");
  264. ext.add("strong-fullscreen", function(){
  265. var elemids = [
  266. "navigator-toolbox"
  267. ];
  268. BrowserFullScreen();
  269. var isfullscreen = window.fullScreen;
  270. for(var i = 0; i < elemids.length; i++){
  271. var elem = document.getElementById(elemids[i]);
  272. if(elem){
  273. if(isfullscreen){
  274. elem.style.display = "none";
  275. }else{
  276. elem.style.display = null;
  277. }
  278. }
  279. }
  280. var tabs = document.getElementById("verticaltabs-box");
  281. if(tabs){
  282. var pref_key = "extensions.verticaltabs.width";
  283. var pref_key_bak = pref_key + "_bak";
  284. if(isfullscreen){
  285. var width_orig = util.getIntPref(pref_key);
  286. util.setIntPref(pref_key_bak, width_orig);
  287. util.setIntPref(pref_key, 0);
  288. tabs.setAttribute("width", "0");
  289. }else if(parseInt(tabs.getAttribute("width") || "") === 0){
  290. var width_bak = util.getIntPref(pref_key_bak);
  291. util.setIntPref(pref_key, width_bak);
  292. tabs.setAttribute("width", width_bak.toString());
  293. }
  294. }
  295. }, "go fullscreen with hiding toolbar and tabbar");
  296. ext.add("bookmark-delicious", function(){
  297. f= 'http://www.delicious.com/save?url=' +
  298. encodeURIComponent(window.content.location.href) +
  299. '&title=' + encodeURIComponent(document.title) +
  300. '&notes=' + encodeURIComponent(
  301. '' + (window.getSelection ?
  302. window.getSelection() : (
  303. document.getSelection ?
  304. document.getSelection() :
  305. document.selection.createRange().text))) + '&v=6&';
  306. a = function(){
  307. if(! window.open(
  308. f + 'noui=1&jump=doclose',
  309. 'deliciousuiv6',
  310. 'location=1,links=0,scrollbars=0,toolbar=0,width=710,height=660')){
  311. location.href = f + 'jump=yes';
  312. }
  313. };
  314. if(/Firefox/.test(navigator.userAgent)){
  315. setTimeout(a,0);
  316. }else{
  317. a();
  318. }
  319. }, "bookmark delicious");
  320. ext.add('view-page-source', function(){
  321. window.content.location.href = "view-source:" +
  322. window.content.location.href;
  323. }, 'view page source');
  324. ext.add('my-setpref', function(){
  325. util.setPrefs(
  326. {
  327. "browser.bookmarks.max_backups":0,
  328. "browser.cache.memory.capacity":16384,
  329. "browser.download.manager.closeWhenDone":true,
  330. "browser.download.useDownloadDir":false,
  331. "browser.fullscreen.autohide":false,
  332. "browser.search.openintab":true,
  333. "browser.sessionhistory.max_total_viewers":8,
  334. "browser.sessionstore.restore_on_demand":true,
  335. "browser.tabs.closeWindowWithLastTab":false,
  336. "browser.tabs.loadDivertedInBackground": true,
  337. "browser.urlbar.autocomplete.enabled":false,
  338. "browser.urlbar.trimURLs":false,
  339. "dom.disable_window_open_feature.location": false,
  340. "dom.max_script_run_time": 30,
  341. "extensions.chaika.bbsmenu.open_new_tab":true,
  342. "extensions.chaika.bbsmenu.open_single_click":false,
  343. "extensions.chaika.board.open_new_tab":true,
  344. "extensions.chaika.board.open_single_click":false,
  345. "extensions.foxage2ch.openThreadInTab":true,
  346. "extensions.saveimageinfolder.general-duplicatefilenamevalue":1,
  347. "extensions.saveimageinfolder.general-fileprefixvalue":
  348. "%yyyy%%MM%%dd%-%hh%%mm%%ss%_",
  349. "extensions.saveimageinfolder.usecache":true,
  350. "extensions.tabutils.openTabNext":1,
  351. "extensions.tabutils.styles.current":
  352. "{\"bold\":true,\"italic\":false,\"underline\":true,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#000000\",\"bgColor\":false,\"bgColorCode\":\"#000000\",\"outline\":false,\"outlineColorCode\":\"#000000\"}",
  353. "extensions.tabutils.styles.unread":
  354. "{\"bold\":false,\"italic\":false,\"underline\":false,\"strikethrough\":false,\"color\":true,\"colorCode\":\"#CC0000\",\"bgColor\":false,\"bgColorCode\":\"undefined\",\"outline\":false,\"outlineColorCode\":\"undefined\"}",
  355. "extensions.yass.edgetype":0,
  356. "extensions.yass.selectedpreset":"red",
  357. "font.default.x-western":"sans-serif",
  358. "gecko.handlerService.schemes.mailto.1.name":"Gmail",
  359. "general.warnOnAboutConfig":false,
  360. "keyword.URL":"http://www.bing.com/search?q=",
  361. "network.dns.disableIPv6":true,
  362. "refcontrol.actions":
  363. "@DEFAULT=@FORGE www.heartrails.com=@NORMAL www.pixiv.net=@NORMAL",
  364. "scrapbook.tabs.open":true
  365. }
  366. );
  367. if(/^Linux/.test(navigator.platform)){
  368. util.setPrefs(
  369. {
  370. "browser.cache.disk.parent_directory":"/tmp",
  371. "browser.cache.disk.capacity":524288
  372. }
  373. );
  374. }
  375. display.showPopup("Keysnail", "My prefs done.");
  376. }, 'my setpref');
  377. ext.add('auto-install-plugins', function(ev, arg){
  378. var urls = [
  379. 'https://raw.github.com/mooz/keysnail/master/plugins/yet-another-twitter-client-keysnail.ks.js',
  380. 'https://raw.github.com/mooz/keysnail/master/plugins/site-local-keymap.ks.js',
  381. 'https://raw.github.com/mooz/keysnail/master/plugins/hok.ks.js',
  382. 'https://github.com/mooz/keysnail/raw/master/plugins/builtin-commands-ext.ks.js',
  383. 'https://raw.github.com/azu/KeySnail-Plugins/master/JSReference/js-referrence.ks.js',
  384. 'https://raw.github.com/gongo/keysnail_plugin/master/linksnail.ks.js',
  385. 'https://raw.github.com/tkosaka/keysnail-plugin/master/nicontroller.ks.js',
  386. 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
  387. 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js',
  388. 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js',
  389. 'https://raw.github.com/10sr/keysnail-plugin/master/pixiv_autojump.ks.js',
  390. 'https://raw.github.com/10sr/keysnail-plugin/master/list-current-urls.ks.js',
  391. 'https://raw.github.com/gist/1976942/firefox-addon-manager.ks.js',
  392. 'https://raw.github.com/gist/1450594/mstranslator.ks.js'
  393. ];
  394. function inst(a){
  395. if(a.length == 0){
  396. display.showPopup("auto-install-plugins",
  397. "All installation finished.");
  398. }else{
  399. var url = a.shift();
  400. var path = userscript.pluginDir +
  401. userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
  402. if(plugins.context[path] === undefined){
  403. userscript.installPluginFromURL(url, function(){inst(a);});
  404. }else{
  405. inst(a);
  406. }
  407. }
  408. }
  409. inst(urls);
  410. }, 'Install plugins automatically if not installed yet.');
  411. ext.add('put-aside-this-page', function (ev, arg) {
  412. var n = gBrowser.mCurrentTab._tPos;
  413. gBrowser.moveTabTo(gBrowser.mCurrentTab, 0);
  414. if (n != 0) {
  415. gBrowser.selectedTab = gBrowser.mTabs[n];
  416. }
  417. }, 'put aside this page');
  418. ext.add('send-escape', function (ev, arg) {
  419. ev.target.dispatchEvent(key.stringToKeyEvent("ESC", true));
  420. }, 'escape');
  421. ext.add("open-hatebu-comment", function (ev, arg) {
  422. var url = window.content.location.href.replace(/^[^/]*\/\//, "");
  423. window.content.location.href = "http://b.hatena.ne.jp/entry/" + url;
  424. }, 'hatebu');
  425. // ext.add("focus-on-content", function(){
  426. // let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  427. // gBrowser.focus();
  428. // content.focus();
  429. // }, "forcus on content");
  430. ext.add("hide-sidebar", function(){
  431. var sidebarBox = document.getElementById("sidebar-box");
  432. if (!sidebarBox.hidden) {
  433. toggleSidebar(sidebarBox.getAttribute("sidebarcommand"));
  434. }
  435. }, "hide-sidebar");
  436. ext.add("close-and-next-tab", function (ev, arg) {
  437. var n = gBrowser.mCurrentTab._tPos;
  438. gBrowser.removeCurrentTab();
  439. gBrowser.selectedTab = gBrowser.mTabs[n];
  440. }, "close and focus to next tab");
  441. //////////////////////////////////////
  442. //
  443. ext.add("restart-firefox-add-menu", function(){
  444. const XUL_NS =
  445. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  446. var cmdelm = document.createElementNS(XUL_NS, "command");
  447. cmdelm.setAttribute("id", "my_cmd_restartFirefoxKs");
  448. cmdelm.setAttribute("oncommand", "ext.exec('restart-firefox');");
  449. var commandset = document.getElementById("mainCommandSet");
  450. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  451. commandset.appendChild(cmdelm);
  452. var menuelm = document.createElementNS(XUL_NS, "menuitem");
  453. menuelm.setAttribute("label", "Restart Firefox");
  454. menuelm.setAttribute("id", "my_menu_restartFirefoxKs");
  455. menuelm.setAttribute("command", "my_cmd_restartFirefoxKs");
  456. var menu = document.getElementById("menu_FilePopup");
  457. // menu.insertBefore(elm, menu.getElementById("menu_FileQuitItem"));
  458. menu.appendChild(menuelm);
  459. }, "add restart firefox menu");
  460. /////////////////////////////////////////
  461. // feed url
  462. (function(){
  463. function getFeeds(){
  464. const doc = content.document;
  465. var feeds = [[e.getAttribute("title"), e.getAttribute("href")]
  466. for ([, e] in Iterator(doc.querySelectorAll([
  467. 'link[type="application/rss+xml"]',
  468. 'link[type="application/atom+xml"]'
  469. ])))];
  470. var uh = window.content.location.href.replace(/(.*?\/\/[^/]*)(\/.*)?/,
  471. "$1");
  472. for (i = 0; i < feeds.length; i++)
  473. if ( feeds[i][1].substr(0,1) == "/" ) feeds[i][1] = uh + feeds[i][1];
  474. feeds.unshift([window.content.document.title,
  475. window.content.location.href]);
  476. return feeds;
  477. };
  478. ext.add("copy-feed-url", function () {
  479. var feeds = getFeeds();
  480. prompt.selector(
  481. {
  482. message : "Select Feed",
  483. collection : feeds,
  484. callback : function (i) {
  485. if (i >= 0) {
  486. command.setClipboardText(feeds[i][1]);
  487. }
  488. }
  489. }
  490. );
  491. }, "Copy url or feed url of current page");
  492. ext.add("open-feed", function () {
  493. var feeds = getFeeds();
  494. prompt.selector(
  495. {
  496. message : "Select Feed",
  497. collection : feeds,
  498. callback : function (i) {
  499. if (i >= 0) {
  500. window.openUILinkIn(feeds[i][1], "tab");
  501. }
  502. }
  503. }
  504. );
  505. }, "Copy url or feed url of current page");
  506. })();
  507. ///////////////////////////////////////
  508. // keysnail z menu
  509. ext.add("keysnail-setting-dialog", function(){
  510. KeySnail.openPreference();
  511. }, "keysnail setting dialog");
  512. ext.add("keysnail-plugin-manager", function(){
  513. userscript.openPluginManager();
  514. }, "keysnail plugin manager");
  515. ext.add("firefox-open-addon-manager", function(){
  516. BrowserOpenAddonsMgr();
  517. }, "firefox addon manager");
  518. ext.add("keysnail-reload-init-file", function(){
  519. userscript.reload();
  520. }, "keysnail reload init file");
  521. ext.add("keysnail-z-menu",function(){
  522. var list = [["keysnail-setting-dialog"],
  523. ["keysnail-plugin-manager"],
  524. ["firefox-open-addon-manager"],
  525. ["keysnail-reload-init-file"],
  526. // ["check-for-plugins-update"],
  527. ["restart-firefox"]
  528. ];
  529. prompt.selector(
  530. {
  531. message : "open setting dialog",
  532. collection : list,
  533. callback : function (i) {
  534. ext.exec(list[i][0]);
  535. }
  536. });
  537. },"open keysnail z menu");
  538. ///////////////////////////////////
  539. // search web
  540. ext.add("query-then-engine", function () {
  541. prompt.reader({
  542. message : "Search Word?:",
  543. group : "query_word",
  544. completer : completer.matcher.header(share.friendsCache || []),
  545. callback : function (q) {
  546. if (q) {
  547. prompt.selector({
  548. message : "search \"" + q + "\" with?",
  549. collection : plugins.options["search-url-list"],
  550. width : [20,80],
  551. callback : function (i) {
  552. getBrowser().selectedTab =
  553. getBrowser().addTab(
  554. plugins.options["search-url-list"][i][1].
  555. replace("%r",q).replace(
  556. "%q",encodeURIComponent(q)));
  557. }
  558. });
  559. };
  560. },
  561. initialInput : content.document.getSelection() || ""
  562. });
  563. }, "enter search word and then select engine");
  564. /////////////////////////////////////
  565. // closed tab list
  566. ext.add("list-closed-tabs", function () {
  567. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  568. var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(
  569. Ci.nsISessionStore
  570. );
  571. var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
  572. var closedTabs = [[tab.image || fav, tab.title, tab.url]
  573. for each (tab in json.decode(ss.getClosedTabData(window)))
  574. ];
  575. if (!closedTabs.length)
  576. return void display.echoStatusBar("No recently closed tab.", 2000);
  577. prompt.selector(
  578. {
  579. message : "select tab to undo:",
  580. collection : closedTabs,
  581. flags : [ICON | IGNORE, 0, 0],
  582. callback : function (i) { if (i >= 0) window.undoCloseTab(i); }
  583. });
  584. }, "List closed tabs");
  585. ///////////////////////////////
  586. // http://malblue.tumblr.com/post/349001250/tips-japanese-keysnail-github
  587. ext.add("list-tab-history", function () {
  588. const fav = "chrome://mozapps/skin/places/defaultFavicon.png";
  589. var tabHistory = [];
  590. var sessionHistory = gBrowser.webNavigation.sessionHistory;
  591. if (sessionHistory.count < 1)
  592. return void display.echoStatusBar("Tab history not exist", 2000);
  593. var curIdx = sessionHistory.index;
  594. for (var i = 0; i < sessionHistory.count; i++) {
  595. var entry = sessionHistory.getEntryAtIndex(i, false);
  596. if (!entry)
  597. continue;
  598. try {
  599. var iconURL = Cc["@mozilla.org/browser/favicon-service;1"]
  600. .getService(Ci.nsIFaviconService)
  601. .getFaviconForPage(entry.URI).spec;
  602. } catch (ex) {}
  603. tabHistory.push([iconURL || fav, entry.title, entry.URI.spec, i]);
  604. }
  605. for (var thIdx = 0; thIdx < tabHistory.length; thIdx++) {
  606. if (tabHistory[thIdx][3] == curIdx) break;
  607. }
  608. prompt.selector(
  609. {
  610. message : "select history in tab",
  611. collection : tabHistory,
  612. flags : [ICON | IGNORE, 0, 0, IGNORE | HIDDEN],
  613. header : ["Title", "URL"],
  614. initialIndex : thIdx,
  615. callback : function(i) {
  616. if (i >= 0) gBrowser.webNavigation.gotoIndex(tabHistory[i][3]);
  617. }
  618. });
  619. }, 'List tab history');
  620. //}}%PRESERVE%
  621. // ========================================================================= //
  622. // ========================= Special key settings ========================== //
  623. key.quitKey = "ESC";
  624. key.helpKey = "<f1>";
  625. key.escapeKey = "C-q";
  626. key.macroStartKey = "";
  627. key.macroEndKey = "";
  628. key.universalArgumentKey = "C-u";
  629. key.negativeArgument1Key = "C--";
  630. key.negativeArgument2Key = "C-M--";
  631. key.negativeArgument3Key = "M--";
  632. key.suspendKey = "Not defined";
  633. // ================================= Hooks ================================= //
  634. hook.setHook('KeyBoardQuit', function (aEvent) {
  635. ext.exec("hide-sidebar");
  636. let(elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  637. gBrowser.focus();
  638. content.focus();
  639. command.closeFindBar();
  640. if (util.isCaretEnabled()) {
  641. command.resetMark(aEvent);
  642. } else {
  643. goDoCommand("cmd_selectNone");
  644. }
  645. key.generateKey(aEvent.originalTarget, KeyEvent.DOM_VK_ESCAPE, true);
  646. });
  647. hook.setHook('Unload', function () {
  648. util.getBrowserWindows().some(function (win) {
  649. if (win === window) {
  650. return false;
  651. }
  652. const ks = win.KeySnail;
  653. share.pluginUpdater = ks.getPluginUpdater(
  654. share.pluginUpdater.pluginsWithUpdate
  655. );
  656. ks.setUpPluginUpdaterDelegator();
  657. return true;
  658. });
  659. });
  660. // ============================= Key bindings ============================== //
  661. key.setGlobalKey('C-<right>', function () {
  662. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  663. }, 'ひとつ右のタブへ');
  664. key.setGlobalKey('C-<left>', function () {
  665. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  666. }, 'ひとつ左のタブへ');
  667. key.setGlobalKey('C-<up>', function () {
  668. var browser = getBrowser();
  669. if (browser.mCurrentTab.previousSibling) {
  670. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  671. } else {
  672. browser.moveTabTo(browser.mCurrentTab,
  673. browser.mTabContainer.childNodes.length - 1);
  674. }
  675. }, '選択中のタブを右へ');
  676. key.setGlobalKey('C-<down>', function () {
  677. var browser = getBrowser();
  678. if (browser.mCurrentTab.nextSibling) {
  679. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  680. } else {
  681. browser.moveTabTo(browser.mCurrentTab, 0);
  682. }
  683. }, '選択中のタブを左へ');
  684. key.setGlobalKey('<delete>', function (ev, arg) {
  685. let (elem = document.commandDispatcher.focusedElement) elem && elem.blur();
  686. gBrowser.focus();
  687. content.focus();
  688. }, 'コンテンツへフォーカス', true);
  689. key.setGlobalKey('<f11>', function (ev, arg) {
  690. ext.exec("strong-fullscreen", arg, ev);
  691. }, 'go fullscreen with hiding toolbar and tabbar', true);
  692. key.setViewKey('0', function (ev) {
  693. BrowserCloseTabOrWindow();
  694. }, 'タブ / ウィンドウを閉じる');
  695. key.setViewKey('N', function (ev) {
  696. getBrowser().mTabContainer.advanceSelectedTab(1, true);
  697. }, 'ひとつ右のタブへ');
  698. key.setViewKey('P', function (ev) {
  699. getBrowser().mTabContainer.advanceSelectedTab(-1, true);
  700. }, 'ひとつ左のタブへ');
  701. key.setViewKey('o', function (ev, arg) {
  702. ext.exec("hok-start-foreground-mode", arg, ev);
  703. }, 'Start Hit a Hint foreground mode', true);
  704. key.setViewKey('c', function (ev) {
  705. command.interpreter();
  706. }, 'JavaScript のコードを評価');
  707. key.setViewKey('D', function (ev, arg) {
  708. ext.exec("dig-url", arg, ev);
  709. }, 'dig url with selector', true);
  710. key.setViewKey('x', function (aEvent, aArg) {
  711. ext.select(aArg, aEvent);
  712. }, 'エクステ一覧');
  713. key.setViewKey(['t', 'w'], function (ev, arg) {
  714. ext.exec("twitter-client-tweet", arg, ev);
  715. }, 'つぶやく', true);
  716. key.setViewKey(['t', 'p'], function (ev, arg) {
  717. ext.exec("twitter-client-tweet-this-page", arg, ev);
  718. }, 'このページのタイトルと URL を使ってつぶやく', true);
  719. key.setViewKey([['u'], ['<left>']], function (ev) {
  720. goDoCommand("cmd_scrollPageUp");
  721. }, '一画面分スクロールアップ');
  722. key.setViewKey('g', function () {
  723. goDoCommand("cmd_scrollTop");
  724. }, 'ページ先頭へ移動');
  725. key.setViewKey('G', function () {
  726. goDoCommand("cmd_scrollBottom");
  727. }, 'ページ末尾へ移動');
  728. key.setViewKey('r', function (aEvent) {
  729. BrowserReload();
  730. }, '再読み込み');
  731. key.setViewKey('m', function (ev, arg) {
  732. _fi.toogle();
  733. }, 'fetchimiをトグル');
  734. key.setViewKey('SPC', function (ev, arg) {
  735. MultipleTabService.toggleSelection(gBrowser.mCurrentTab);
  736. gBrowser.mTabContainer.advanceSelectedTab(1, true);
  737. }, 'タブの選択をトグルして次のタブ');
  738. key.setViewKey('S-SPC', function (ev, arg) {
  739. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  740. gBrowser.mTabContainer.advanceSelectedTab(-1, true);
  741. }, 'タブの選択をトグルして前のタブ');
  742. key.setViewKey('z', function (ev, arg) {
  743. ext.exec("keysnail-z-menu", arg, ev);
  744. }, 'open keysnail setting menu', true);
  745. key.setViewKey('C-SPC', function (ev, arg) {
  746. MultipleTabService.toggleSelection(gBrowser.selectedTab);
  747. }, 'タブの選択をトグル');
  748. key.setViewKey('e', function () {
  749. command.focusElement(command.elementsRetrieverTextarea, 0);
  750. }, '最初のインプットエリアへフォーカス', true);
  751. key.setViewKey('S', function (ev, arg) {
  752. if (window.loadURI) {
  753. 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{}");
  754. }
  755. }, 'google reader share');
  756. key.setViewKey('!', function (ev, arg) {
  757. shell.input();
  758. }, 'Command system');
  759. key.setViewKey('R', function () {
  760. BrowserReloadSkipCache();
  761. }, '更新(キャッシュを無視)');
  762. key.setViewKey('<backspace>', function () {
  763. BrowserBack();
  764. }, '戻る');
  765. key.setViewKey('S-<backspace>', function () {
  766. BrowserForward();
  767. }, '進む');
  768. key.setViewKey('q', function (ev, arg) {
  769. ext.exec("query-then-engine", arg, ev);
  770. }, 'enter search word and then select engine', true);
  771. key.setViewKey('/', function () {
  772. command.iSearchForward();
  773. }, 'インクリメンタル検索', true);
  774. key.setViewKey('?', function (ev) {
  775. command.iSearchForwardKs(ev);
  776. }, 'Emacs ライクなインクリメンタル検索', true);
  777. key.setViewKey('a', function (ev, arg) {
  778. allTabs.open();
  779. }, 'alltabs.open');
  780. key.setViewKey([['<right>'], ['d']], function (ev) {
  781. goDoCommand("cmd_scrollPageDown");
  782. }, '一画面スクロールダウン');
  783. key.setViewKey([['<prior>'], ['<next>']], function (ev, arg) {
  784. return;
  785. }, 'ignore');
  786. key.setViewKey(':', function (ev, arg) {
  787. return !document.getElementById("keysnail-prompt").hidden &&
  788. document.getElementById("keysnail-prompt-textbox").focus();
  789. }, 'KeySnail のプロンプトへフォーカス', true);
  790. key.setViewKey('B', function (ev) {
  791. var browser = getBrowser();
  792. if (browser.mCurrentTab.previousSibling) {
  793. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
  794. } else {
  795. browser.moveTabTo(browser.mCurrentTab,
  796. browser.mTabContainer.childNodes.length - 1);
  797. }
  798. }, '選択中のタブを左へ');
  799. key.setViewKey('C', function (ev, arg) {
  800. ext.exec("linksnail", arg, ev);
  801. }, 'LinkSnail', true);
  802. key.setViewKey('C-<backspace>', function (ev, arg) {
  803. ext.exec("list-tab-history", arg, ev);
  804. }, 'List tab history', true);
  805. key.setViewKey('I', function (ev, arg) {
  806. ext.exec("instapaper-post-page-with-comment", arg, ev);
  807. }, 'post page and comment', true);
  808. key.setViewKey('T', function (ev, arg) {
  809. ext.exec("mstranslator-open-prompt", arg, ev);
  810. }, 'MSTranslator - Open prompt', true);
  811. key.setViewKey('n', function (ev) {
  812. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
  813. }, '一行スクロールダウン');
  814. key.setViewKey('p', function (ev) {
  815. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
  816. }, '一行スクロールアップ');
  817. key.setViewKey('f', function (ev) {
  818. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RIGHT, true);
  819. }, '右へスクロール');
  820. key.setViewKey('b', function (ev) {
  821. key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true);
  822. }, '左へスクロール');
  823. key.setViewKey('F', function (ev) {
  824. var browser = getBrowser();
  825. if (browser.mCurrentTab.nextSibling) {
  826. browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
  827. } else {
  828. browser.moveTabTo(browser.mCurrentTab, 0);
  829. }
  830. }, '選択中のタブを右へ');
  831. key.setViewKey('U', function (ev, arg) {
  832. ext.exec("list-closed-tabs", arg, ev);
  833. }, 'List closed tabs', true);
  834. key.setEditKey('C-<tab>', function (ev) {
  835. command.walkInputElement(command.elementsRetrieverTextarea, true, true);
  836. }, '次のテキストエリアへフォーカス');
  837. key.setEditKey('C-a', function (ev) {
  838. command.beginLine(ev);
  839. }, '行頭へ移動');
  840. key.setEditKey('C-e', function (ev) {
  841. command.endLine(ev);
  842. }, '行末へ');
  843. key.setEditKey('C-d', function (ev) {
  844. goDoCommand("cmd_deleteCharForward");
  845. }, '次の一文字削除');
  846. key.setEditKey('C-b', function (ev) {
  847. command.previousChar(ev);
  848. }, '一文字左へ移動');
  849. key.setEditKey('C-f', function (ev) {
  850. command.nextChar(ev);
  851. }, '一文字右へ移動');
  852. key.setEditKey('C-h', function (ev) {
  853. goDoCommand("cmd_deleteCharBackward");
  854. }, '前の一文字を削除');
  855. key.setEditKey('C-k', function (ev) {
  856. command.killLine(ev);
  857. }, 'カーソルから先を一行カット (Kill line)');
  858. key.setEditKey('C-l', function (ev) {
  859. command.recenter(ev);
  860. }, 'カーソル位置が画面の中央へ来るようスクロール', true);
  861. key.setEditKey('C-n', function (ev) {
  862. command.nextLine(ev);
  863. }, '一行下へ');
  864. key.setEditKey('C-p', function (ev) {
  865. command.previousLine(ev);
  866. }, '一行上へ');
  867. key.setEditKey('C-o', function (ev) {
  868. command.openLine(ev);
  869. }, '行を開く (Open line)');
  870. key.setViewKey('f', function (ev, arg) {
  871. ext.exec('strong-fullscreen', arg, ev);
  872. }, 'go fullscreen with hiding toolbar and tabbar', true);