mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-15 22:21:04 +00:00
fix
This commit is contained in:
parent
e902cc8625
commit
b82e1006b4
|
@ -37,11 +37,28 @@ var ChromeObject = function() {
|
||||||
this.open = function(url) {
|
this.open = function(url) {
|
||||||
this.setProfileName(this.profileName);
|
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)) {
|
if (!FILE.fileExists(this.binPath)) {
|
||||||
console.error("ChromeObject.open() -> '" + this.profileName + "' 존재하지 않는 프로파일입니다. 생성 후 사용해주세요.");
|
console.error("ChromeObject.open() -> '" + this.profileName + "' 존재하지 않는 프로파일입니다. 생성 후 사용해주세요.");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 바로가기 생성
|
||||||
|
SHELL.createDesktopIcon("Chrome (" + this.profileName + ")", [
|
||||||
|
"cscript",
|
||||||
|
"app.js",
|
||||||
|
"shoutcut",
|
||||||
|
"chrome",
|
||||||
|
this.profileName
|
||||||
|
], SYS.getCurrentScriptDirectory());
|
||||||
|
|
||||||
var process;
|
var process;
|
||||||
while (this.processID == 0) {
|
while (this.processID == 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -66,11 +83,12 @@ var ChromeObject = function() {
|
||||||
"\"" + 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=\"" + this.workingDirectory + "\"",
|
"--user-data-dir=\"" + SYS.getCurrentScriptDirectory() + "\\UserData_Chrome_" + this.profileName + "\"",
|
||||||
"\"" + url + "\""
|
"\"" + url + "\""
|
||||||
].join(" "));
|
].join(" "));
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
this.processID = process.ProcessID;
|
this.processID = process.ProcessID;
|
||||||
|
sleep(1000);
|
||||||
shell.release();
|
shell.release();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("ChromeObject.open() -> " + e.message);
|
console.error("ChromeObject.open() -> " + e.message);
|
||||||
|
|
24
lib/shell.js
24
lib/shell.js
|
@ -106,14 +106,20 @@ var ShellObject = function() {
|
||||||
return oShell;
|
return oShell;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.createDesktopIcon = function(filename, workingDirectory) {
|
this.createDesktopIcon = function(shoutcutname, cmd, workingDirectory) {
|
||||||
var desktopPath = this.interface.SpecialFolders("Desktop");
|
var desktopPath = this.interface.SpecialFolders("Desktop");
|
||||||
var link = this.interface.CreateShortcut(desktopPath + "\\" + name + ".lnk");
|
var path = desktopPath + "\\" + shoutcutname + ".lnk";
|
||||||
link.IconLocation = filename + ",1";
|
|
||||||
link.TargetPath = workingDirectory + "\\" + filename;
|
if (!FILE.fileExists(path)) {
|
||||||
link.WindowStyle = 3;
|
var link = this.interface.CreateShortcut(path);
|
||||||
link.WorkingDirectory = workingDirectory;
|
link.TargetPath = "cmd";
|
||||||
link.Save();
|
link.Arguments = "/q /c " + this.build(cmd);
|
||||||
|
link.WindowStyle = 3;
|
||||||
|
link.WorkingDirectory = workingDirectory;
|
||||||
|
//link.Hotkey = "";
|
||||||
|
//link.IconLocation = "";
|
||||||
|
link.Save();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.release = function() {
|
this.release = function() {
|
||||||
|
@ -156,8 +162,8 @@ exports.runAs = function(FN, args) {
|
||||||
return (new ShellObject()).runAs(FN, args);
|
return (new ShellObject()).runAs(FN, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.createDesktopIcon = function(filename, workingDirectory) {
|
exports.createDesktopIcon = function(name, cmd, workingDirectory) {
|
||||||
return (new ShellObject()).createDesktopIcon(filename, workingDirectory);
|
return (new ShellObject()).createDesktopIcon(name, cmd, workingDirectory);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.VERSIONINFO = "Shell interface (shell.js) version 0.2";
|
exports.VERSIONINFO = "Shell interface (shell.js) version 0.2";
|
||||||
|
|
61
shoutcut.js
Normal file
61
shoutcut.js
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user