diff options
-rw-r--r-- | commandBookmarklet.js | 37 | ||||
-rw-r--r-- | proxy.js | 102 |
2 files changed, 139 insertions, 0 deletions
diff --git a/commandBookmarklet.js b/commandBookmarklet.js new file mode 100644 index 0000000..e279b32 --- /dev/null +++ b/commandBookmarklet.js @@ -0,0 +1,37 @@ +/** + * bookmarklet wo command ni suru plugin + * + * @author halt feits <halt.feits@gmail.com> + * @version 0.6.0 + */ + +(function(){ + var filter = "javascript:"; + var items = liberator.bookmarks.get(filter); + + if (items.length == 0) { + if (filter.length > 0) { + liberator.echoerr("E283: No bookmarks matching \"" + filter + "\""); + } else { + liberator.echoerr("No bookmarks set"); + } + } + + for (var i = 0; i < items.length; i++) { + var title = liberator.util.escapeHTML(items[i][1]); + if (title.length > 50) { + title = title.substr(0, 47) + "..."; + } + + var url = liberator.util.escapeHTML(items[i][0]); + var command = new Function('', 'liberator.open("' + url + '");'); + liberator.commands.addUserCommand( + [title], + 'bookmarklet', + command, + { + shortHelp: 'bookmarklet', + } + ); + } +})(); diff --git a/proxy.js b/proxy.js new file mode 100644 index 0000000..134c40d --- /dev/null +++ b/proxy.js @@ -0,0 +1,102 @@ +/** + * vimperator plugin + * + * proxy setting plugin (for vimperator-0.6pre) + * + * @author cho45 + * @author halt feits + * @version 0.6.0 + */ + +(function() { + + const proxy_settings = [ + { + conf_name: 'disable', + setting: [ + { + label: 'network.proxy.type', + param: 0 + } + ] + }, + { + conf_name: 'polipo', + setting: [ + { + label: 'network.proxy.type', + param: 1 + }, + { + label: 'network.proxy.http', + param: 'localhost' + }, + { + label: 'network.proxy.http_port', + param: 8123 + } + ] + } + ]; + + liberator.commands.addUserCommand(["proxy"], 'proxy settings', + function (args) { + const prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); + var name = args; + if (!name) { + liberator.echo("Usage: proxy {setting name}"); + } + for (var i = 0; i < proxy_settings.length; i++) { + if (proxy_settings[i].conf_name.toLowerCase() == name.toLowerCase()) { + + //delete setting + ['http', 'ssl', 'ftp', 'gopher'].forEach( + function (p) { + prefs.setCharPref("network.proxy." + p, ''); + prefs.setIntPref("network.proxy." + p + "_port", 0); + } + ); + + for (var j = 0; j < proxy_settings[i].setting.length; j++) { + + var conf = proxy_settings[i].setting[j]; + switch (conf.label) { + case "network.proxy.type": + prefs.setIntPref(conf.label, conf.param); + break; + case "network.proxy.http": + prefs.setCharPref(conf.label, conf.param); + break; + case "network.proxy.http_port": + prefs.setIntPref(conf.label, conf.param); + break; + } + + } + + liberator.echo("set config:" + name); + break; + } + } + }, + { + completer: function (filter) { + var completions = []; + + for (var i = 0; i < proxy_settings.length; i++) { + name = proxy_settings[i].conf_name; + + var exp = new RegExp("^" + filter); + + if (exp.test(name)) { + completions.push([name, name]); + } + } + + return [0, completions]; + } + } +); + +})(); +// vim: set sw=4 ts=4 et: |