mirror of
https://github.com/twofas/2fas-browser-extension.git
synced 2024-11-22 02:00:08 +01:00
#1515 clearAfterInputToken added
This commit is contained in:
parent
ccf4df36a1
commit
d965d039ec
43
src/content/functions/clearAfterInputToken.js
Normal file
43
src/content/functions/clearAfterInputToken.js
Normal 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;
|
@ -18,6 +18,7 @@
|
||||
//
|
||||
|
||||
exports.addFormElementsNumber = require('./addFormElementsNumber');
|
||||
exports.clearAfterInputToken = require('./clearAfterInputToken');
|
||||
exports.clearFormElementsNumber = require('./clearFormElementsNumber');
|
||||
exports.clickSubmit = require('./clickSubmit');
|
||||
exports.closeNotificationInfo = require('./closeNotificationInfo');
|
||||
|
@ -21,6 +21,7 @@
|
||||
const delay = require('../../partials/delay');
|
||||
const getTabData = require('./getTabData');
|
||||
const clickSubmit = require('./clickSubmit');
|
||||
const clearAfterInputToken = require('./clearAfterInputToken');
|
||||
|
||||
const inputToken = (request, inputElement, siteURL) => {
|
||||
return new Promise(resolve => {
|
||||
@ -81,6 +82,8 @@ const inputToken = (request, inputElement, siteURL) => {
|
||||
clickSubmit(inputElement, siteURL);
|
||||
}
|
||||
|
||||
clearAfterInputToken(inputElement, tab.id);
|
||||
|
||||
return resolve({
|
||||
status: 'completed',
|
||||
url: siteURL
|
||||
|
Loading…
Reference in New Issue
Block a user