mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-09 13:16:05 +00:00
fix
This commit is contained in:
parent
b82e1006b4
commit
43b7562b8d
114
lib/chrome.js
114
lib/chrome.js
|
@ -6,10 +6,12 @@ var SYS = require("lib/system");
|
||||||
var FILE = require("lib/file");
|
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\\Chrome\\Application";
|
||||||
this.binPath = this.workingDirectory + "\\chrome.exe";
|
this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:installedDir\\Application\\chrome.exe";
|
||||||
this.processID = 0;
|
this.processID = 0;
|
||||||
|
this.installedDir = "Chrome";
|
||||||
this.profileName = "Default";
|
this.profileName = "Default";
|
||||||
|
this.userDataDir = null;
|
||||||
this.proxyPort = 1080;
|
this.proxyPort = 1080;
|
||||||
this.processList = [];
|
this.processList = [];
|
||||||
|
|
||||||
|
@ -18,10 +20,21 @@ var ChromeObject = function() {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setProfileName = function(profileName) {
|
this.setProfile = function(profileName, installedDir) {
|
||||||
this.profileName = (profileName == "Default" ? "Chrome" : profileName);
|
this.profileName = (profileName == "Default" ? "Chrome" : profileName);
|
||||||
this.workingDirectory = this.workingDirectory.replace(":profileName", this.profileName);
|
this.installedDir = installedDir;
|
||||||
this.binPath = this.binPath.replace(":profileName", this.profileName);
|
//this.workingDirectory = this.workingDirectory.replace(":installedDir", this.installedDir);
|
||||||
|
this.binPath = this.binPath.replace(":installedDir", this.installedDir);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setUserDataDir = function(dirname) {
|
||||||
|
this.userDataDir = dirname;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setInstalledDir = function(dirname) {
|
||||||
|
this.installedDir = dirname;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,14 +47,31 @@ var ChromeObject = function() {
|
||||||
return this.processList;
|
return this.processList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.createShoutcut = function(url) {
|
||||||
|
if (!this.userDataDir) {
|
||||||
|
this.userDataDir = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHELL.createDesktopIcon("Chrome Prototype (" + this.installedDir + ")", [
|
||||||
|
"cscript",
|
||||||
|
"app.js",
|
||||||
|
"shoutcut",
|
||||||
|
"chrome",
|
||||||
|
this.installedDir,
|
||||||
|
"--profile-directory=\"" + this.profileName + "\"",
|
||||||
|
"--user-data-dir=\"" + this.userDataDir + "\"",
|
||||||
|
url
|
||||||
|
].join(' '), SYS.getCurrentScriptDirectory());
|
||||||
|
};
|
||||||
|
|
||||||
this.open = function(url) {
|
this.open = function(url) {
|
||||||
this.setProfileName(this.profileName);
|
this.setProfile(this.profileName, this.installedDir);
|
||||||
|
|
||||||
// 파일이 없는 경우, 32비트 설치 폴더에 위치하는지 한번 더 확인
|
// 파일이 없는 경우, 32비트 설치 폴더에 위치하는지 한번 더 확인
|
||||||
if (!FILE.fileExists(this.binPath)) {
|
if (!FILE.fileExists(this.binPath)) {
|
||||||
this.workingDirectory = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\:profileName\\Application";
|
this.workingDirectory = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\Chrome\\Application";
|
||||||
this.binPath = this.workingDirectory + "\\chrome.exe";
|
this.binPath = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\:installedDir\\Application\\chrome.exe";
|
||||||
this.setProfileName(this.profileName);
|
this.setProfile(this.profileName, this.installedDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 파일 찾기
|
// 파일 찾기
|
||||||
|
@ -51,39 +81,22 @@ var ChromeObject = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 바로가기 생성
|
// 바로가기 생성
|
||||||
SHELL.createDesktopIcon("Chrome (" + this.profileName + ")", [
|
this.createShoutcut();
|
||||||
"cscript",
|
|
||||||
"app.js",
|
|
||||||
"shoutcut",
|
|
||||||
"chrome",
|
|
||||||
this.profileName
|
|
||||||
], SYS.getCurrentScriptDirectory());
|
|
||||||
|
|
||||||
|
/*
|
||||||
var process;
|
var process;
|
||||||
while (this.processID == 0) {
|
while (this.processID == 0) {
|
||||||
try {
|
try {
|
||||||
/*
|
if (!this.userDataDir) {
|
||||||
process = SB.start(this.profileName, [
|
this.userDataDir = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName;
|
||||||
this.binPath,
|
}
|
||||||
"--profile-directory=" + this.profileName,
|
|
||||||
"--proxy-server=socks5://127.0.0.1:" + this.proxyPort,
|
|
||||||
url
|
|
||||||
]);
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
process = SHELL.createProcess([
|
|
||||||
this.binPath,
|
|
||||||
"--profile-directory=" + this.profileName,
|
|
||||||
"--proxy-server=socks5://127.0.0.1:" + this.proxyPort,
|
|
||||||
url
|
|
||||||
], this.workingDirectory);
|
|
||||||
*/
|
|
||||||
var shell = SHELL.create().setWorkingDirectory(this.workingDirectory);
|
var shell = SHELL.create().setWorkingDirectory(this.workingDirectory);
|
||||||
var process = shell.createProcess([
|
var process = shell.createProcess([
|
||||||
"\"" + this.binPath + "\"",
|
"\"" + this.binPath + "\"",
|
||||||
"--profile-directory=\"" + this.profileName + "\"",
|
"--profile-directory=\"" + this.profileName + "\"",
|
||||||
"--proxy-server=\"socks5://127.0.0.1:" + this.proxyPort + "\"",
|
"--proxy-server=\"socks5://127.0.0.1:" + this.proxyPort + "\"",
|
||||||
"--user-data-dir=\"" + SYS.getCurrentScriptDirectory() + "\\UserData_Chrome_" + this.profileName + "\"",
|
"--user-data-dir=\"" + this.userDataDir + "\"",
|
||||||
"\"" + url + "\""
|
"\"" + url + "\""
|
||||||
].join(" "));
|
].join(" "));
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
|
@ -95,15 +108,46 @@ var ChromeObject = function() {
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!this.userDataDir) {
|
||||||
|
this.userDataDir = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
var shell = SHELL.create().setWorkingDirectory(this.workingDirectory);
|
||||||
|
shell.runAs(this.binPath, [
|
||||||
|
"--profile-directory=\"" + this.profileName + "\"",
|
||||||
|
"--proxy-server=\"socks5://127.0.0.1:" + this.proxyPort + "\"",
|
||||||
|
"--user-data-dir=\"" + this.userDataDir + "\"",
|
||||||
|
"\"" + url + "\""
|
||||||
|
]);
|
||||||
|
sleep(3000);
|
||||||
|
shell.release();
|
||||||
|
} catch (e) {
|
||||||
|
console.error("ChromeObject.open() -> " + e.message);
|
||||||
|
sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.create = function() {
|
||||||
|
return new ChromeObject();
|
||||||
|
};
|
||||||
|
|
||||||
exports.getProcessIDs = function() {
|
exports.getProcessIDs = function() {
|
||||||
return (new ChromeObject()).getProcessIDs();
|
return (new ChromeObject()).getProcessIDs();
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.start = function(url, proxyPort, profileName) {
|
exports.start = function(url, proxyPort, profileName, userDataDir, installedDir) {
|
||||||
return (new ChromeObject()).setProxyPort(proxyPort).setProfileName(profileName).open(url).processID;
|
return (new ChromeObject())
|
||||||
|
.setProxyPort(proxyPort)
|
||||||
|
.setProfile(profileName, installedDir)
|
||||||
|
.setUserDataDir(userDataDir)
|
||||||
|
.setInstalledDir(installedDir)
|
||||||
|
.open(url)
|
||||||
|
.processID
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,7 @@ var FileObject = function() {
|
||||||
this.open = function(filename) {
|
this.open = function(filename) {
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
if (!this.exists()) {
|
if (!this.exists()) {
|
||||||
console.warn("FileObject.open() -> The file does not exists.");
|
console.warn("FileObject.open() -> The file does not exists: " + this.filename);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
16
lib/shell.js
16
lib/shell.js
|
@ -101,8 +101,12 @@ var ShellObject = function() {
|
||||||
|
|
||||||
this.runAs = function(FN, args) {
|
this.runAs = function(FN, args) {
|
||||||
var oShell = CreateObject("Shell.Application");
|
var oShell = CreateObject("Shell.Application");
|
||||||
|
var _args = null;
|
||||||
console.info("ShellObject.runAs() -> " + FN);
|
console.info("ShellObject.runAs() -> " + FN);
|
||||||
oShell.shellExecute(FN, args, this.workingDirectory, "runas", (!this.isVisibleWindow ? 0 : 1));
|
if (typeof(args) !== "undefined") {
|
||||||
|
_args = args.join(' ');
|
||||||
|
}
|
||||||
|
oShell.shellExecute(FN, _args, this.workingDirectory, "runas", (!this.isVisibleWindow ? 0 : 1));
|
||||||
return oShell;
|
return oShell;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,7 +118,7 @@ var ShellObject = function() {
|
||||||
var link = this.interface.CreateShortcut(path);
|
var link = this.interface.CreateShortcut(path);
|
||||||
link.TargetPath = "cmd";
|
link.TargetPath = "cmd";
|
||||||
link.Arguments = "/q /c " + this.build(cmd);
|
link.Arguments = "/q /c " + this.build(cmd);
|
||||||
link.WindowStyle = 3;
|
link.WindowStyle = 7;
|
||||||
link.WorkingDirectory = workingDirectory;
|
link.WorkingDirectory = workingDirectory;
|
||||||
//link.Hotkey = "";
|
//link.Hotkey = "";
|
||||||
//link.IconLocation = "";
|
//link.IconLocation = "";
|
||||||
|
@ -122,6 +126,10 @@ var ShellObject = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.getPathOfMyDocuments = function() {
|
||||||
|
return this.interface.SpecialFolders("MyDocuments");
|
||||||
|
};
|
||||||
|
|
||||||
this.release = function() {
|
this.release = function() {
|
||||||
console.info("ShellObject.release() -> " + this.currentDirectory);
|
console.info("ShellObject.release() -> " + this.currentDirectory);
|
||||||
this.interface.CurrentDirectory = this.currentDirectory;
|
this.interface.CurrentDirectory = this.currentDirectory;
|
||||||
|
@ -166,6 +174,10 @@ exports.createDesktopIcon = function(name, cmd, workingDirectory) {
|
||||||
return (new ShellObject()).createDesktopIcon(name, cmd, workingDirectory);
|
return (new ShellObject()).createDesktopIcon(name, cmd, workingDirectory);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.getPathOfMyDocuments = function() {
|
||||||
|
return (new ShellObject()).getPathOfMyDocuments();
|
||||||
|
};
|
||||||
|
|
||||||
exports.VERSIONINFO = "Shell interface (shell.js) version 0.2";
|
exports.VERSIONINFO = "Shell interface (shell.js) version 0.2";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
|
@ -143,7 +143,7 @@ exports.createShortcut = function(shoutcutName, fileName) {
|
||||||
var link = WSH.CreateShortcut(desktopPath + "\\" + shoutcutName + ".lnk");
|
var link = WSH.CreateShortcut(desktopPath + "\\" + shoutcutName + ".lnk");
|
||||||
link.IconLocation = fileName + ",1";
|
link.IconLocation = fileName + ",1";
|
||||||
link.TargetPath = workingDirectory + "\\" + fileName;
|
link.TargetPath = workingDirectory + "\\" + fileName;
|
||||||
link.WindowStyle = 3;
|
link.WindowStyle = 1;
|
||||||
link.WorkingDirectory = workingDirectory;
|
link.WorkingDirectory = workingDirectory;
|
||||||
link.Save();
|
link.Save();
|
||||||
};
|
};
|
||||||
|
|
17
shadow.js
17
shadow.js
|
@ -135,27 +135,19 @@ var check_NoxPlayer = function() {
|
||||||
|
|
||||||
// App 3. Chrome
|
// App 3. Chrome
|
||||||
var check_Chrome = function() {
|
var check_Chrome = function() {
|
||||||
var ssPort, ssPID;
|
|
||||||
for (var uniqueId in Apps.Chrome) {
|
for (var uniqueId in Apps.Chrome) {
|
||||||
if (AppsMutex.indexOf("chrome_" + uniqueId) < 0) {
|
if (AppsMutex.indexOf("chrome_" + uniqueId) < 0) {
|
||||||
console.info("Starting Google Chrome: " + uniqueId);
|
console.info("Creating Chrome Shoutcut: " + uniqueId);
|
||||||
|
|
||||||
var ss = SS.connect(Apps.Chrome[uniqueId]);
|
// 바탕화면에 바로가기만 생성
|
||||||
ssPort = ss.listenPort;
|
Chrome.create().setProfile(uniqueId, uniqueId).createShoutcut("https://google.com");
|
||||||
ssPID = ss.processID;
|
|
||||||
|
|
||||||
console.info("Wait 10 seconds...")
|
|
||||||
sleep(10000);
|
|
||||||
|
|
||||||
Chrome.start("https://whatismyipaddress.com/", ssPort, uniqueId);
|
|
||||||
|
|
||||||
AppsPID.push([ssPID]);
|
|
||||||
AppsMutex.push("chrome_" + uniqueId);
|
AppsMutex.push("chrome_" + uniqueId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check dead processes
|
// Check dead processes
|
||||||
|
/*
|
||||||
var check_Exits = function() {
|
var check_Exits = function() {
|
||||||
var alivePIDList = SYS.getProcessList().reduce(function(acc, process) {
|
var alivePIDList = SYS.getProcessList().reduce(function(acc, process) {
|
||||||
acc.push(process.ProcessID);
|
acc.push(process.ProcessID);
|
||||||
|
@ -176,6 +168,7 @@ var check_Exits = function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
var main = function() {
|
var main = function() {
|
||||||
console.info("Waiting new launched");
|
console.info("Waiting new launched");
|
||||||
|
|
28
shoutcut.js
28
shoutcut.js
|
@ -1,6 +1,8 @@
|
||||||
var SS = require("lib/shadowsocks");
|
var SS = require("lib/shadowsocks");
|
||||||
var XML = require("lib/xml");
|
var XML = require("lib/xml");
|
||||||
var Chrome = require("lib/chrome");
|
var Chrome = require("lib/chrome");
|
||||||
|
var SHELL = require("lib/shell");
|
||||||
|
var SYS = require("lib/system");
|
||||||
|
|
||||||
var Apps = {
|
var Apps = {
|
||||||
LDPlayer: {},
|
LDPlayer: {},
|
||||||
|
@ -24,7 +26,23 @@ for (var i = 0; i < items.length; i++) {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
var do_Chrome = function(_uniqueId) {
|
var do_Chrome = function(args) {
|
||||||
|
var _uniqueId = args[1];
|
||||||
|
var _args = {};
|
||||||
|
var _url = "https://google.com";
|
||||||
|
for (var i = 0; i < args.length; i++) {
|
||||||
|
var pos = args[i].indexOf('=');
|
||||||
|
if (pos > -1) {
|
||||||
|
if (args[i].indexOf("--") == 0) {
|
||||||
|
_args[args[i].substring(2, pos)] = args[i].substring(pos + 1);
|
||||||
|
} else {
|
||||||
|
_args[args[i].substring(0, pos)] = args[i].substring(pos + 1);
|
||||||
|
}
|
||||||
|
} else if (args[i] != "chrome") {
|
||||||
|
_url = args[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var ssPort, ssPID;
|
var ssPort, ssPID;
|
||||||
for (var uniqueId in Apps.Chrome) {
|
for (var uniqueId in Apps.Chrome) {
|
||||||
if (_uniqueId == uniqueId && AppsMutex.indexOf("chrome_" + uniqueId) < 0) {
|
if (_uniqueId == uniqueId && AppsMutex.indexOf("chrome_" + uniqueId) < 0) {
|
||||||
|
@ -34,10 +52,10 @@ var do_Chrome = function(_uniqueId) {
|
||||||
ssPort = ss.listenPort;
|
ssPort = ss.listenPort;
|
||||||
ssPID = ss.processID;
|
ssPID = ss.processID;
|
||||||
|
|
||||||
console.info("Wait 10 seconds...")
|
console.info("Wait 3 seconds...")
|
||||||
sleep(10000);
|
sleep(3000);
|
||||||
|
|
||||||
Chrome.start("https://whatismyipaddress.com/", ssPort, uniqueId);
|
Chrome.start(_url, ssPort, _args['profile-directory'], _args['user-data-dir'], _uniqueId);
|
||||||
|
|
||||||
AppsPID.push([ssPID]);
|
AppsPID.push([ssPID]);
|
||||||
AppsMutex.push("chrome_" + uniqueId);
|
AppsMutex.push("chrome_" + uniqueId);
|
||||||
|
@ -55,7 +73,7 @@ exports.main = function(args) {
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "chrome":
|
case "chrome":
|
||||||
return do_Chrome(args[1]);
|
return do_Chrome(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user