From cc76a40ad3a001def2f2a9348bad82453d8fd5d6 Mon Sep 17 00:00:00 2001 From: drry Date: Fri, 21 Mar 2008 02:11:34 +0000 Subject: lang/javascript/vimperator-plugins/trunk/xpathBlink.js lang/javascript/vimperator-plugins/trunk/autoIgnoreKey.js lang/javascript/vimperator-plugins/trunk/copy.js lang/javascript/vimperator-plugins/trunk/lookupDictionary.js lang/javascript/vimperator-plugins/trunk/splitBrowser.js lang/javascript/vimperator-plugins/trunk/gmperator.js: * 消えたファイルを trunk にコピーしました。 * ほか。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8235 d0d07461-0603-4401-acd4-de1884942a52 --- gmperator.js | 217 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 gmperator.js (limited to 'gmperator.js') diff --git a/gmperator.js b/gmperator.js new file mode 100644 index 0000000..ba92925 --- /dev/null +++ b/gmperator.js @@ -0,0 +1,217 @@ +/** + * gmperator - vimperator plugin for Greasemonkey + * For vimperator 0.5.3 + * @author teramako teramako@gmail.com + * @version 0.1a + * + * Usage: + * + * :gmli[st] {filter} -> show user scripts matches {filter} + * :gmli[st]! -> show all user scripts + * :gmli[st] full -> same as :gmli[st]! + * + * :gmlo[ad] {name|filename} -> load the user script to the current page + * but, don't dispatch load event + * so maybe you should edit the scripts before load + * + * :gmset! -> toggle enable/disable greasemonkey + * :gmset! {filename} -> toogle enable/disable the script + * :gmset {filename} {options} + * {options}: + * n[ame]={value} -> change name to {value} + * i[nclude]={expr[,expr,...]} -> change includes to expr list ("," demiliter) + * e[xclude]={expr[,expr,...]} -> change excludes to expr list ("," demiliter) + * + * Caution: + * The change is permanent, not only the session. + * And cannot get back. + * + * ex) + * :gmset! {filename} n=fooScriptName i=http://*,https://* e=http://example.com/* + * toggle enable or disable, + * name to "fooScriptName", + * includes to "http://*" and "https://*", + * and excludes to "http://example.com/*" + */ +(function(){ +vimperator.commands.add(new vimperator.Command( + ['gmli[st]','lsgm'], + function(arg,special){ + var str = ''; + var scripts = getScripts(); + var reg; + if (special || arg == 'full'){ + reg = new RegExp('.*'); + } else if( arg ){ + reg = new RegExp(arg,'i'); + } + if (reg){ + for (var i=0; i' + } else { + str += scripts[i].name; + } + str += ' (' + scripts[i].filename + ')\n' + } + } + vimperator.echo(str); + function scriptToString(script){ + return [ + '' + script.name + '::', + 'fileName: ' + script.filename, + 'nameSpace: ' + script.namespace, + 'description: ' + script.description, + 'includes:', + ' ' + script.includes.join('\n '), + 'excludes:', + ' ' + script.excludes.join('\n '), + 'enabled: ' + script.enabled + ].join('\n'); + } + },{ + usage: ['gmli[st] [full] | {filter}','lsgm [full] | {filter}'], + shortHelp: 'list Greasemonkey scripts' + } +)); +vimperator.commands.add(new vimperator.Command( + ['gmlo[ad]'], + function(arg){ + if (!arg) return; + var scripts = getScripts(); + var script; + for (var i=0; i{filename} is exist, if not toggle greasemonkey', + '
n
name
change the name
', + '
i
include
change the inclue list ("," demiliter)
', + '
e
exclude
change the exclude list ("," demiliter)
', + 'Caution: the change is permanent, not the only session.
And cannot get back.' + ].join(''), + completer: function(filter){ + return scriptsCompleter(filter, false); + } + } +)); +function getScripts(){ + var config = new Config(); + config.load(); + return config.scripts; +} +function scriptsCompleter(filter,flag){ + var candidates = []; + var scripts = getScripts(); + var isAll = false; + if (!filter) isAll=true; + if (flag){ + for (var i=0; i