mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 05:31:03 +00:00
Add files via upload
This commit is contained in:
parent
9c024cf5e1
commit
922dd56410
26
lib/autoitx.js
Normal file
26
lib/autoitx.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// AutoItX3.Control API
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var AutoItXObject = function() {
|
||||
this.interface = null;
|
||||
|
||||
this.create = function() {
|
||||
try {
|
||||
this.interface = CreateObject("AutoItX3.Control");
|
||||
return this;
|
||||
} catch (e) {
|
||||
console.error("AutoItXObject.create() ->", e.message);
|
||||
}
|
||||
};
|
||||
|
||||
this.getInterface = function() {
|
||||
return this.interface;
|
||||
};
|
||||
|
||||
this.create();
|
||||
};
|
||||
|
||||
exports.create = function() {
|
||||
return new AutoItXObject();
|
||||
};
|
|
@ -6,6 +6,7 @@ var SYS = require("lib/system");
|
|||
var FILE = require("lib/file");
|
||||
var HTTP = require("lib/http");
|
||||
var Websocket = require("lib/websocket");
|
||||
var AutoItX = require("lib/autoitx");
|
||||
|
||||
// for remote debugging
|
||||
var pageEventId = 0;
|
||||
|
@ -23,6 +24,8 @@ var ChromeObject = function() {
|
|||
"port": 1080
|
||||
};
|
||||
this.inPrivate = false;
|
||||
|
||||
// dependencies
|
||||
this.oAutoIt = null;
|
||||
|
||||
// for remote debugging
|
||||
|
@ -33,11 +36,8 @@ var ChromeObject = function() {
|
|||
this.pageList = [];
|
||||
|
||||
this.create = function() {
|
||||
try {
|
||||
this.oAutoIt = CreateObject("AutoItX3.Control");
|
||||
} catch (e) {
|
||||
console.log("ChromeObject.create() -> " + e.message);
|
||||
}
|
||||
this.oAutoIt = AutoItX.create().getInterface();
|
||||
return this;
|
||||
};
|
||||
|
||||
this.setBinPath = function(path) {
|
||||
|
@ -189,39 +189,58 @@ var ChromeObject = function() {
|
|||
*/
|
||||
|
||||
try {
|
||||
// get user data directory
|
||||
if (!this.userDataDir) {
|
||||
this.userDataDir = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName;
|
||||
}
|
||||
|
||||
// connect to shell
|
||||
var shell = SHELL.create();
|
||||
shell.setWorkingDirectory(this.workingDirectory);
|
||||
|
||||
// initialize
|
||||
var cmd = [];
|
||||
|
||||
// enable inPrivate (incognito) mode
|
||||
if (this.inPrivate) {
|
||||
cmd.push("--incognito");
|
||||
}
|
||||
|
||||
// enable debugging port
|
||||
if (this.debuggingPort > 0) {
|
||||
cmd.push("--remote-debugging-port=" + this.debuggingPort);
|
||||
}
|
||||
|
||||
// disable default browser check
|
||||
cmd.push("--no-default-browser-check");
|
||||
|
||||
// disable popop blocking
|
||||
cmd.push("--disable-popup-blocking");
|
||||
|
||||
// set profile directory
|
||||
cmd.push("--profile-directory=\"" + this.profileName + "\"");
|
||||
|
||||
// set proxy configuration
|
||||
if (this.proxy != null) {
|
||||
console.log("--proxy-server=\"" + this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port + "\"");
|
||||
console.log("Proxy enabled:", this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port);
|
||||
cmd.push("--proxy-server=\"" + this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port + "\"");
|
||||
}
|
||||
|
||||
// set user data directory
|
||||
cmd.push("--user-data-dir=\"" + this.userDataDir + "\"");
|
||||
cmd.push("\"" + url + "\"");
|
||||
shell.runAs(this.binPath, cmd);
|
||||
|
||||
sleep(1500);
|
||||
// set URL
|
||||
cmd.push("\"" + url + "\"");
|
||||
|
||||
// run
|
||||
shell.runAs(this.binPath, cmd);
|
||||
sleep(300);
|
||||
|
||||
// release shell
|
||||
shell.release();
|
||||
} catch (e) {
|
||||
console.error("ChromeObject.open() -> " + e.message);
|
||||
sleep(1500);
|
||||
console.error("ChromeObject.open() -> ", e.message);
|
||||
sleep(300);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -236,7 +255,7 @@ var ChromeObject = function() {
|
|||
this.pageList = pageList;
|
||||
return pageList;
|
||||
} catch (e) {
|
||||
console.error("ChromeObject.getPageList() -> " + e.message);
|
||||
console.error("ChromeObject.getPageList() ->", e.message);
|
||||
return this.getPageList();
|
||||
}
|
||||
} else {
|
||||
|
@ -573,6 +592,11 @@ var ChromeObject = function() {
|
|||
this.oAutoIt.Send("{SPACE}");
|
||||
};
|
||||
|
||||
this.setValue = function(selector, value) {
|
||||
var s = encodeURIComponent(value);
|
||||
return this.evaluate('document.querySelector("' + selector + '").value = decodeURIComponent("' + s + '")');
|
||||
};
|
||||
|
||||
this.create();
|
||||
};
|
||||
|
||||
|
|
24
lib/toolkit.js
Normal file
24
lib/toolkit.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// WelsonJS.Toolkit API
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var ToolkitObject = function() {
|
||||
this.interface = null;
|
||||
|
||||
this.create = function() {
|
||||
try {
|
||||
this.interface = CreateObject("WelsonJS.Toolkit");
|
||||
return this;
|
||||
} catch (e) {
|
||||
console.error("ToolkitObject.create() ->", e.message);
|
||||
}
|
||||
};
|
||||
|
||||
this.getInterface = function() {
|
||||
return this.interface;
|
||||
};
|
||||
};
|
||||
|
||||
exports.create = function() {
|
||||
return new ToolkitObject();
|
||||
};
|
Loading…
Reference in New Issue
Block a user