From d5c2a0dd2cff06230eea1d7930d8cd17ba377522 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 30 Jul 2021 03:22:15 +0900 Subject: [PATCH] Update chrome.js --- lib/chrome.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/chrome.js b/lib/chrome.js index f78bdcb..520b4ed 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -511,15 +511,26 @@ var ChromeObject = function() { return this.sendPageRPC("Page.reload", {}); }; - this.hasClass = function(selector, className) { - var result = this.getEvaluatedValue('document.querySelector(".html5-video-player").getAttribute("class")'); - if (result) { - var classNames = result.split(' '); - return (classNames.indexOf(className) > -1); - } else { - return false; + this.hasClass = function(seletctor, className) { + try { + var result = this.getEvaluatedValue('document.querySelector(".html5-video-player").getAttribute("class")'); + if (typeof(result) === "string") { + return (result.split(' ').indexOf(className) > -1); + } else { + return false; + } + } catch (e) { + console.error("ChromeObject.hasClass() -> " + e.message); } }; + + this.getAttribute = function(selector, attributeName) { + return this.getEvaluatedValue('document.querySelector("' + selector + '").getAttribute("' + attributeName + '")'); + }; + + this.sendSpaceKey = function() { + this.oAutoIt.Send("{SPACE}"); + }; this.create(); };