Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added javascript injector for logging into zabbix #125

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Binary file added images/zabbix-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions javascript-injectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,10 @@ $ screenly asset inject-js "$ASSET_ID" "$JAVASCRIPT_URL"

* Download [cyfe-sign-in-via-credentials.js](https://github.com/Screenly/Playground/tree/master/javascript-injectors/examples/cyfe-sign-in-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 Zabbix via credentials

<img src="../images/zabbix-logo.png" alt="Zabbix logo" width="150"/>

* 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
31 changes: 31 additions & 0 deletions javascript-injectors/examples/zabbix-login-via-credentials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(function () {
const username = '<YOUR_USERNAME>'
const password = '<YOUR PASSWORD>'

const authLocation = '/index.php'

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

function submitForm () {
document.querySelector('button[value="Sign in"]').click()
}

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

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