mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 05:31:03 +00:00
fix
This commit is contained in:
parent
5f6489f6ac
commit
e902cc8625
|
@ -3,6 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
var SHELL = require("lib/shell");
|
var SHELL = require("lib/shell");
|
||||||
var SYS = require("lib/system");
|
var SYS = require("lib/system");
|
||||||
|
var FILE = require("lib/file");
|
||||||
|
|
||||||
var ChromeObject = function() {
|
var ChromeObject = function() {
|
||||||
this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:profileName\\Application";
|
this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:profileName\\Application";
|
||||||
|
@ -36,6 +37,11 @@ var ChromeObject = function() {
|
||||||
this.open = function(url) {
|
this.open = function(url) {
|
||||||
this.setProfileName(this.profileName);
|
this.setProfileName(this.profileName);
|
||||||
|
|
||||||
|
if (!FILE.fileExists(this.binPath)) {
|
||||||
|
console.error("ChromeObject.open() -> '" + this.profileName + "' 존재하지 않는 프로파일입니다. 생성 후 사용해주세요.");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
var process;
|
var process;
|
||||||
while (this.processID == 0) {
|
while (this.processID == 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -68,6 +74,7 @@ var ChromeObject = function() {
|
||||||
shell.release();
|
shell.release();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("ChromeObject.open() -> " + e.message);
|
console.error("ChromeObject.open() -> " + e.message);
|
||||||
|
sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
84
lib/file.js
84
lib/file.js
|
@ -9,6 +9,68 @@
|
||||||
|
|
||||||
var LIB = require('lib/std');
|
var LIB = require('lib/std');
|
||||||
|
|
||||||
|
var FileObject = function() {
|
||||||
|
this.interfaces = null;
|
||||||
|
this.interface = null;
|
||||||
|
this.filename = null;
|
||||||
|
this.charset = "utf-8";
|
||||||
|
this.isExists = false;
|
||||||
|
this.isFile = false;
|
||||||
|
this.isDirectory = false;
|
||||||
|
|
||||||
|
this.setInterface = function(interfaceName) {
|
||||||
|
this.interface = this.interfaces[interfaceName];
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setCharset = function(charset) {
|
||||||
|
this.charset = charset;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.create = function() {
|
||||||
|
this.interfaces = {
|
||||||
|
fso: CreateObject("Scripting.FileSystemObject"),
|
||||||
|
ado: CreateObject("ADODB.Stream")
|
||||||
|
};
|
||||||
|
this.setInterface("fso");
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.exists = function() {
|
||||||
|
try {
|
||||||
|
if (this.interface.FileExists(this.filename)) {
|
||||||
|
this.isExists = true;
|
||||||
|
this.isFile = true;
|
||||||
|
} else if (this.interface.folderExists(this.filename)) {
|
||||||
|
this.isExists = true;
|
||||||
|
this.isDirectory = true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("FileObject.exists() -> " + e.message);
|
||||||
|
}
|
||||||
|
return this.isExists;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.open = function(filename) {
|
||||||
|
this.filename = filename;
|
||||||
|
if (!this.exists()) {
|
||||||
|
console.warn("FileObject.open() -> The file does not exists.");
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.create();
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fileExists = function(FN) {
|
||||||
|
return (new FileObject()).open(FN).exists();
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.folderExists = function(FN) {
|
||||||
|
return (new FileObject()).open(FN).exists();
|
||||||
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
// Private APIs / Utility functions
|
// Private APIs / Utility functions
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -17,28 +79,6 @@ exports.VERSIONINFO = "File Lib (file.js) version 0.2";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// exports.fileExists
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
exports.fileExists = function(FN) {
|
|
||||||
var FSO = CreateObject("Scripting.FileSystemObject");
|
|
||||||
var exists = FSO.FileExists(FN);
|
|
||||||
FSO = null;
|
|
||||||
return exists;
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// exports.folderExists
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
exports.folderExists = function(FN) {
|
|
||||||
var FSO = CreateObject("Scripting.FileSystemObject");
|
|
||||||
var exists = FSO.FolderExists(FN);
|
|
||||||
FSO = null;
|
|
||||||
return exists;
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
// exports.fileGet
|
// exports.fileGet
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -11,15 +11,17 @@ exports.require = global.require;
|
||||||
|
|
||||||
exports.getList = function() {
|
exports.getList = function() {
|
||||||
var data = [];
|
var data = [];
|
||||||
var cmd = [
|
var commands = [
|
||||||
SYS.getEnvString("SYSTEMDRIVE") + "/LDPlayer/LDPlayer3.0/ldconsole.exe",
|
[SYS.getEnvString("SYSTEMDRIVE") + "/LDPlayer/LDPlayer4.0/ldconsole.exe", "list2"],
|
||||||
"list2"
|
[SYS.getEnvString("SYSTEMDRIVE") + "/LDPlayer/LDPlayer3.0/ldconsole.exe", "list2"]
|
||||||
];
|
];
|
||||||
var result = SHELL.exec(cmd);
|
|
||||||
|
for (var i = 0; i < commands.length; i++) {
|
||||||
|
var result = SHELL.exec(commands[i]);
|
||||||
var lines = result.split(/\r?\n/);
|
var lines = result.split(/\r?\n/);
|
||||||
|
|
||||||
for(var i = 0; i < lines.length; i++) {
|
for(var k = 0; k < lines.length; k++) {
|
||||||
var row = lines[i].split(',');
|
var row = lines[k].split(',');
|
||||||
|
|
||||||
if(row.length == 7) {
|
if(row.length == 7) {
|
||||||
data.push({
|
data.push({
|
||||||
|
@ -33,6 +35,7 @@ exports.getList = function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
40
shadow.js
40
shadow.js
|
@ -41,9 +41,7 @@ for (var i = 0; i < items.length; i++) {
|
||||||
if (name in Apps) {
|
if (name in Apps) {
|
||||||
Apps[name][uniqueId] = ipAddress;
|
Apps[name][uniqueId] = ipAddress;
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch (e) {}
|
||||||
console.error(e.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// App 1. LDPlayer
|
// App 1. LDPlayer
|
||||||
|
@ -59,7 +57,7 @@ var check_LDPlayer = function() {
|
||||||
AppsMutex.push(pid);
|
AppsMutex.push(pid);
|
||||||
|
|
||||||
if (title in Apps.LDPlayer) {
|
if (title in Apps.LDPlayer) {
|
||||||
var ss = SS.create.connect(Apps.LDPlayer[title]);
|
var ss = SS.connect(Apps.LDPlayer[title]);
|
||||||
ssPort = ss.listenPort;
|
ssPort = ss.listenPort;
|
||||||
ssPID = ss.processID;
|
ssPID = ss.processID;
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,7 +102,7 @@ var check_NoxPlayer = function() {
|
||||||
AppsMutex.push(pid);
|
AppsMutex.push(pid);
|
||||||
|
|
||||||
if (hostname in Apps.NoxPlayer) {
|
if (hostname in Apps.NoxPlayer) {
|
||||||
var ss = SS.create.connect(Apps.NoxPlayer[hostname]);
|
var ss = SS.connect(Apps.NoxPlayer[hostname]);
|
||||||
ssPort = ss.listenPort;
|
ssPort = ss.listenPort;
|
||||||
ssPID = ss.processID;
|
ssPID = ss.processID;
|
||||||
} else {
|
} else {
|
||||||
|
@ -146,10 +144,12 @@ var check_Chrome = function() {
|
||||||
ssPort = ss.listenPort;
|
ssPort = ss.listenPort;
|
||||||
ssPID = ss.processID;
|
ssPID = ss.processID;
|
||||||
|
|
||||||
var chromePID = Chrome.start("https://www.showmyip.com/", ssPort, uniqueId);
|
console.info("Wait 10 seconds...")
|
||||||
//AppsPID.push([ssPID, chromePID]);
|
sleep(10000);
|
||||||
AppsPID.push([ssPID]);
|
|
||||||
|
|
||||||
|
Chrome.start("https://whatismyipaddress.com/", ssPort, uniqueId);
|
||||||
|
|
||||||
|
AppsPID.push([ssPID]);
|
||||||
AppsMutex.push("chrome_" + uniqueId);
|
AppsMutex.push("chrome_" + uniqueId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,22 +157,19 @@ var check_Chrome = function() {
|
||||||
|
|
||||||
// Check dead processes
|
// Check dead processes
|
||||||
var check_Exits = function() {
|
var check_Exits = function() {
|
||||||
var availablePIDs = [];
|
var alivePIDList = SYS.getProcessList().reduce(function(acc, process) {
|
||||||
var processes = SYS.getProcesses();
|
acc.push(process.ProcessID);
|
||||||
|
}, []);
|
||||||
for (var i = 0; i < processes.length; i++) {
|
|
||||||
availablePIDs.push(processes[i].ProcessID);
|
|
||||||
}
|
|
||||||
|
|
||||||
AppsPID.forEach(function(v1) {
|
AppsPID.forEach(function(v1) {
|
||||||
v1.forEach(function(v2) {
|
v1.forEach(function(v2) {
|
||||||
if (availablePIDs.indexOf(v2) < 0) {
|
if (alivePIDList.indexOf(v2) < 0) {
|
||||||
//console.warn("Detected dead process: " + v2);
|
console.warn("Detected dead process: " + v2);
|
||||||
//console.warn("Will be kill related processes.");
|
console.warn("Will be kill related processes.");
|
||||||
|
|
||||||
//v1.forEach(function(v2) {
|
v1.forEach(function(v2) {
|
||||||
// SYS.killProcess(v2);
|
SYS.killProcess(v2);
|
||||||
//});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -192,9 +189,6 @@ var main = function() {
|
||||||
|
|
||||||
sleep(3000);
|
sleep(3000);
|
||||||
check_Chrome();
|
check_Chrome();
|
||||||
|
|
||||||
sleep(3000);
|
|
||||||
check_Exits();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user