From 5c83c086ac71b45342d71b7c5b4845a0c4605c5e Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 6 Jun 2025 13:01:53 +0900 Subject: [PATCH 1/6] Update chrome.js --- lib/chrome.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/chrome.js b/lib/chrome.js index c651b37..4f627af 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -1246,6 +1246,8 @@ var ChromeObject = function() { this.setVendor = function(vendor) { this.setPublisherName(vendor); console.warn("Deprecated: Please use setPublisherName"); + + return this; }; this.setPublisherName = function(publisherName) { From 9def5b996eff9050bb6328c16a737c23e595df2d Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 6 Jun 2025 19:35:21 +0900 Subject: [PATCH 2/6] Update chrome.js, std.js --- lib/chrome.js | 31 ++++++++++++++++---------- lib/std.js | 62 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/lib/chrome.js b/lib/chrome.js index 4f627af..9edc572 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -14,13 +14,13 @@ var AutoIt = require("lib/autoit"); var Toolkit = require("lib/toolkit"); var ExtraMath = require("lib/extramath"); -// for remote debugging -var pageEventId = 0; +// for Chromium-based browsers +var pageEventId = new STD.Accessor(0); +var publisherName = new STD.Accessor("chrome"); var ChromeObject = function() { STD.EventTarget.apply(this, arguments); // Set event-attachable object - this.publisherName = "chrome"; this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application"; this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application\\chrome.exe"; @@ -63,6 +63,8 @@ var ChromeObject = function() { this.oAutoIt = AutoIt.create(); this.baseScreenX = 1; this.baseScreenY = (!this.isAppMode ? 84 : 32); + this.setPublisherName(publisherName.get()); + return this; }; @@ -102,7 +104,7 @@ var ChromeObject = function() { if (dirname != null) { this.userDataDir = dirname; } else { - this.userDataDir = SYS.getEnvString("APPDATA") + "\\WelsonJS\\" + this.publisherName + "_user_profile"; + this.userDataDir = SYS.getEnvString("APPDATA") + "\\WelsonJS\\" + publisherName.get() + "_user_profile"; } return this; }; @@ -188,7 +190,7 @@ var ChromeObject = function() { cmd.push("\"--user-data-dir=" + this.userDataDir + "\""); cmd.push("\"" + url + "\""); - SHELL.createShoutcut(this.publisherName + " (" + this.profileName + ")", cmd.join(' '), SYS.getCurrentScriptDirectory()); + SHELL.createShoutcut(publisherName.get() + " (" + this.profileName + ")", cmd.join(' '), SYS.getCurrentScriptDirectory()); }; this.setInPrivate = function(flag) { @@ -223,8 +225,7 @@ var ChromeObject = function() { // if the file does not exists, Check the 32bit installation folder again if (!FILE.fileExists(this.binPath)) { - this.workingDirectory = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\:installedDir\\Application"; - this.binPath = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\:installedDir\\Application\\chrome.exe"; + this.setPublisherName("chrome.x86"); this.setProfile(this.profileName, this.installedDir); } @@ -400,11 +401,11 @@ var ChromeObject = function() { try { if (this.pageId != "") { result = this.ws.send("ws://127.0.0.1:" + this.debuggingPort + "/devtools/page/" + this.pageId, JSON.stringify({ - "id": pageEventId, + "id": pageEventId.get(), "method": method, "params": params })); - pageEventId++; + pageEventId.set(pageEventId.get() + 1); console.log("ChromeObject().sendPageRPC() -> Sent"); } else { this.setPageId(null); @@ -1251,9 +1252,9 @@ var ChromeObject = function() { }; this.setPublisherName = function(publisherName) { - publisherName = publisherName.toLowerCase(); + publisherName.set(publisherName.toLowerCase()); - switch (publisherName) { + switch (publisherName.get()) { case "msedge": this.workingDirectory = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Microsoft\\Edge\\Application"; this.binPath = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Microsoft\\Edge\\Application\\msedge.exe"; @@ -1263,6 +1264,11 @@ var ChromeObject = function() { this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application"; this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:installedDir\\Application\\chrome.exe"; break; + + case "chrome.x86": + this.workingDirectory = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\Chrome\\Application"; + this.binPath = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\:installedDir\\Application\\chrome.exe"; + break; case "chromium": this.workingDirectory = SYS.getEnvString("LOCALAPPDATA") + "\\Chromium\\Application"; @@ -1277,6 +1283,7 @@ var ChromeObject = function() { case "whale": this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Naver\\Naver Whale\\Application"; this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Naver\\Naver Whale\\Application\\whale.exe"; + this.baseScreenY = 82; break; case "brave": @@ -1416,7 +1423,7 @@ exports.startDebugInPrivate = function(url, proxy, profileName, debuggingPort, i ; }; -exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.18"; +exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.19"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require; diff --git a/lib/std.js b/lib/std.js index 9bd27c9..78a466d 100644 --- a/lib/std.js +++ b/lib/std.js @@ -539,31 +539,60 @@ GeneratorFunction.Yield = function(message) { GeneratorFunction.Yield.prototype = new Error(); GeneratorFunction.Yield.prototype.constructor = GeneratorFunction.Yield; -function StdStorage() { - this.data = {}; - this.length = 0; +function StdAccessor(initialValue) { + var value = initialValue; - this.commit = function() { - this.length = Object.keys(data).length; + this.get = function() { + return value; }; - this.key = function(idx) { - var keyName = Object.keys(data)[idx]; - return data[keyName]; + + this.set = function(v) { + value = v; }; +} +StdAccessor.isAccessor = function(obj) { + return obj instanceof StdAccessor; +}; + +function StdStorage() { + var data = new StdAccessor({}); + var length = new StdAccessor(0); + + function commit() { + length.set(Object.keys(data.get()).length); + } + this.setItem = function(keyName, keyValue) { - data[keyName] = keyValue; - this.commit(); + var d = data.get(); + d[keyName] = keyValue; + data.set(d); + commit(); }; + this.getItem = function(keyName) { - return data[keyName]; + return data.get()[keyName]; }; + this.removeItem = function(keyName) { - delete data[keyName]; - this.commit(); + var d = data.get(); + delete d[keyName]; + data.set(d); + commit(); }; + this.clear = function() { - this.data = {}; - this.commit(); + data.set({}); + commit(); + }; + + this.key = function(idx) { + var d = data.get(); + var keyName = Object.keys(d)[idx]; + return d[keyName]; + }; + + this.length = function() { + return length.get(); }; } @@ -581,13 +610,14 @@ global.parseEnv = parseEnv; exports.Event = StdEvent; exports.EventTarget = StdEventTarget; +exports.Accessor = StdAccessor; exports.Storage = StdStorage; exports.alert = alert; exports.confirm = confirm; exports.prompt = prompt; -exports.VERSIONINFO = "WelsonJS Standard Library (std.js) version 0.8.16"; +exports.VERSIONINFO = "WelsonJS Standard Library (std.js) version 0.8.17"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require; From 13839a1fc333727ee5b7054aa38597beea493991 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 6 Jun 2025 19:40:46 +0900 Subject: [PATCH 3/6] Update chrome.js --- lib/chrome.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/chrome.js b/lib/chrome.js index 9edc572..85a42dd 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -21,8 +21,8 @@ var publisherName = new STD.Accessor("chrome"); var ChromeObject = function() { STD.EventTarget.apply(this, arguments); // Set event-attachable object - this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application"; - this.binPath = SYS.getEnvString("PROGRAMFILES") + "\\Google\\Chrome\\Application\\chrome.exe"; + this.workingDirectory = null; + this.binPath = null; this.profileName = "Default"; this.userDataDir = null; @@ -34,7 +34,7 @@ var ChromeObject = function() { "protocol": "socks5", "host": "127.0.0.1", "port": 1080, - "ua": null + "userAgent": null }; this.inPrivate = false; @@ -198,13 +198,13 @@ var ChromeObject = function() { return this; }; - this.setUserAgent = function(ua) { - this.userAgent = ua; + this.setUserAgent = function(userAgent) { + this.userAgent = userAgent; return this; }; - this.addUserAgent = function(ua) { - this.userAgents.push(ua); + this.addUserAgent = function(userAgent) { + this.userAgents.push(userAgent); return this; }; @@ -283,8 +283,8 @@ var ChromeObject = function() { if (this.proxy != null && this.isPreventProxy != true) { console.log("Enabled proxy server:", this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port); cmd.push("--proxy-server=\"" + this.proxy.protocol + "://" + this.proxy.host + ":" + this.proxy.port + "\""); - if (this.proxy.ua != null) { - this.setUserAgent(this.proxy.ua); + if (this.proxy.userAgent != null) { + this.setUserAgent(this.proxy.userAgent); } } From 0de9edc83c9d0ba66e526056b9abff98c610fed2 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 7 Jun 2025 04:18:20 +0900 Subject: [PATCH 4/6] Update chrome.js --- lib/chrome.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/chrome.js b/lib/chrome.js index 85a42dd..992db34 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -1251,8 +1251,8 @@ var ChromeObject = function() { return this; }; - this.setPublisherName = function(publisherName) { - publisherName.set(publisherName.toLowerCase()); + this.setPublisherName = function(_publisherName) { + publisherName.set(_publisherName.toLowerCase()); switch (publisherName.get()) { case "msedge": From b168b57de8b1e2702b82cc538a79b2749b8a394f Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 7 Jun 2025 04:26:33 +0900 Subject: [PATCH 5/6] Update chrome.js --- lib/chrome.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/chrome.js b/lib/chrome.js index 992db34..d44beba 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -79,8 +79,11 @@ var ChromeObject = function() { this.setProfile = function(profileName, installedDir) { this.profileName = (profileName == "Default" ? "Chrome" : profileName); - this.workingDirectory = this.workingDirectory.replace(":installedDir", installedDir); - this.binPath = this.binPath.replace(":installedDir", installedDir); + if (installedDir != null) { + this.installedDir = installedDir; + } + this.workingDirectory = this.workingDirectory.replace(":installedDir", this.installedDir); + this.binPath = this.binPath.replace(":installedDir", this.installedDir); return this; }; @@ -1423,7 +1426,7 @@ exports.startDebugInPrivate = function(url, proxy, profileName, debuggingPort, i ; }; -exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.19"; +exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.20"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require; From de41c115cd240949a5fa168b08a708b6d7c4e213 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 7 Jun 2025 04:46:28 +0900 Subject: [PATCH 6/6] Update std.js --- lib/std.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/std.js b/lib/std.js index 78a466d..6faebd7 100644 --- a/lib/std.js +++ b/lib/std.js @@ -587,8 +587,7 @@ function StdStorage() { this.key = function(idx) { var d = data.get(); - var keyName = Object.keys(d)[idx]; - return d[keyName]; + return Object.keys(d)[idx]; }; this.length = function() {