/** * gmperator - vimperator plugin for Greasemonkey * For vimperator 0.6pre * @author teramako teramako@gmail.com * @version 0.2a * * 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(){ commands.addUserCommand(['gmli[st]','lsgm'], 'list Greasemonkey scripts', 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' } } 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'); } } ); commands.addUserCommand(['gmlo[ad]'], 'load Greasemonkey script', function(arg){ if (!arg) return; var scripts = getScripts(); var script; for (var i=0; i 0){ script.name = liberator.commands.getOption(res.opts, '-name', script.name); script.includes = liberator.commands.getOption(res.opts, '-include', script.includes); script.excludes = liberator.commands.getOption(res.opts, '-exclude', script.excludes); } config.save(); },{ args: [ [['-name','-n'], liberator.commands.OPTION_STRING], [['-include','-i'], liberator.commands.OPTION_LIST], [['-exclude','-e'], liberator.commands.OPTION_LIST] ], shortHelp: 'change setting a greasemonkey script', help: [ 'toggle enable/disable with "!", if {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