var PLUGIN_INFO = xml` {NAME} options migrate user_pref :set foobarbaz で簡単に user_pref をセットできるプラグイン 2.0pre 2.0 https://github.com/vimpr/vimperator-plugins/raw/master/options-migrate-user-pref.js Yuichi Tateno MIT 0.1 || :set! javascript.enabled=true ||< を >|| :set javascript :set nojavascript ||< のようにマッピングするためのプラグインです。 boolean/number を簡単にセットできるようになるため、よく user_pref を変更する場合などに便利です。 例 >|| js < `; (function() { let p = function(msg) { Application.console.log(msg); } liberator.plugins.migrateUserPref = function(config) { config.forEach(function(conf) { let pref = conf.pref; let type; try { switch (services.get('pref').getPrefType(conf.pref)) { case Ci.nsIPrefBranch.PREF_STRING: // XXX: string のとき、うまく user_pref に設定できていない? type = 'string'; break; case Ci.nsIPrefBranch.PREF_INT: type = 'number'; break; case Ci.nsIPrefBranch.PREF_BOOL: type = 'boolean'; break; default: return liberator.echoerr('migrate-user-pref: error pref: ' + pref); } } catch (e) { return liberator.echoerr('migrate-user-pref: error pref: ' + pref + ' ' + e); } options.add(conf.command, conf.description, type, (typeof conf.defaultValue == 'undefined' ? options.getPref(pref) : conf.defaultValue), { setter: function(value) options.setPref(pref, value), getter: function() options.getPref(pref), } ); }); } liberator.plugins.migrateUserPref(liberator.globalVariables['options_migrate_user_pref'] || []); })();