aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorha1t2008-03-31 18:07:43 +0000
committerha1t2008-03-31 18:07:43 +0000
commita53da6dbbf19e8cf4b0c24c2bd50c01b7fda48d9 (patch)
treee6f4f79dd25868258f280f8d36cd25340046e4f4
parent3b37922de86b4a20b3bdfa9726338c3328126050 (diff)
downloadvimperator-plugins-a53da6dbbf19e8cf4b0c24c2bd50c01b7fda48d9.tar.bz2
import from project-p.jp
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8591 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r--commandBookmarklet.js37
-rw-r--r--proxy.js102
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: