NFC with Custom Scripts in TheFlex
Writing Login Data to Your NFC Chip in TheFlex
To store login data on an NFC chip using theFlex, proceed as follows:
- Navigate to Settings > Useful Tools > NFC Writer.
- Select text/pg from the dropdown menu.
- Enter your email address or username in the first input field.
- Enter your password in the second input field.
- Hold your NFC chip to the back of your device until it vibrates.
- Tap the blue button to write the data onto the NFC chip.
If no error message appears, you can return and open the NFC Reader. Again, select text/pg in the dropdown. Hold the chip to your device—your previously saved information should now be displayed.
Creating a Custom Script to Read the NFC Chip
To ensure that the script is executed only on the intended login page, the exact URL of the login page should be specified. Below is an example of how an automated NFC login script for Microsoft might look. After reading the NFC chip, the login process will proceed automatically:
document.addEventListener("deviceready", function() {
function showNFCData(username, password) {
alert("Username: " + username + "\nPassword: " + password);
var emailInput = document.querySelector('input[type="email"]');
var checkEmailInterval;
if (emailInput) {
var emailAddress = username.toLowerCase();
emailInput.value = emailAddress;
emailInput.blur();
checkEmailInterval = setInterval(function() {
var emailConfirmationButton = document.querySelector('button, input[type="submit"]');
if (emailConfirmationButton) {
clearInterval(checkEmailInterval);
emailConfirmationButton.click();
checkPassword(password);
}
}, 1000);
}
}
function checkPassword(userPassword) {
var checkPasswordInterval = setInterval(function() {
var passwordInput = document.querySelector('input[type="password"]');
if (passwordInput) {
var confirmationButton = document.querySelector('input[type="submit"]');
if (confirmationButton) {
passwordInput.value = userPassword;
passwordInput.blur();
clearInterval(checkPasswordInterval);
confirmationButton.click();
}
}
}, 1000);
}
function checkCheckbox() {
var checkCheckboxInterval = setInterval(function() {
var confirmationCheckbox = document.querySelector('input[type="checkbox"]');
if (confirmationCheckbox) {
clearInterval(checkCheckboxInterval);
confirmationCheckbox.checked = true;
var backButton = document.getElementById('idBtn_Back');
if (backButton) {
backButton.focus();
backButton.click();
}
}
}, 1000);
}
checkCheckbox();
nfc.addNdefListener(
function (nfcEvent) {
var message = nfcEvent.tag.ndefMessage;
var usernamePayload = message[0];
var username = nfc.bytesToString(usernamePayload.payload).toLowerCase();
var password = "";
if (message.length > 1) {
var passwordPayload = message[1];
password = nfc.bytesToString(passwordPayload.payload);
}
showNFCData(username, password);
},
function () {
console.log('Scann failed');
}
);
});