#1515 clearAfterInputToken added

This commit is contained in:
GrzegorzZajac000 2024-03-25 12:34:05 +01:00
parent ccf4df36a1
commit d965d039ec
3 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,43 @@
//
// This file is part of the 2FAS Browser Extension (https://github.com/twofas/2fas-browser-extension)
// Copyright © 2023 Two Factor Authentication Service, Inc.
// Contributed by Grzegorz Zając. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
const { loadFromLocalStorage, saveToLocalStorage } = require('../../localStorage')
const clearAfterInputToken = (inputElement, tabID) => {
// CLEAR INPUT
if (inputElement) {
if (typeof inputElement?.removeAttribute === 'function') {
inputElement.removeAttribute('data-twofas-input');
}
}
// CLEAR STORAGE
return loadFromLocalStorage([`tabData-${tabID}`])
.then(storage => {
if (storage[`tabData-${tabID}`] && storage[`tabData-${tabID}`].lastFocusedInput) {
delete storage[`tabData-${tabID}`].lastFocusedInput;
return saveToLocalStorage({ [`tabData-${tabID}`]: storage[`tabData-${tabID}`] });
}
return true;
})
.catch(() => {});
};
module.exports = clearAfterInputToken;

View File

@ -18,6 +18,7 @@
// //
exports.addFormElementsNumber = require('./addFormElementsNumber'); exports.addFormElementsNumber = require('./addFormElementsNumber');
exports.clearAfterInputToken = require('./clearAfterInputToken');
exports.clearFormElementsNumber = require('./clearFormElementsNumber'); exports.clearFormElementsNumber = require('./clearFormElementsNumber');
exports.clickSubmit = require('./clickSubmit'); exports.clickSubmit = require('./clickSubmit');
exports.closeNotificationInfo = require('./closeNotificationInfo'); exports.closeNotificationInfo = require('./closeNotificationInfo');

View File

@ -21,6 +21,7 @@
const delay = require('../../partials/delay'); const delay = require('../../partials/delay');
const getTabData = require('./getTabData'); const getTabData = require('./getTabData');
const clickSubmit = require('./clickSubmit'); const clickSubmit = require('./clickSubmit');
const clearAfterInputToken = require('./clearAfterInputToken');
const inputToken = (request, inputElement, siteURL) => { const inputToken = (request, inputElement, siteURL) => {
return new Promise(resolve => { return new Promise(resolve => {
@ -81,6 +82,8 @@ const inputToken = (request, inputElement, siteURL) => {
clickSubmit(inputElement, siteURL); clickSubmit(inputElement, siteURL);
} }
clearAfterInputToken(inputElement, tab.id);
return resolve({ return resolve({
status: 'completed', status: 'completed',
url: siteURL url: siteURL