Add files via upload

This commit is contained in:
Namhyeon Go 2021-08-10 20:39:27 +09:00 committed by GitHub
parent 9c024cf5e1
commit 922dd56410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 646 additions and 572 deletions

26
lib/autoitx.js Normal file
View 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();
};

View File

@ -6,6 +6,7 @@ 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 Websocket = require("lib/websocket");
var AutoItX = require("lib/autoitx");
// for remote debugging // for remote debugging
var pageEventId = 0; var pageEventId = 0;
@ -23,6 +24,8 @@ var ChromeObject = function() {
"port": 1080 "port": 1080
}; };
this.inPrivate = false; this.inPrivate = false;
// dependencies
this.oAutoIt = null; this.oAutoIt = null;
// for remote debugging // for remote debugging
@ -33,11 +36,8 @@ var ChromeObject = function() {
this.pageList = []; this.pageList = [];
this.create = function() { this.create = function() {
try { this.oAutoIt = AutoItX.create().getInterface();
this.oAutoIt = CreateObject("AutoItX3.Control"); return this;
} catch (e) {
console.log("ChromeObject.create() -> " + e.message);
}
}; };
this.setBinPath = function(path) { this.setBinPath = function(path) {
@ -189,39 +189,58 @@ var ChromeObject = function() {
*/ */
try { try {
// get user data directory
if (!this.userDataDir) { if (!this.userDataDir) {
this.userDataDir = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName; this.userDataDir = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName;
} }
// connect to shell
var shell = SHELL.create(); var shell = SHELL.create();
shell.setWorkingDirectory(this.workingDirectory); shell.setWorkingDirectory(this.workingDirectory);
// initialize
var cmd = []; var cmd = [];
// enable inPrivate (incognito) mode
if (this.inPrivate) { if (this.inPrivate) {
cmd.push("--incognito"); cmd.push("--incognito");
} }
// enable debugging port
if (this.debuggingPort > 0) { if (this.debuggingPort > 0) {
cmd.push("--remote-debugging-port=" + this.debuggingPort); 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 + "\""); cmd.push("--profile-directory=\"" + this.profileName + "\"");
// set proxy configuration
if (this.proxy != null) { 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 + "\""); 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("--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(); shell.release();
} catch (e) { } catch (e) {
console.error("ChromeObject.open() -> " + e.message); console.error("ChromeObject.open() -> ", e.message);
sleep(1500); sleep(300);
} }
return this; return this;
@ -236,7 +255,7 @@ var ChromeObject = function() {
this.pageList = pageList; this.pageList = pageList;
return pageList; return pageList;
} catch (e) { } catch (e) {
console.error("ChromeObject.getPageList() -> " + e.message); console.error("ChromeObject.getPageList() ->", e.message);
return this.getPageList(); return this.getPageList();
} }
} else { } else {
@ -573,6 +592,11 @@ var ChromeObject = function() {
this.oAutoIt.Send("{SPACE}"); this.oAutoIt.Send("{SPACE}");
}; };
this.setValue = function(selector, value) {
var s = encodeURIComponent(value);
return this.evaluate('document.querySelector("' + selector + '").value = decodeURIComponent("' + s + '")');
};
this.create(); this.create();
}; };

24
lib/toolkit.js Normal file
View 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();
};