summaryrefslogtreecommitdiffstats
path: root/plugins/www/resources/js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 17:06:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 17:06:32 +0000
commit2dad5357405ad33cfa792f04b3ab62a5d188841e (patch)
treeb8f8893942060fe3cfb04ac374cda96fdfc8f453 /plugins/www/resources/js
parentInitial commit. (diff)
downloadremmina-upstream/1.4.34+dfsg.tar.xz
remmina-upstream/1.4.34+dfsg.zip
Adding upstream version 1.4.34+dfsg.upstream/1.4.34+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/www/resources/js')
-rw-r--r--plugins/www/resources/js/.eslintrc.json13
-rw-r--r--plugins/www/resources/js/package.json11
-rw-r--r--plugins/www/resources/js/www-js.js98
3 files changed, 122 insertions, 0 deletions
diff --git a/plugins/www/resources/js/.eslintrc.json b/plugins/www/resources/js/.eslintrc.json
new file mode 100644
index 0000000..8f6a415
--- /dev/null
+++ b/plugins/www/resources/js/.eslintrc.json
@@ -0,0 +1,13 @@
+{
+ "env": {
+ "browser": true,
+ "es2021": true
+ },
+ "extends": "eslint:recommended",
+ "parserOptions": {
+ "ecmaVersion": "latest",
+ "sourceType": "module"
+ },
+ "rules": {
+ }
+}
diff --git a/plugins/www/resources/js/package.json b/plugins/www/resources/js/package.json
new file mode 100644
index 0000000..70b8fe8
--- /dev/null
+++ b/plugins/www/resources/js/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "js",
+ "version": "1.0.0",
+ "description": "",
+ "main": "www-js.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "Antenore Gatta",
+ "license": "GPL-2.0"
+}
diff --git a/plugins/www/resources/js/www-js.js b/plugins/www/resources/js/www-js.js
new file mode 100644
index 0000000..06980c9
--- /dev/null
+++ b/plugins/www/resources/js/www-js.js
@@ -0,0 +1,98 @@
+/* jshint esversion: 6 */
+
+/** A quick function to find and fill login fields */
+function setLoginFields () {
+ const evt = new Event('change')
+
+ const frames = window.frames
+
+ let doc
+ let pswdField
+ let usrField
+ let formNode
+ let userFound = false
+
+ if (frames.length !== 0) {
+ for (let i = 0; i < frames.length; i++) {
+ doc = frames[i].document
+ pswdField = doc.querySelectorAll('input[type=\'password\']')
+ if ((pswdField !== undefined) && (pswdField !== null)) {
+ break
+ }
+ }
+ if ((pswdField === undefined) || (pswdField === null)) {
+ /* What if we don't have login forms in the iFrame? -> window */
+ doc = window.document
+ pswdField = doc.querySelectorAll('input[type=\'password\']')
+ }
+ } else {
+ doc = window.document
+ pswdField = doc.querySelectorAll('input[type=\'password\']')
+ }
+
+ if (pswdField !== undefined) {
+ pswdField.forEach(function (pswdElement) {
+ if (pswdElement.getAttribute('autocomplete') !== 'new-password') {
+ pswdElement.value = 'PWDPLACEHOLDER'
+ }
+
+ formNode = pswdElement.form
+ if (formNode !== null) {
+ console.debug('Form elements found')
+ usrField = formNode.querySelectorAll('input[type=\'text\']')
+
+ usrField.forEach(function (usrElement) {
+ usrElement.value = 'USRPLACEHOLDER'
+ if (usrElement !== null) {
+ usrElement.dispatchEvent(evt)
+ userFound = true
+ }
+ })
+ pswdElement.dispatchEvent(evt)
+ }
+ if (formNode === null || !userFound) {
+ console.debug('Form elements found')
+ console.debug('Inputs elements may be in other containers')
+ const inputs = doc.getElementsByTagName('input')
+ for (let i = 0; i < inputs.length; i += 1) {
+ console.debug('input type: ' + inputs[i].type)
+ switch (inputs[i].type) {
+ case 'new-password':
+ continue
+ case 'password':
+ continue
+ case 'hidden':
+ continue
+ case 'email':
+ inputs[i].value = 'USRPLACEHOLDER'
+ userFound = true
+ break
+ case 'text':
+ if (!userFound) {
+ inputs[i].value = 'USRPLACEHOLDER'
+ userFound = true
+ }
+ break
+ default:
+ console.debug('Tentativily add username if no userFound')
+ if (!userFound) {
+ inputs[i].value = 'USRPLACEHOLDER'
+ userFound = true
+ }
+ // code block
+ }
+ if (userFound) {
+ inputs[i].dispatchEvent(evt)
+ console.debug('Username field found and set(?)')
+ break
+ }
+ }
+ }
+ })
+ } else {
+ console.debug('We already have a password')
+
+ }
+}
+
+setLoginFields()