mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-12 17:05:14 +00:00
Update chrome.js
This commit is contained in:
parent
b3907bd2ed
commit
fe435257f7
|
@ -5,6 +5,7 @@ var SHELL = require("lib/shell");
|
||||||
var SYS = require("lib/system");
|
var SYS = require("lib/system");
|
||||||
var FILE = require("lib/file");
|
var FILE = require("lib/file");
|
||||||
var HTTP = require("lib/http");
|
var HTTP = require("lib/http");
|
||||||
|
var Websocket = require("lib/websocket");
|
||||||
|
|
||||||
var ChromeObject = function() {
|
var ChromeObject = function() {
|
||||||
this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application";
|
this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application";
|
||||||
|
@ -19,7 +20,12 @@ var ChromeObject = function() {
|
||||||
"port": 1080
|
"port": 1080
|
||||||
};
|
};
|
||||||
this.inPrivate = false;
|
this.inPrivate = false;
|
||||||
|
|
||||||
|
// for remote debugging
|
||||||
this.debuggingPort = 0;
|
this.debuggingPort = 0;
|
||||||
|
this.pageEventId = 1;
|
||||||
|
this.pageId = "";
|
||||||
|
this.ws = Websocket.create();
|
||||||
|
|
||||||
this.setBinPath = function(path) {
|
this.setBinPath = function(path) {
|
||||||
this.binPath = path;
|
this.binPath = path;
|
||||||
|
@ -68,6 +74,10 @@ var ChromeObject = function() {
|
||||||
this.setDebuggingPort = function(n) {
|
this.setDebuggingPort = function(n) {
|
||||||
this.debuggingPort = (typeof(n) !== "number" ? this.debuggingPort : n);
|
this.debuggingPort = (typeof(n) !== "number" ? this.debuggingPort : n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setPageId = function(s) {
|
||||||
|
this.pageId = s;
|
||||||
|
};
|
||||||
|
|
||||||
this.createShoutcut = function(url) {
|
this.createShoutcut = function(url) {
|
||||||
if (!this.userDataDir) {
|
if (!this.userDataDir) {
|
||||||
|
@ -211,6 +221,25 @@ var ChromeObject = function() {
|
||||||
return (x.title == title);
|
return (x.title == title);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.sendRPC = function(method, params) {
|
||||||
|
this.ws.send("ws://localhost:" + this.debuggingPort + "/devtools/page/" + this.pageId, JSON.stringify({
|
||||||
|
"id": this.pageEventId,
|
||||||
|
"method": method,
|
||||||
|
"params": params
|
||||||
|
}));
|
||||||
|
this.pageEventId++;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.navigate = function(url) {
|
||||||
|
return this.sendRPC("Page.navigate", {
|
||||||
|
"url": url
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.evaluate = function(code) {
|
||||||
|
// todo
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.create = function() {
|
exports.create = function() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user