From 9a8cf4e8a04daad9865d00075c269f04adaefcf8 Mon Sep 17 00:00:00 2001 From: janus_wel Date: Tue, 21 Oct 2008 10:27:41 +0000 Subject: liberator -> liberator.modules - buffer - commandline - commands - hints - ..etc コマンド追加時に使う addUserCommand の第 3 引数に指定する関数の第 1 引数が String から Object に変更したのに対応 - ldrize_cooperation_fetch_flv.js - lookupDictionary.js - matanico.js - nicontroller.js - nnp_cooperation.js - reading.js - youtubeamp.js migemo_hint.js で一時的にグローバルオブジェクト plugins を定義 応急処置なのであとで削る必要あり git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@21797 d0d07461-0603-4401-acd4-de1884942a52 --- autoIgnoreKey.js | 2 +- direct_bookmark.js | 26 +++++++------- ldrize_cooperation.js | 68 ++++++++++++++++++------------------ ldrize_cooperation_fetch_flv.js | 8 ++--- lookupDictionary.js | 4 ++- matanico.js | 16 +++++---- migemo_hint.js | 5 ++- nicontroller.js | 76 ++++++++++++++++++++++++----------------- nnp_cooperation.js | 28 ++++++++------- reading.js | 16 +++++---- youtubeamp.js | 40 ++++++++++++++-------- 11 files changed, 163 insertions(+), 126 deletions(-) diff --git a/autoIgnoreKey.js b/autoIgnoreKey.js index 8dc4ca1..ce3de31 100644 --- a/autoIgnoreKey.js +++ b/autoIgnoreKey.js @@ -44,7 +44,7 @@ getBrowser().mTabBox.addEventListener('TabSelect',passAllKeysIfTarget,false); function passAllKeysIfTarget() { var uri = content.document.documentURI; - liberator.modes.passAllKeys = isMatch(uri); + liberator.modules.modes.passAllKeys = isMatch(uri); //liberator.log('load page: ' + gBrowser.selectedBrowser.contentDocument.URL); } diff --git a/direct_bookmark.js b/direct_bookmark.js index d1058e1..f035c23 100644 --- a/direct_bookmark.js +++ b/direct_bookmark.js @@ -1,6 +1,6 @@ // Vimperator plugin: 'Direct Post to Social Bookmarks' // Version: 0.12 -// Last Change: 22-Sep-2008. Jan 2008 +// Last Change: 21-Oct-2008. Jan 2008 // License: Creative Commons // Maintainer: Trapezoid - http://unsigned.g.hatena.ne.jp/Trapezoid // Parts: @@ -396,7 +396,7 @@ return returnValue; }, icon:function(url){ - var url = liberator.buffer.URL; + var url = liberator.modules.buffer.URL; var cryptoHash = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash); cryptoHash.init(Ci.nsICryptoHash.MD5); var inputStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream); @@ -540,9 +540,9 @@ .error(function(e){liberator.echoerr("direct_bookmark.js: Exception throwed! " + e)}); return first; } - liberator.commands.addUserCommand(['btags'],"Update Social Bookmark Tags", + liberator.modules.commands.addUserCommand(['btags'],"Update Social Bookmark Tags", function(arg){setTimeout(function(){getTags().call([])},0)}, {}); - liberator.commands.addUserCommand(['bentry'],"Goto Bookmark Entry Page", + liberator.modules.commands.addUserCommand(['bentry'],"Goto Bookmark Entry Page", function(service, special){ service = service || useServicesByPost.split(/\s*/)[0]; var currentService = services[service] || null; @@ -551,10 +551,10 @@ } liberator.open(currentService.entryPage .replace(/%URL(?:::(ESC|MD5))?%/g, function(x, t){ - if(!t) return liberator.buffer.URL.replace(/#/, '%23'); - if(t == "ESC") return encodeURIComponent(liberator.buffer.URL); + if(!t) return liberator.modules.buffer.URL.replace(/#/, '%23'); + if(t == "ESC") return encodeURIComponent(liberator.modules.buffer.URL); if(t == "MD5"){ - var url = liberator.buffer.URL; + var url = liberator.modules.buffer.URL; var cryptoHash = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash); cryptoHash.init(Ci.nsICryptoHash.MD5); var inputStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream); @@ -575,9 +575,9 @@ [0, useServicesByPost.split(/\s*/).map(function(p) [p, services[p].description])] } ); - liberator.commands.addUserCommand(['bicon'],"Show Bookmark Count as Icon", + liberator.modules.commands.addUserCommand(['bicon'],"Show Bookmark Count as Icon", function(arg){ - var url = getNormalizedPermalink(liberator.buffer.URL); + var url = getNormalizedPermalink(liberator.modules.buffer.URL); var html = useServicesByTag.split(/\s*/).map(function(service){ var currentService = services[service] || null; return (currentService && typeof currentService.icon === 'function') ? @@ -585,7 +585,7 @@ }).join('
'); liberator.echo(html, true); }, {}); - liberator.commands.addUserCommand(['sbm'],"Post to Social Bookmark", + liberator.modules.commands.addUserCommand(['sbm'],"Post to Social Bookmark", function(arg){ var comment = ""; var targetServices = useServicesByPost; @@ -615,8 +615,8 @@ comment = text || ''; } - var url = liberator.buffer.URL; - var title = liberator.buffer.title; + var url = liberator.modules.buffer.URL; + var title = liberator.modules.buffer.title; targetServices.split(/\s*/).forEach(function(service){ var user, password, currentService = services[service] || null; @@ -640,7 +640,7 @@ for each (tag in liberator.plugins.direct_bookmark.tags) if (m.test(tag) && match_result[1].indexOf('[' + tag + ']') < 0)]]; }, options: [ - [['-s','-service'], liberator.commands.OPTION_STRING], + [['-s','-service'], liberator.modules.commands.OPTION_STRING], ] } ); diff --git a/ldrize_cooperation.js b/ldrize_cooperation.js index b353162..f431e29 100644 --- a/ldrize_cooperation.js +++ b/ldrize_cooperation.js @@ -1,6 +1,6 @@ // Vimperator plugin: 'Cooperation LDRize Mappings' // Version: 0.21 -// Last Change: 13-Jun-2008. Jan 2008 +// Last Change: 21-Oct-2008. Jan 2008 // License: Creative Commons // Maintainer: Trapezoid - http://unsigned.g.hatena.ne.jp/Trapezoid // @@ -161,12 +161,12 @@ this.addAfter(GreasemonkeyService,'evalInSandbox',function(code,codebase,sandbox){ if(sandbox.window.LDRize != undefined && sandbox.window.Minibuffer != undefined){ sandbox.window.addEventListener("focus",function(){ - self.LDRize = window.eval("self",sandbox.LDRize.getSiteinfo); - self.Minibuffer = window.eval("command",sandbox.Minibuffer.addCommand); + self.LDRize = sandbox.LDRize; + self.Minibuffer = sandbox.Minibuffer.command; },false); if(window.content.wrappedJSObject == sandbox.unsafeWindow){ - self.LDRize = window.eval("self",sandbox.LDRize.getSiteinfo); - self.Minibuffer = window.eval("command",sandbox.Minibuffer.addCommand); + self.LDRize = sandbox.LDRize; + self.Minibuffer = sandbox.Minibuffer.command; } } }); @@ -174,7 +174,7 @@ initLDRizeCaptureKeys: function(keys){ var self = this; keys.forEach(function(x){ - var map = liberator.mappings.getDefault(null,x) || liberator.mappings.get(null,x); + var map = liberator.modules.mappings.getDefault(null,x) || liberator.modules.mappings.get(null,x); var oldAction = map.action; var getter = "getPrev"; switch(x){ @@ -197,73 +197,73 @@ initLDRizeCooperationFuture: function(){ var self = this; - var originalHinttags = liberator.options.hinttags; - var originalExtendedHinttags = liberator.options.hinttags; + var originalHinttags = liberator.modules.options.hinttags; + var originalExtendedHinttags = liberator.modules.options.hinttags; function setHinttags(enable){ if(enable){ var siteinfo = self.LDRize.getSiteinfo(); if(siteinfo.link && siteinfo.paragraph){ - liberator.options.hinttags = siteinfo.paragraph + "/" + siteinfo.link; - liberator.options.extendedhinttags = siteinfo.paragraph + "/" + siteinfo.link; + liberator.modules.options.hinttags = siteinfo.paragraph + "/" + siteinfo.link; + liberator.modules.options.extendedhinttags = siteinfo.paragraph + "/" + siteinfo.link; }else{ - liberator.options.hinttags = originalHinttags; - liberator.options.extendedhinttags = originalExtendedHinttags; + liberator.modules.options.hinttags = originalHinttags; + liberator.modules.options.extendedhinttags = originalExtendedHinttags; } }else{ - liberator.options.hinttags = originalHinttags; - liberator.options.extendedhinttags = originalExtendedHinttags; + liberator.modules.options.hinttags = originalHinttags; + liberator.modules.options.extendedhinttags = originalExtendedHinttags; } } //Mappings - liberator.mappings.addUserMap([liberator.modes.NORMAL], [",f"], + liberator.modules.mappings.addUserMap([liberator.modules.modes.NORMAL], [",f"], "Start QuickHint mode with LDRize", function(){ setHinttags(true); - liberator.hints.show(liberator.modes.QUICK_HINT); + liberator.modules.hints.show(liberator.modules.modes.QUICK_HINT); setHinttags(self.isEnableLDRizeCooperation() && self.isModHints); } ,{}); - liberator.mappings.addUserMap([liberator.modes.NORMAL], ["f"], + liberator.modules.mappings.addUserMap([liberator.modules.modes.NORMAL], ["f"], "Start QuickHint mode", function(){ setHinttags(self.isEnableLDRizeCooperation() && self.isModHints); - liberator.hints.show(liberator.modes.QUICK_HINT); + liberator.modules.hints.show(liberator.modules.modes.QUICK_HINT); },{}); - liberator.mappings.addUserMap([liberator.modes.NORMAL], ["F"], + liberator.modules.mappings.addUserMap([liberator.modules.modes.NORMAL], ["F"], "Start QuickHint mode, but open link in a new tab", function(){ setHinttags(self.isEnableLDRizeCooperation() && self.isModHints); - liberator.hints.show(liberator.modes.QUICK_HINT, "t"); + liberator.modules.hints.show(liberator.modules.modes.QUICK_HINT, "t"); },{}); - liberator.mappings.addUserMap([liberator.modes.NORMAL], [";"], + liberator.modules.mappings.addUserMap([liberator.modules.modes.NORMAL], [";"], "Start an extended hint mode", function(arg){ setHinttags(self.isEnableLDRizeCooperation() && self.isModHints); if(arg == "f") - liberator.hints.show(liberator.modes.ALWAYS_HINT, "o"); + liberator.modules.hints.show(liberator.modules.modes.ALWAYS_HINT, "o"); else if(arg == "F") - liberator.hints.show(liberator.modes.ALWAYS_HINT, "t"); + liberator.modules.hints.show(liberator.modules.modes.ALWAYS_HINT, "t"); else - liberator.hints.show(liberator.modes.EXTENDED_HINT, arg); + liberator.modules.hints.show(liberator.modules.modes.EXTENDED_HINT, arg); }, - { flags: liberator.Mappings.flags.ARGUMENT }); + { flags: liberator.modules.Mappings.flags.ARGUMENT }); //Commands - liberator.commands.addUserCommand(["pin"], "LDRize Pinned Links", + liberator.modules.commands.addUserCommand(["pin"], "LDRize Pinned Links", function(){ var links = self.getPinnedItems(); var showString = links.length + " Items
"; links.forEach(function(link){ showString += link + "
"; }); - liberator.commandline.echo(showString, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); + liberator.modules.commandline.echo(showString, liberator.modules.commandline.HL_NORMAL, liberator.modules.commandline.FORCE_MULTILINE); } ,{}); - liberator.commands.addUserCommand(["mb","m","minibuffer"], "Execute Minibuffer", + liberator.modules.commands.addUserCommand(["mb","m","minibuffer"], "Execute Minibuffer", function(arg){self.Minibuffer.execute(arg)}, { completer: function(filter){ @@ -277,18 +277,18 @@ return [0,completionList]; } }); - liberator.commands.addUserCommand(["pindownload"], "Download pinned links by any software", + liberator.modules.commands.addUserCommand(["pindownload"], "Download pinned links by any software", function(arg){ self.downloadLinksByProgram(self.getPinnedItems());} ,{}); - liberator.commands.addUserCommand(["toggleldrizecooperation","toggleldrc"], "Toggle LDRize Cooperation", + liberator.modules.commands.addUserCommand(["toggleldrizecooperation","toggleldrc"], "Toggle LDRize Cooperation", function(arg){ self.isEnable = !self.isEnable}, {}); //Options - liberator.options.add(['ldrc','ldrizecooperation'],'LDRize cooperation','boolean',this.isEnable, + liberator.modules.options.add(['ldrc','ldrizecooperation'],'LDRize cooperation','boolean',this.isEnable, { setter: function(value){ self.isEnable = value; }, getter: function(){ return self.isEnable; } } ); - liberator.options.add(['ldrchints'],'mod hinttags for LDRize','boolean',this.isModHints, + liberator.modules.options.add(['ldrchints'],'mod hinttags for LDRize','boolean',this.isModHints, { setter: function(value){ self.isModHints = value; }, getter: function(){ return self.isModHints; } @@ -335,9 +335,9 @@ setTimeout(function(){ if(typeof x.handler == "object"){ var args = x.handler[1].map(function(s){ return s.replace(/%URL%/g,url).replace(/%TITLE%/g,title); }); - liberator.io.run(x.handler[0],args,false); + liberator.modules.io.run(x.handler[0],args,false); }else if(typeof x.handler == "string"){ - liberator.io.run(x.handler,[url],false); + liberator.modules.io.run(x.handler,[url],false); }else if(typeof x.handler == "function"){ x.handler(url.toString(),title); } diff --git a/ldrize_cooperation_fetch_flv.js b/ldrize_cooperation_fetch_flv.js index b8bec88..743ba8c 100644 --- a/ldrize_cooperation_fetch_flv.js +++ b/ldrize_cooperation_fetch_flv.js @@ -1,6 +1,6 @@ // Vimperator plugin: 'Cooperation LDRize Mappings - Niconico Flv Fetchearg || liberator.buffer.URLr' // Version: 0.4 -// Last Change: 06-Apr-2008. Jan 2008 +// Last Change: 21-Oct-2008. Jan 2008 // License: Creative Commons // Maintainer: Trapezoid - http://unsigned.g.hatena.ne.jp/Trapezoid // @@ -66,12 +66,12 @@ xhr.open("GET",uri,true); xhr.send(null); } - liberator.commands.addUserCommand(['fetchflv'],'Download flv file from Nicovideo', + liberator.modules.commands.addUserCommand(['fetchflv'],'Download flv file from Nicovideo', function(arg){ - httpGET(arg || liberator.buffer.URL,function(responseText){ + httpGET(arg.string || liberator.modules.buffer.URL,function(responseText){ var [,title] = responseText.match(/(.*?)<\/title>/i); liberator.log(title); - NiconicoFlvHandler(arg || liberator.buffer.URL,title); + NiconicoFlvHandler(arg.string || liberator.modules.buffer.URL,title); }); },{} ); diff --git a/lookupDictionary.js b/lookupDictionary.js index f52b751..c0ba49c 100644 --- a/lookupDictionary.js +++ b/lookupDictionary.js @@ -141,7 +141,9 @@ SITE_DEFINITION.forEach(function(dictionary){ commands.addUserCommand( dictionary.names, dictionary.shortHelp, - function(arg,special){ + function(args,special){ + var arg = args.string; + var sel = (window.content.window.getSelection) ? window.content.window.getSelection().toString() : null; if (special && sel) arg = sel; diff --git a/matanico.js b/matanico.js index cfdb6e1..cd5f8ba 100644 --- a/matanico.js +++ b/matanico.js @@ -4,8 +4,8 @@ * @description update Twitter's status to current video name and comment * @description-ja 今見てる動画のタイトルとコメントを Twitter に投稿する * @author janus_wel <janus_wel@fb3.so-net.ne.jp> - * @version 0.60 - * @minversion 1.1 + * @version 0.62 + * @minversion 2.0pre 2008/10/16 * ==VimperatorPlugin== * * LICENSE @@ -89,7 +89,7 @@ function NicoScraper() {} NicoScraper.prototype = { constants: { - VERSION: '0.50', + VERSION: '0.62', WATCH_PAGE: 1, WATCH_URL: '^http://www\\.nicovideo\\.jp/watch/[a-z]{2}\\d+', TAG_PAGE: 2, @@ -117,7 +117,7 @@ NicoScraper.prototype = { return null; }, - getURL: function() { return liberator.buffer.URL; }, + getURL: function() { return liberator.modules.buffer.URL; }, getSubject: function() { if(this.pagecheck() === this.constants.WATCH_PAGE) { @@ -176,9 +176,11 @@ NicoScraper.prototype = { var scraper = new NicoScraper; -liberator.commands.addUserCommand(['matanico'], "update Twitter's status to current video name and comment", - function(arg, special) { +liberator.modules.commands.addUserCommand(['matanico'], "update Twitter's status to current video name and comment", + function(args, special) { try { + var arg = args.string; + // build post string ----- var post_string; // domain check @@ -238,7 +240,7 @@ liberator.commands.addUserCommand(['matanico'], "update Twitter's status to curr // ':matanico!' display the evaluated format. if(special) { - liberator.util.copyToClipboard(post_string, true); + liberator.modules.util.copyToClipboard(post_string, true); return; } diff --git a/migemo_hint.js b/migemo_hint.js index 62d7c19..ac3651b 100644 --- a/migemo_hint.js +++ b/migemo_hint.js @@ -1,5 +1,5 @@ // Vimperator plugin: 'Hint Matching with XUL/Migemo' -// Last Change: 16-Jun-2008. Jan 2008 +// Last Change: 21-Oct-2008. Jan 2008 // License: Creative Commons // Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid // Require: XUL/Migemo extension - https://addons.mozilla.org/ja/firefox/addon/5239 @@ -19,3 +19,6 @@ liberator.plugins.customHintMatcher = function(inputString){ var r = new RegExp(XMigemoCore.getRegExp(inputString)); return function(hintString) r.test(hintString); } + +plugins = {}; +plugins.customHintMatcher = liberator.plugins.customHintMatcher; diff --git a/nicontroller.js b/nicontroller.js index a519c0c..aaa4275 100644 --- a/nicontroller.js +++ b/nicontroller.js @@ -4,8 +4,8 @@ * @description this script give you keyboard opration for nicovideo.jp. * @description-ja ニコニコ動画のプレーヤーをキーボードで操作できるようにする。 * @author janus_wel <janus_wel@fb3.so-net.ne.jp> - * @version 0.52 - * @minversion 1.2 + * @version 0.53 + * @minversion 2.0pre 2008/10/16 * ==VimperatorPlugin== * * LICENSE @@ -78,29 +78,29 @@ javascript <<EOM // [N],n- // N 秒前にシークする。 // 指定なしの場合 10 秒前。 -liberator.mappings.addUserMap( - [liberator.modes.NORMAL], +liberator.modules.mappings.addUserMap( + [liberator.modules.modes.NORMAL], [',n-'], 'seek by count backward', function(count) { if(count === -1) count = 10; liberator.execute(':nicoseek! ' + '-' + count); }, - { flags: liberator.Mappings.flags.COUNT } + { flags: liberator.modules.Mappings.flags.COUNT } ); // [N],n+ // N 秒後にシークする。 // 指定なしの場合 10 秒後。 -liberator.mappings.addUserMap( - [liberator.modes.NORMAL], +liberator.modules.mappings.addUserMap( + [liberator.modules.modes.NORMAL], [',n+'], 'seek by count forward', function(count) { if(count === -1) count = 10; liberator.execute(':nicoseek! ' + count); }, - { flags: liberator.Mappings.flags.COUNT } + { flags: liberator.modules.Mappings.flags.COUNT } ); EOM */ @@ -186,7 +186,7 @@ NicoPlayerController.prototype = { }, constants: { - VERSION: '0.51', + VERSION: '0.53', CARDINAL_NUMBER: 10, @@ -261,7 +261,7 @@ NicoPlayerController.prototype = { throw new Error('current tab is not watch page on nicovideo.jp'); }, - getURL: function() { return liberator.buffer.URL; }, + getURL: function() { return liberator.modules.buffer.URL; }, _flvplayer: function() { if(this.pagecheck() === this.constants.WATCH_PAGE) { @@ -412,7 +412,7 @@ NicoPlayerController.prototype = { var controller = new NicoPlayerController(); // command register -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicoinfo'], 'display player information', function() { @@ -421,14 +421,14 @@ liberator.commands.addUserCommand( 'player version : ' + controller.getPlayerVersion(), 'controller version : ' + controller.getControllerVersion(), ].join("\n"); - liberator.echo(info, liberator.commandline.FORCE_MULTILINE); + liberator.echo(info, liberator.modules.commandline.FORCE_MULTILINE); } catch(e) { liberator.echoerr(e); } }, {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicopause'], 'toggle play / pause', function() { @@ -438,7 +438,7 @@ liberator.commands.addUserCommand( {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicomute'], 'toggle mute', function() { @@ -448,7 +448,7 @@ liberator.commands.addUserCommand( {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicommentvisible'], 'toggle comment visible', function() { @@ -458,7 +458,7 @@ liberator.commands.addUserCommand( {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicorepeat'], 'toggle repeat', function() { @@ -468,11 +468,16 @@ liberator.commands.addUserCommand( {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicoseek'], 'controll seek bar', - function(arg, special) { - try { special ? controller.seekBy(arg) : controller.seekTo(arg); } + function(args, special) { + try { + var arg = (args.arguments.length > 1) + ? args.arguments[0].toString() + : args.string; + special ? controller.seekBy(arg) : controller.seekTo(arg); + } catch(e) { liberator.echoerr(e); } }, { @@ -480,11 +485,16 @@ liberator.commands.addUserCommand( } ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicovolume'], 'controll volume', - function(arg, special) { - try { special ? controller.volumeBy(arg) : controller.volumeTo(arg); } + function(args, special) { + try { + var arg = (args.arguments.length > 1) + ? args.arguments[0].toString() + : args.string; + special ? controller.volumeBy(arg) : controller.volumeTo(arg); + } catch(e) { liberator.echoerr(e); } }, { @@ -492,7 +502,7 @@ liberator.commands.addUserCommand( } ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicosize'], 'toggle video size', function() { @@ -502,21 +512,23 @@ liberator.commands.addUserCommand( {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicodescription'], 'toggle display or not the description for video', - function(arg) { + function() { try { controller.toggleDescription(); } catch(e) { liberator.echoerr(e); } }, {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicomment'], 'fill comment box', - function(arg) { + function(args) { try { + var arg = args.string; + var command, comment; [command, comment] = expandExCommand(arg); @@ -534,15 +546,17 @@ liberator.commands.addUserCommand( {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['nicommand'], 'fill command box', function(arg) { - try { controller.setValue('inputArea.MailInput.text', arg); } + try { controller.setValue('inputArea.MailInput.text', arg.string); } catch(e) { liberator.echoerr(e); } }, { - completer: function(arg){ + completer: function(args){ + var arg = args.string; + // get available commands by roll var availableCommands = controller.getAvailableCommands(); @@ -592,7 +606,7 @@ const MAX_LINE = { medium: 25, small: 38, }; -const EMSP = ' '; +const EMSP = '\u3000'; const NBSP = '\u00a0'; const LF = '\u000a'; const PROPATIES_DEFAULT = { diff --git a/nnp_cooperation.js b/nnp_cooperation.js index 8a5ea0a..26f149e 100644 --- a/nnp_cooperation.js +++ b/nnp_cooperation.js @@ -5,7 +5,7 @@ * @description-ja NicoNicoPlaylist をキーボードで操作できるようにする。 * @author janus_wel <janus_wel@fb3.so-net.ne.jp> * @version 0.32 - * @minversion 1.2 + * @minversion 2.0pre 2008/10/16 * ==VimperatorPlugin== * * CONSTRAINT @@ -62,22 +62,22 @@ javascript <<EOM // [N],nn // N 番目の動画を再生する。 // 指定なしの場合次の動画が再生される。 -liberator.mappings.addUserMap( - [liberator.modes.NORMAL], +liberator.modules.mappings.addUserMap( + [liberator.modules.modes.NORMAL], [',nn'], 'play next item in NicoNicoPlaylist', function(count) { if(count === -1) count = 1; liberator.execute(':nnpplaynext ' + count); }, - { flags: liberator.Mappings.flags.COUNT } + { flags: liberator.modules.Mappings.flags.COUNT } ); // [N],nr // 上から N 個の動画を削除する。 // 指定なしの場合一番上の動画が削除される。 -liberator.mappings.addUserMap( - [liberator.modes.NORMAL], +liberator.modules.mappings.addUserMap( + [liberator.modules.modes.NORMAL], [',nr'], 'remove item in NicoNicoPlaylist', function(count) { @@ -85,7 +85,7 @@ liberator.mappings.addUserMap( for(var i=0 ; i<count ; ++i) liberator.execute(':nnpremove'); liberator.execute(':nnpgetlist'); }, - { flags: liberator.Mappings.flags.COUNT } + { flags: liberator.modules.Mappings.flags.COUNT } ); EOM @@ -143,8 +143,12 @@ const itemHTML = [ // scrape from div element that inserted by NicoNicoPlaylist -liberator.commands.addUserCommand(['nnpgetlist'], 'get NicoNicoPlaylist', - function (arg) { +liberator.modules.commands.addUserCommand(['nnpgetlist'], 'get NicoNicoPlaylist', + function (args) { + var arg = (args.arguments.length > 1) + ? args.arguments[0].toString() + : args.string; + // check existence of NicoNicoPlaylist var playlist = $f('//div[contains(@id, "playlistcontroller_")]'); if(!playlist) { @@ -204,7 +208,7 @@ liberator.commands.addUserCommand(['nnpgetlist'], 'get NicoNicoPlaylist', .replace(/\$THEAD/g, thead) .replace(/\$ITEMS/g, items.join('')); - liberator.echo(str, liberator.commandline.FORCE_MULTILINE); + liberator.echo(str, liberator.modules.commandline.FORCE_MULTILINE); },{} ); @@ -250,10 +254,10 @@ function $s(query, node) { [['nnpfullscreen'], "toggle fullscreen mode of NicoNicoPlaylist", 'GMNNPFullScreen'], ].forEach( function ([command, description, eventname]){ - liberator.commands.addUserCommand(command, description, + liberator.modules.commands.addUserCommand(command, description, function (arg) { var r = document.createEvent("CommandEvent"); - r.initCommandEvent(eventname, true, true, arg); + r.initCommandEvent(eventname, true, true, arg.string); window.content.dispatchEvent(r); },{} ); diff --git a/reading.js b/reading.js index d8a7845..955287d 100644 --- a/reading.js +++ b/reading.js @@ -4,8 +4,8 @@ * @description update Twitter's status to current URL and comment * @description-ja 今見てるページの URL とタイトルをコメントといっしょに Twitter に投稿する * @author janus_wel <janus_wel@fb3.so-net.ne.jp> - * @version 0.21 - * @minversion 1.2 + * @version 0.22 + * @minversion 2.0pre 2008/10/16 * ==VimperatorPlugin== * * LICENSE @@ -56,13 +56,13 @@ const POST_URL = 'https://twitter.com/statuses/update.json'; function Scraper(){} Scraper.prototype = { constants: { - VERSION: '0.21', + VERSION: '0.22', }, version: function(){ return this.constants.VERSION; }, getURL: function() { - return liberator.buffer.URL; + return liberator.modules.buffer.URL; }, getTitle: function() { @@ -76,9 +76,11 @@ Scraper.prototype = { } }; -liberator.commands.addUserCommand(['reading'], "update Twitter's status to current page title, URL and comment", - function(arg, special) { +liberator.modules.commands.addUserCommand(['reading'], "update Twitter's status to current page title, URL and comment", + function(args, special) { try { + var arg = args.string; + // build post string ----- var post_string; @@ -100,7 +102,7 @@ liberator.commands.addUserCommand(['reading'], "update Twitter's status to curre // ':matanico!' display the evaluated format. if(special) { - liberator.util.copyToClipboard(post_string, true); + liberator.modules.util.copyToClipboard(post_string, true); return; } diff --git a/youtubeamp.js b/youtubeamp.js index 46a186a..7b269ea 100644 --- a/youtubeamp.js +++ b/youtubeamp.js @@ -4,8 +4,8 @@ * @description this script gives you keyboard oprations for YouTube.com. * @description-ja YouTube のプレーヤーをキーボードで操作できるようにする。 * @author janus_wel <janus_wel@fb3.so-net.ne.jp> - * @version 0.11 - * @minversion 1.2 + * @version 0.12 + * @minversion 2.0pre 2008/10/16 * ==VimperatorPlugin== * * LICENSE @@ -60,7 +60,7 @@ YouTubePlayerController.prototype = { }, constants: { - VERSION: '0.10', + VERSION: '0.12', CARDINAL_NUMBER: 10, @@ -102,7 +102,7 @@ YouTubePlayerController.prototype = { throw new Error('current tab is not watch page on youtube.com'); }, - getURL: function() { return liberator.buffer.URL; }, + getURL: function() { return liberator.modules.buffer.URL; }, _player: function() { if(this.pagecheck() === this.constants.WATCH_PAGE) { @@ -250,7 +250,7 @@ YouTubePlayerController.prototype = { var controller = new YouTubePlayerController(); // command register -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['ytinfo'], 'display player information', function() { @@ -258,14 +258,14 @@ liberator.commands.addUserCommand( var info = [ 'controller version : ' + controller.getControllerVersion(), ].join('\n'); - liberator.echo(info, liberator.commandline.FORCE_MULTILINE); + liberator.echo(info, liberator.modules.commandline.FORCE_MULTILINE); } catch(e) { liberator.echoerr(e); } }, {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['ytpause'], 'toggle play / pause', function() { @@ -275,7 +275,7 @@ liberator.commands.addUserCommand( {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['ytmute'], 'toggle mute', function() { @@ -285,11 +285,16 @@ liberator.commands.addUserCommand( {} ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['ytseek'], 'control seek bar', - function(arg, special) { - try { special ? controller.seekBy(arg) : controller.seekTo(arg); } + function(args, special) { + try { + var arg = (args.arguments.length > 1) + ? args.arguments[0].toString() + : args.string; + special ? controller.seekBy(arg) : controller.seekTo(arg); + } catch(e) { liberator.echoerr(e); } }, { @@ -297,11 +302,16 @@ liberator.commands.addUserCommand( } ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['ytvolume'], 'control volume', - function(arg, special) { - try { special ? controller.volumeBy(arg) : controller.volumeTo(arg); } + function(args, special) { + try { + var arg = (args.arguments.length > 1) + ? args.arguments[0].toString() + : args.string; + special ? controller.volumeBy(arg) : controller.volumeTo(arg); + } catch(e) { liberator.echoerr(e); } }, { @@ -309,7 +319,7 @@ liberator.commands.addUserCommand( } ); -liberator.commands.addUserCommand( +liberator.modules.commands.addUserCommand( ['ytsize'], 'toggle video size', function() { -- cgit v1.2.3