mirror of
https://github.com/twofas/2fas-browser-extension.git
synced 2024-11-25 11:40:30 +01:00
#1570 inputToken improvement
This commit is contained in:
parent
e265080aae
commit
b2d1fe8a00
@ -34,61 +34,38 @@ const inputToken = (request, inputElement, siteURL) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tokenLength = request.token.length;
|
const tokenLength = request.token.length;
|
||||||
let clearEvent = new Event('change', { bubbles: true, cancelable: true });
|
|
||||||
let inputEvent = new Event('input', { bubbles: true, cancelable: true });
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
let currentToken = '';
|
||||||
|
|
||||||
|
inputElement.focus();
|
||||||
|
|
||||||
for (let i = 0; i < tokenLength; i++) {
|
for (let i = 0; i < tokenLength; i++) {
|
||||||
promises.push(
|
promises.push(
|
||||||
delay(() => {
|
delay(() => {
|
||||||
// MANY INPUTS FIX
|
if (document.activeElement.value.length > 0 && document.activeElement.value !== currentToken) {
|
||||||
if (i === 0) {
|
document.activeElement.value = '';
|
||||||
inputElement.focus();
|
|
||||||
inputElement.value = '';
|
|
||||||
inputElement.dispatchEvent(clearEvent);
|
|
||||||
inputElement.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inputElement.contains(document.activeElement)) {
|
document.activeElement.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, cancelable: true, charCode: 0, code: `Digit${request.token[i]}`, ctrlKey: false, key: request.token[i], keyCode: 48 + parseInt(request.token[i], 10), location: 0, metaKey: false, repeat: false, shiftKey: false, which: 48 + parseInt(request.token[i], 10) }));
|
||||||
if (!siteURL.includes('secure.newegg')) { // NEWEGG FIX
|
document.activeElement.dispatchEvent(new KeyboardEvent('keypress', { bubbles: true, cancelable: true, charCode: 48 + parseInt(request.token[i], 10), code: `Digit${request.token[i]}`, ctrlKey: false, key: request.token[i], keyCode: 48 + parseInt(request.token[i], 10), location: 0, metaKey: false, repeat: false, shiftKey: false, which: 48 + parseInt(request.token[i], 10) }));
|
||||||
document.activeElement.focus();
|
|
||||||
document.activeElement.value = '';
|
if (document.activeElement.type.toLowerCase() === 'number') {
|
||||||
document.activeElement.dispatchEvent(clearEvent);
|
document.activeElement.value += parseInt(request.token[i], 10);
|
||||||
document.activeElement.focus();
|
} else {
|
||||||
}
|
document.activeElement.value += request.token[i];
|
||||||
}
|
}
|
||||||
// END MANY INPUTS FIX
|
|
||||||
|
|
||||||
document.activeElement.value += request.token[i];
|
document.activeElement.dispatchEvent(new InputEvent('input', { bubbles: true, cancelable: true, data: request.token[i], inputType: 'insertText', which: 0 }));
|
||||||
document.activeElement.dispatchEvent(inputEvent);
|
document.activeElement.dispatchEvent(new KeyboardEvent('keyup', { bubbles: true, cancelable: true, charCode: 0, code: `Digit${request.token[i]}`, ctrlKey: false, key: request.token[i], keyCode: 48 + parseInt(request.token[i], 10), location: 0, metaKey: false, repeat: false, shiftKey: false, which: 48 + parseInt(request.token[i], 10) }));
|
||||||
|
document.activeElement.dispatchEvent(new Event('change', { bubbles: true, cancelable: true }));
|
||||||
|
|
||||||
// NORTON FIX
|
currentToken += request.token[i];
|
||||||
if (siteURL.includes('login.norton') || siteURL.includes('indodax.com')) {
|
|
||||||
document.activeElement.dispatchEvent(new KeyboardEvent('keyup', { key: request.token[i] }));
|
|
||||||
}
|
|
||||||
// END NORTON FIX
|
|
||||||
|
|
||||||
// SOC PRIME FIX
|
|
||||||
if (siteURL.includes('socprime.com')) {
|
|
||||||
const nextInput = document.activeElement.getAttribute('data-next');
|
|
||||||
|
|
||||||
if (nextInput) {
|
|
||||||
const nextInputEl = document.querySelector(`input[name="${nextInput}"]`);
|
|
||||||
nextInputEl.focus();
|
|
||||||
} else {
|
|
||||||
document.activeElement.dispatchEvent(new KeyboardEvent('keyup', { key: 'Enter' }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// END SOC PRIME FIX
|
|
||||||
}, 100 * i)
|
}, 100 * i)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
clearEvent = null;
|
|
||||||
inputEvent = null;
|
|
||||||
|
|
||||||
const tab = await getTabData();
|
const tab = await getTabData();
|
||||||
|
|
||||||
if (tab.status === 'complete') {
|
if (tab.status === 'complete') {
|
||||||
|
Loading…
Reference in New Issue
Block a user