This commit is contained in:
Namhyeon Go 2020-11-18 19:55:06 +09:00
parent e902cc8625
commit b82e1006b4
3 changed files with 95 additions and 10 deletions

View File

@ -37,11 +37,28 @@ var ChromeObject = function() {
this.open = function(url) {
this.setProfileName(this.profileName);
// 파일이 없는 경우, 32비트 설치 폴더에 위치하는지 한번 더 확인
if (!FILE.fileExists(this.binPath)) {
this.workingDirectory = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\:profileName\\Application";
this.binPath = this.workingDirectory + "\\chrome.exe";
this.setProfileName(this.profileName);
}
// 파일 찾기
if (!FILE.fileExists(this.binPath)) {
console.error("ChromeObject.open() -> '" + this.profileName + "' 존재하지 않는 프로파일입니다. 생성 후 사용해주세요.");
return this;
}
// 바로가기 생성
SHELL.createDesktopIcon("Chrome (" + this.profileName + ")", [
"cscript",
"app.js",
"shoutcut",
"chrome",
this.profileName
], SYS.getCurrentScriptDirectory());
var process;
while (this.processID == 0) {
try {
@ -66,11 +83,12 @@ var ChromeObject = function() {
"\"" + this.binPath + "\"",
"--profile-directory=\"" + this.profileName + "\"",
"--proxy-server=\"socks5://127.0.0.1:" + this.proxyPort + "\"",
"--user-data-dir=\"" + this.workingDirectory + "\"",
"--user-data-dir=\"" + SYS.getCurrentScriptDirectory() + "\\UserData_Chrome_" + this.profileName + "\"",
"\"" + url + "\""
].join(" "));
sleep(1000);
this.processID = process.ProcessID;
sleep(1000);
shell.release();
} catch (e) {
console.error("ChromeObject.open() -> " + e.message);

View File

@ -106,14 +106,20 @@ var ShellObject = function() {
return oShell;
};
this.createDesktopIcon = function(filename, workingDirectory) {
this.createDesktopIcon = function(shoutcutname, cmd, workingDirectory) {
var desktopPath = this.interface.SpecialFolders("Desktop");
var link = this.interface.CreateShortcut(desktopPath + "\\" + name + ".lnk");
link.IconLocation = filename + ",1";
link.TargetPath = workingDirectory + "\\" + filename;
var path = desktopPath + "\\" + shoutcutname + ".lnk";
if (!FILE.fileExists(path)) {
var link = this.interface.CreateShortcut(path);
link.TargetPath = "cmd";
link.Arguments = "/q /c " + this.build(cmd);
link.WindowStyle = 3;
link.WorkingDirectory = workingDirectory;
//link.Hotkey = "";
//link.IconLocation = "";
link.Save();
}
};
this.release = function() {
@ -156,8 +162,8 @@ exports.runAs = function(FN, args) {
return (new ShellObject()).runAs(FN, args);
};
exports.createDesktopIcon = function(filename, workingDirectory) {
return (new ShellObject()).createDesktopIcon(filename, workingDirectory);
exports.createDesktopIcon = function(name, cmd, workingDirectory) {
return (new ShellObject()).createDesktopIcon(name, cmd, workingDirectory);
};
exports.VERSIONINFO = "Shell interface (shell.js) version 0.2";

61
shoutcut.js Normal file
View File

@ -0,0 +1,61 @@
var SS = require("lib/shadowsocks");
var XML = require("lib/xml");
var Chrome = require("lib/chrome");
var Apps = {
LDPlayer: {},
NoxPlayer: {},
Chrome: {},
ProcessName: {}
};
var AppsMutex = [];
var AppsPID = [];
var items = XML.load("staticip.xml").select("/StaticIP/Item").toArray();
for (var i = 0; i < items.length; i++) {
try {
var name = items[i].getDOM().selectSingleNode("Name").text;
var uniqueId = items[i].getDOM().selectSingleNode("UniqueID").text;
var ipAddress = items[i].getDOM().selectSingleNode("IPAddress").text;
if (name in Apps) {
Apps[name][uniqueId] = ipAddress;
}
} catch (e) {}
}
var do_Chrome = function(_uniqueId) {
var ssPort, ssPID;
for (var uniqueId in Apps.Chrome) {
if (_uniqueId == uniqueId && AppsMutex.indexOf("chrome_" + uniqueId) < 0) {
console.info("Starting Google Chrome: " + uniqueId);
var ss = SS.connect(Apps.Chrome[uniqueId]);
ssPort = ss.listenPort;
ssPID = ss.processID;
console.info("Wait 10 seconds...")
sleep(10000);
Chrome.start("https://whatismyipaddress.com/", ssPort, uniqueId);
AppsPID.push([ssPID]);
AppsMutex.push("chrome_" + uniqueId);
}
}
};
exports.main = function(args) {
if (args.length < 1) {
console.error("arguments could not empty.")
return;
}
while (true) {
sleep(1000);
switch (args[0]) {
case "chrome":
return do_Chrome(args[1]);
}
}
};