Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions images/arcgis-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion javascript-injectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,16 @@ $ screenly asset inject-js "$ASSET_ID" "$JAVASCRIPT_URL"
* Download [zabbix-login-via-credentials.js](https://github.com/Screenly/Playground/tree/master/javascript-injectors/examples/zabbix-login-via-credentials.js) and modify it with your credentials.
* Run `screenly asset inject-js "$ASSET_ID" /path/to/script.js` to add the JavaScript

## Sign in to Dynatrace via credentials
## Sign in to Dynatrace via credentials arcgis-logo.svg

<img src="../images/dynatrace-logo.svg" alt="Dynatrace logo" width="150"/>

* Download [dynatrace-login-via-credentials.js](https://github.com/Screenly/Playground/tree/master/javascript-injectors/examples/dynatrace-login-via-credentials.js) and modify it with your credentials.
* Run `screenly asset inject-js "$ASSET_ID" /path/to/script.js` to add the JavaScript

## Sign in to ArcGIS via credentials

<img src="../images/arcgis-logo.svg" alt="ArcGIS logo" width="150"/>

* Download [arcgis-signin-via-credentials.js](https://github.com/Screenly/Playground/tree/master/javascript-injectors/examples/arcgis-signin-via-credentials.js) and modify it with your credentials.
* Run `screenly asset inject-js "$ASSET_ID" /path/to/script.js` to add the JavaScript
31 changes: 31 additions & 0 deletions javascript-injectors/examples/arcgis-signin-via-credentials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(function () {
const username = '<USERNAME>'
const password = '<PASSWORD>'

const authLocation = '/portal/sharing/rest/oauth2/authorize'

function setValue (selector, value) {
const element = document.querySelector(selector)
element.value = value
element.dispatchEvent(new Event('change'))
}

function submitForm () {
document.querySelector('button[id="signIn"]').click()
}

function login () {
try {
setValue('input[name="username"]', username)
setValue('input[name="password"]', password)
submitForm()
} catch (error) {
console.warn(error)
setTimeout(login, 3000)
}
}

if (window.location.pathname === authLocation) {
login()
}
})()