Hi,
I have a XD234 running an HTML site that loads correctly but I need it to auto log in.
I have a javascript that has been tested working when used through Chrome devtools.
I have found a brightscript that should allow the injection of the javascript into the HTML when loaded, but instead, I get the following error in the debug log:
[ 30.425] + Plugin for Autorunner is invalid.
[ 30.877] + 2025/03/14 17:05:06.372
[ 30.877] + msg received - type=roHtmlWidgetEvent
[ 30.877] + Plugin for Autorunner is invalid.
[ 30.878] + reason = load-started
Autorunner is what I have called the script plugin in BA:Connected.
Here is the brightscript I am using for the script plugin:
Function sendWebLogin_Initialize(msgPort As Object, userVariables As Object, bsp As Object)
sendWebLogin = newSendWebLogin(msgPort, userVariables, bsp)
return sendWebLogin
End Function
Function newSendWebLogin(msgPort As Object, userVariables As Object, bsp As Object)
'create the new object
s={}
s.objectName = "sendWebLogin_object"
s.msgPort = msgPort
s.userVariables = userVariables
s.bsp = bsp
s.htmlwidget = invalid ' We'll use the FindHTMLWidget method to set this later
s.ProcessEvent = sendWebLogin_ProcessEvent
return s
End Function
Function sendWebLogin_ProcessEvent(event As Object) as boolean
m.htmlwidget = FindHTMLWidget(m.bsp) 'find the htmlwidget in the presentation
'Receive a plugin message
if type(event) = "roHtmlWidgetEvent" then
eventData = event.getData()
if type(eventData) = "roAssociativeArray" and type(eventData.reason) = "roString" then
if eventData.reason = "load-finished" then
print "calling javascript login"
m.htmlwidget.InjectJavaScript("function setReactInputValue(element, value) {let nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;nativeInputValueSetter.call(element, value);element.dispatchEvent(new Event('input', { bubbles: true }));element.dispatchEvent(new Event('change', { bubbles: true }));}let username = document.getElementById(':r0:');let password = document.getElementById(':r1:');setReactInputValue(username, 'brightsign');setReactInputValue(password, 'bty2URP8cvu1azu@qfe');document.querySelectorAll('button')[1].click();")
end if
end if
end if
return false
End Function
Function FindHTMLWidget(bsp)
for each baZone in bsp.sign.zonesHSM
if baZone.loadingHtmlWidget <> invalid then
return baZone.loadingHtmlWidget
end if
end for
print "Couldn't find htmlwidget"
return false
End Function
Note that I do not get a flashing error light on the player.
Hoping somebody can help,
Thanks