Stop browser autofill stuffing login username into transfer amount fields.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -285,22 +285,34 @@
|
||||
}
|
||||
|
||||
function hardenOrderAutofill() {
|
||||
const note = document.getElementById("opt-signal-note");
|
||||
if (!note) return;
|
||||
function wipeNote() {
|
||||
if (/^[a-z][a-z0-9._-]{1,31}$/i.test(String(note.value || "").trim())) {
|
||||
note.value = "";
|
||||
}
|
||||
function looksLikeUsername(v) {
|
||||
return /^[a-z][a-z0-9._-]{1,31}$/i.test(String(v || "").trim());
|
||||
}
|
||||
wipeNote();
|
||||
note.addEventListener("focus", function () {
|
||||
note.removeAttribute("readonly");
|
||||
function harden(el) {
|
||||
if (!el) return;
|
||||
function wipe() {
|
||||
if (looksLikeUsername(el.value)) el.value = "";
|
||||
}
|
||||
wipe();
|
||||
el.addEventListener("focus", function () {
|
||||
el.removeAttribute("readonly");
|
||||
});
|
||||
el.addEventListener("blur", function () {
|
||||
if (!el.value) el.setAttribute("readonly", "readonly");
|
||||
});
|
||||
setTimeout(wipe, 200);
|
||||
setTimeout(wipe, 800);
|
||||
setTimeout(wipe, 2000);
|
||||
}
|
||||
const note = document.getElementById("opt-signal-note");
|
||||
harden(note);
|
||||
[
|
||||
"opt-sheets-amount",
|
||||
"opt-eth-amount",
|
||||
"opt-target-idx",
|
||||
].forEach(function (id) {
|
||||
harden(document.getElementById(id));
|
||||
});
|
||||
note.addEventListener("blur", function () {
|
||||
if (!note.value) note.setAttribute("readonly", "readonly");
|
||||
});
|
||||
setTimeout(wipeNote, 200);
|
||||
setTimeout(wipeNote, 800);
|
||||
}
|
||||
|
||||
function quoteUrl(instId) {
|
||||
|
||||
Reference in New Issue
Block a user