mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-06-10 07:09:03 +00:00
Update chrome.js, std.js
This commit is contained in:
parent
5c83c086ac
commit
9def5b996e
|
@ -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;
|
||||
|
|
62
lib/std.js
62
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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user