Skip to content

Instantly share code, notes, and snippets.

@SteveRyherd
Created October 10, 2024 13:54
Show Gist options
  • Save SteveRyherd/fc76a7159b9b63e149e2aa2af02d5770 to your computer and use it in GitHub Desktop.
Save SteveRyherd/fc76a7159b9b63e149e2aa2af02d5770 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Change OTP Field Type
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Change the password field for OTP to a standard text field with autocomplete for one-time codes.
// @match https://ep.fram.idm.toyota.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log('Tampermonkey script started');
// Function to change the OTP field once it's found
function modifyOtpField() {
var otpField = document.getElementById('idToken1');
if (otpField) {
console.log('OTP field found!');
otpField.type = 'text';
otpField.setAttribute('autocomplete', 'one-time-code');
console.log('OTP field modified successfully');
} else {
console.log('OTP field not yet available');
}
}
// Set up a MutationObserver to watch for changes in the DOM
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
// Try modifying the OTP field each time there's a change in the DOM
modifyOtpField();
});
});
// Start observing the body for changes in the DOM tree
observer.observe(document.body, { childList: true, subtree: true });
// Call modifyOtpField in case the element is already present when the script runs
modifyOtpField();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment