diff --git a/lib/chrome.js b/lib/chrome.js index 4b78aac..f49acc5 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -1,6 +1,6 @@ -////////////////////////////////////////////////////////////////////////////////// -// Google Chrome API -///////////////////////////////////////////////////////////////////////////////// +// chrome.js +// Namhyeon Go +// https://github.com/gnh1201/welsonjs var STD = require("lib/std"); var RAND = require("lib/rand"); @@ -234,7 +234,7 @@ var ChromeObject = function(interfaces) { this.open = function(url) { this.setProfile(this.profileName, this.installedDir); - + // if the file does not exists, Check the 32bit installation folder again if (!FILE.fileExists(this.binPath)) { this.workingDirectory = SYS.getEnvString("PROGRAMFILES(X86)") + "\\Google\\Chrome\\Application"; @@ -808,8 +808,8 @@ var ChromeObject = function(interfaces) { ; } - else if (searchText.indexOf(':text(') == 0) { - this.evaluate(ExtraMath.export_measureSimilarity()); + else if (searchText.indexOf(':text(') == 0) { + this.evaluate(ExtraMath.export_measureSimilarity()); searchText = searchText.substring(searchText.indexOf('(') + 1, searchText.lastIndexOf(')')); s += '(function() {' @@ -1183,17 +1183,22 @@ var ChromeObject = function(interfaces) { return this.evaluate('__getWindow().addEventListener("click",function(e){var t=e.clientX,n=e.clientY,l=__getDocument().createElement("div");l.style.position="absolute",l.style.width="20px",l.style.height="20px",l.style.backgroundColor="#00ff00",l.style.zIndex=99999,l.style.top=__getWindow().pageYOffset+n-10+"px",l.style.left=__getWindow().pageXOffset+t-10+"px",__getDocument().body.appendChild(l)});'); }; + // Added in 2023-12-27 + this.getTextsBySelectorAll = function(selector) { + return JSON.parse(this.getEvaluatedValue('JSON.stringify(Object.values(__getDocument().querySelectorAll("' + selector + '")).reduce(function(a, x) { a.push(x.innerText); return a; }, []))')); + }; + this.getWindowInnerHeight = function() { return parseInt(this.getEvaluatedValue('__getWindow().innerHeight')); }; - this.getWindowPageYOffset = function() { - return this.getEvaluatedValue('__getWindow().pageYOffset'); - }; - - this.getDocumentBodyOffsetHeight = function() { - return this.getEvaluatedValue('__getDocument().body.offsetHeight'); - }; + this.getWindowPageYOffset = function() { + return this.getEvaluatedValue('__getWindow().pageYOffset'); + }; + + this.getDocumentBodyOffsetHeight = function() { + return this.getEvaluatedValue('__getDocument().body.offsetHeight'); + }; this.getDocumentScrollTop = function() { return parseInt(this.getEvaluatedValue('__getDocument().documentElement.scrollTop')); @@ -1204,9 +1209,9 @@ var ChromeObject = function(interfaces) { return (elementPosition.y > 0 && (elementPosition.y + elementPosition.h < this.getWindowInnerHeight())); }; - this.isPageScrollEnded = function() { - return (this.getWindowInnerHeight() + this.getWindowPageYOffset()) >= this.getDocumentBodyOffsetHeight; - }; + this.isPageScrollEnded = function() { + return (this.getWindowInnerHeight() + this.getWindowPageYOffset()) >= this.getDocumentBodyOffsetHeight; + }; this.__escape = function(value) { var pos = value.indexOf("__escaped:"); @@ -1367,7 +1372,7 @@ exports.startDebugInPrivate = function(url, proxy, profileName, debuggingPort, i ; }; -exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.4"; +exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.5"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require;