/** * 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