Socket
Socket
Sign inDemoInstall

fxconsole

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fxconsole - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

t.diff

122

index.js

@@ -16,9 +16,8 @@ var util = require("util"),

start: function(options) {
this.connect(options, function(err, tab) {
this.connect(options, function(err, page) {
if (err) throw err;
console.log(tab.url.yellow);
console.log(page.url.yellow);
this.setActor(page);
this.setTab(tab)
this.repl = repl.start({

@@ -33,3 +32,3 @@ prompt: this.getPrompt(),

this.defineCommands();
}.bind(this))
}.bind(this));
},

@@ -40,4 +39,23 @@

client.connect(options.port, options.host, function() {
client.selectedTab(cb);
})
// see https://github.com/harthur/firefox-client/issues/11
client.listTabs(function(err, tabs) {
// If some tabs are open
if (tabs.length) {
client.selectedTab(cb);
}
// Otherwise apps
else {
client.getWebapps(function(err, webapps) {
webapps.listRunningApps(function(err, apps) {
if (apps.length) {
webapps.getApp(apps[0], cb);
} else {
throw new Error ("No tabs or apps open");
}
});
});
}
});
});
client.on("error", function(error) {

@@ -49,3 +67,3 @@ if (error.code == "ECONNREFUSED") {

throw error;
})
});
client.on("end", this.quit);

@@ -72,3 +90,3 @@

props[name] = getters[name];
})
});

@@ -87,3 +105,3 @@ // then the own properties

var strs = [];
for (name in props) {
for (var name in props) {
var value = props[name].value;

@@ -106,3 +124,3 @@ value = this.transformResult(value);

if (more > 0) {
str += ", ..." + (more + " more").grey
str += ", ..." + (more + " more").grey;
}

@@ -118,4 +136,4 @@ str += " } ";

setTab: function(tab) {
this.tab = tab;
setActor: function(page) {
this.page = page;

@@ -129,7 +147,6 @@ if (this.repl) {

getPrompt: function() {
var parts = url.parse(this.tab.url);
var parts = url.parse(this.page.url);
var name = parts.hostname;
if (!name) {
name = path.basename(parts.path);
name = path.basename(parts.path);
}

@@ -141,7 +158,7 @@ return name + "> ";

eval: function(cmd, context, filename, cb) {
this.evalInTab(cmd, cb);
this.evalInActor(cmd, cb);
},
evalInTab: function(input, cb) {
this.tab.Console.evaluateJS(input, function(err, resp) {
evalInActor: function(input, cb) {
this.page.Console.evaluateJS(input, function(err, resp) {
if (err) throw err;

@@ -164,3 +181,3 @@

cb(null, result);
})
});
}

@@ -170,3 +187,3 @@ else {

}
}.bind(this))
}.bind(this));
},

@@ -188,8 +205,13 @@

action: this.listTabs.bind(this)
})
});
this.repl.defineCommand('apps', {
help: 'list currently open apps',
action: this.listApps.bind(this)
});
this.repl.defineCommand('quit', {
help: 'quit fxconsole',
action: this.quit
})
});

@@ -199,3 +221,8 @@ this.repl.defineCommand('switch', {

action: this.switchTab.bind(this)
})
});
this.repl.defineCommand('switchapp', {
help: 'switch to evaluating in another tab by index',
action: this.switchApp.bind(this)
});
},

@@ -206,4 +233,4 @@

if (err) throw err;
var tab = tabs[index];
if (!tab) {

@@ -213,6 +240,5 @@ this.write("no tab at index " + index + "\n");

else {
this.setTab(tab);
this.write((this.tab.url + "\n").yellow);
this.setActor(tab);
this.write((this.page.url + "\n").yellow);
}
this.repl.displayPrompt();

@@ -222,2 +248,22 @@ }.bind(this));

switchApp: function(index) {
this.client.getWebapps(function(err, webapps) {
webapps.listRunningApps(function(err, apps) {
if (err) throw err;
var app = apps[index];
if (!app) {
this.write("no app at index " + index + "\n");
this.repl.displayPrompt();
} else {
webapps.getApp(app, function(err, page) {
this.setActor(page);
this.write((this.page.url + "\n").yellow);
this.repl.displayPrompt();
}.bind(this));
}
}.bind(this));
}.bind(this));
},
listTabs: function() {

@@ -239,5 +285,23 @@ this.client.listTabs(function(err, tabs) {

listApps: function() {
this.client.getWebapps(function(err, webapps) {
webapps.listRunningApps(function(err, apps) {
if (err) throw err;
var strs = "";
for (var i in apps) {
strs += "[" + i + "] " + apps[i] + "\n";
}
this.write(strs);
// displayPrompt() not listed in REPL module docs <.<
this.repl.displayPrompt();
}.bind(this));
}.bind(this));
},
quit: function() {
process.exit(0);
}
}
};
{
"name": "fxconsole",
"description": "Remote JavaScript console for Firefox",
"version": "0.0.1",
"version": "0.1.0",
"author": "Heather Arthur <fayearthur@gmail.com>",

@@ -11,5 +11,5 @@ "repository": {

"dependencies": {
"nomnom": "~1.6.1",
"colors": "~0.5.1",
"firefox-client": "~0.0.3"
"nomnom": "^1.6.1",
"colors": "^0.5.1",
"firefox-client": "^0.2.3"
},

@@ -16,0 +16,0 @@ "bin": {

# fxconsole
`fxconsole` is a remote Javascript console for Firefox that runs in your terminal.
`fxconsole` is a remote Javascript console for Firefox that runs in your terminal:
![fxconsole in Terminal](http://i.imgur.com/iKXwCsD.png)
## Install

@@ -31,3 +33,3 @@ With [node.js](http://nodejs.org/) and the npm package manager:

2. Start the Simulator with **Tools** > **Web Developer** > **Firefox OS Simulator**
3. Get the port the Simulator is listening on with this terminal command: `lsof -i -P | grep -i "b2g"` in Linux/Mac.
3. Get the port the Simulator is listening on with this terminal command: `lsof -i -P | grep -i "b2g"` in Linux/Mac, or using [fx-ports](https://github.com/nicola/fx-ports).
4. Start `fxconsole` and with the `--port` argument.

@@ -44,5 +46,1 @@

There are two extra REPL commands available beyond the standard node.js commands. `.tabs` lists the open tabs in Firefox. `.switch 2` switches to evaluating in a tab. The argument is the index of the tab to switch to.
## What it looks like
![fxconsole in Terminal](http://i.imgur.com/fGadT0Y.png)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc