Editor for scripts in TheFlex
Custom Scripts for any websites and web apps can be configured in the TheFlex settings. These can be used to add functions or make visual adjustments without having to change the website.
Code editor for Custom Scripts
- General functionalities
- ITS-Mobile optimization
- Login automation
Hello world
Normal Javascript can be used to adapt websites.
Customize CSS
The appearance of the page can be changed by adjusting the CSS.
Page Ready Event
The page is only fully loaded and rendered after this event.
Open dialog with autofocus
This script opens a customizable dialog with autofocus in which you can scan directly.
ITS example page
Almost all elements in ITS-Mobile can be customized.
ITS login screen for small devices
Optimization of the ITS login screen for devices with small screens.
Scroll functionality for ITS-Mobile
Example of how to add a scrollbar.
Read stored login data
Read the username/password which is saved for the current start page.
SAP Fiori login with NFC
An NFC tag is read and automatically logged into SAP Fiori with the stored login data.
ITS-Mobile login with QR code
When a QR code is scanned, the user name/password is parsed and the login is executed in ITS-Mobile.
Microsoft Azure AD/ENTRA with NFC
A multi-stage login process can also be automated.
Important information for scripts
If it is possible to maintain and deliver these scripts directly in the website, then this option should always be preferred. However, if this is not possible, the functionality of the Custom Scripts can be used. Examples of when these Custom Scripts can be used appropriately include
- Visual adjustments to old websites (e.g. ITS-Mobile) that can no longer be changed or are difficult to change.
- Visual adjustments to websites for some special devices.
- Adding login functionalities (e.g. login via NFC chip or QR code) to login pages that cannot be changed (e.g. Microsoft Azure or SAP).
- Adding any scripts to websites or web apps of other service providers without access to their source code.
deviceready-event
If certain elements, e.g. an input field or button, are to be accessed in the script, the deviceready event must be waited for. Only then is the page fully loaded and all elements available:
document.addEventListener("deviceready", function () {
// my script
});
Active URL
For each script, a URL can be defined for which the script is active. This means that the script is only injected for these URLs. However, the script does not check for this exact URL, but only whether the current URL starts with the configured URL.
Example: The URL https://theflexbrowser.com is opened.
- If https is configured as the URL for the script, then this script will be executed.
- If https://theflexbrowser is configured as the URL for the script, this script will be executed.
- If https://other.com is configured as the URL for the script, this script will not be executed.
It must be carefully checked which scripts are executed, as these have full access to all data within the website accessed as well as all user input.
Transfer scripts into the browser
There are three ways to transfer the script from this editor to the browser:
1. Maintenance via an MDM
The easiest way is to roll out the scripts via an MDM such as SOTI or Intune. The scripts can also be managed in these tools, whereby they are automatically transferred to the devices.
Intune does not allow new lines within JSON files, so the custom script must be condensed. Additionally, quotes in custom scripts should be escaped with a backslash ( \ ) or changed to single quotes ( '' ).
2. Import via QR code
If the script is shorter than 3000 characters, it can be displayed here as a QR code using the Export as QR code button. In the TheFlex browser settings, this QR code can be scanned in the scripts via Import script.
3. Screenshare
This option is only recommended for development purposes. If the device is connected to this PC, the scripts can be copied to the browser settings using ctrl-c and ctrl-v.
A further option is planned for the Q3 2024 release to make it even easier to transfer the scripts from this PC to any TheFlex browser. As soon as this new function can be used, it will be announced in this article and in the changelogs.