Advanced settings of the Web Page app allow you to use custom JavaScript for website login.
Notes:
- JavaScript is only supported for single-page logins.
- JavaScript is only available on Enplug devices and Windows Player.
- JavaScript isn't supported on Web Player, Content URL, or third-party devices (EX: BrightSign players).
Accessing Advanced Settings
To access Advanced Setting of a web page:
- Log into Enplug.
- Click the Apps drop-down in the top menu.
- Open the Web Page app.
- Select a web page.
- To create a new web page, click Add Web Page.
- Click Show advanced settings.
From here, you'll scroll down to the JavaScript settings section and enter the corresponding information.
Once completed, click Save in the upper right corner.
JavaScript Examples
The following of JavaScript examples that can be used in the Advanced Settings of the Web Page app.
Generic:
document.querySelector("#id__email").value = webView.getUsername();
document.querySelector("#id__password").value = webView.getPassword();
document.querySelector(".login_button").click();var v1 = document.getElementById('username');
v1.value = webView.getUsername();
var v2 = document.getElementById('password');
v2.value = webView.getPassword(); document.getElementById('loginBtn').click();SharePoint:
try {
document.querySelector('#username').value = webView.getUsername();
var next = document.querySelector('form a');
if(next){next.click();}
} catch (e) { }
try {
const pass = document.querySelector('#password');
if (pass) {
pass.value = webView.getPassword();
document.querySelector('form button').click();
}
} catch (e) { }Okta:
function login() {
if ( document ) {
try {
var event = document.createEvent('Event');
event.initEvent('input', true, true);
//'okta-signin-username' is the ID of the field where the Email address will be entered on the page.
document.getElementById('okta-signin-username').value = webView.getUsername();
document.getElementById('okta-signin-username').dispatchEvent(event);
//'okta-signin-password' is the ID of the field where the Password will be entered on the page.
document.getElementById('okta-signin-password').value = webView.getPassword();
document.getElementById('okta-signin-password').dispatchEvent(event);
//'okta-signin-submit' is the ID of the submit button located on the page.
document.getElementById('okta-signin-submit').click();
} catch(error){}
} else {
setTimeout(login, 800);
}
};
login();Microsoft Online:
function submit(name, value, koProp) {
return function () {
var el = document.querySelector('div input[name=' + name + ']:not(.moveOffScreen)');
if (el) {
ko.dataFor(el)[koProp].value(value);
return true;
}
}
}
function tryRemembered() {
return new Promise(function (resolve) {
var container = document.querySelector('#tilesHolder');
if (!container) { resolve(false); return; }
ko.dataFor(container).tile_onClick(ko.dataFor(document.querySelector('.tile-container')));
resolve(true);
});
}
function complete(task) {
return new Promise(function (resolve) { schedule(task, resolve); });
}
function schedule(task, resolve) {
setTimeout(function () { tryToComplete(task, resolve); }, 2000);
}
function tryToComplete(task, resolve) {
if (task()) {
document.querySelector(`input#idSIButton9`).click();
resolve();
}
else { schedule(task, resolve); }
}
tryRemembered().then(function (foundLogin) {
var completePassword = function () { complete(submit('passwd', webView.getPassword(), 'passwordTextbox')) };
if (foundLogin) {
completePassword();
} else {
complete(submit('loginfmt', webView.getUsername(), 'usernameTextbox'))
.then(completePassword);
}
});Add Auto-Scroll to a Web Page:
function doScroll(body, interval) {
body.animate({ scrollTop: body.scrollTop() + 100 }, interval, 'linear', function () {
setTimeout(function () { doScroll(body, interval) });
});
}
(function run(interval) { doScroll($('html'), interval) })(2500);For questions or concerns, please reach out to our Support Team at support@spectrio.com.