pluginを半自動インストール

urlsにあるプラグインについてそれぞれインストールされてるか調べ、なかった場合インストールダイアログを出すext。

ext.add('auto-install-plugins', function(ev, arg){
    var urls = [
        'https://github.com/mooz/keysnail/raw/master/plugins/yet-another-twitter-client-keysnail.ks.js',
        'https://github.com/mooz/keysnail/raw/master/plugins/site-local-keymap.ks.js',
        'https://github.com/azu/KeySnail-Plugins/raw/master/JSReference/js-referrence.ks.js',
        'https://github.com/tkosaka/keysnail-plugin/raw/master/nicontroller.ks.js',
        'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js',
    ];

    function inst(a){
        if(a.length == 0){
            display.showPopup("auto-install-plugins", "All installation finished.");
        }else{
            var url = a.shift();
            var path = userscript.pluginDir + userscript.directoryDelimiter + url.match(/[^/]+$/)[0];
            if(plugins.context[path] === undefined){
                userscript.installPluginFromURL(url, function(){inst(a);});
            }else{
                inst(a);
            }
        }
    }
    inst(urls);
}, 'Open plugin installation dialogue if not installed yet.');