mirror of
https://github.com/twofas/2fas-browser-extension.git
synced 2024-11-26 04:00:09 +01:00
#1501 getInputs - FIX for URL change (hey.com)
This commit is contained in:
parent
ce0c2e1846
commit
1aab30e921
@ -24,6 +24,7 @@ const { getTabData, getInputs, addInputListener, portSetup, isInFrame, addFormEl
|
||||
const contentOnMessage = require('./events/contentOnMessage');
|
||||
const { loadFromLocalStorage, saveToLocalStorage } = require('../localStorage');
|
||||
const storeLog = require('../partials/storeLog');
|
||||
const delay = require('../partials/delay');
|
||||
|
||||
let tabData;
|
||||
let storage;
|
||||
@ -36,7 +37,19 @@ const contentScriptRun = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
tabData = await getTabData();
|
||||
let tabAttempt = 0;
|
||||
|
||||
do {
|
||||
tabData = await getTabData();
|
||||
|
||||
if (tabData?.status === 'complete') {
|
||||
break;
|
||||
}
|
||||
|
||||
tabAttempt++;
|
||||
await delay(() => {}, 200);
|
||||
}
|
||||
while (tabAttempt < 10)
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
|
@ -17,33 +17,14 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
//
|
||||
|
||||
const { loadFromLocalStorage, saveToLocalStorage } = require('../../localStorage');
|
||||
const storeLog = require('../../partials/storeLog');
|
||||
const addInputListener = require('../functions/addInputListener');
|
||||
const getInputs = require('../functions/getInputs');
|
||||
const addFormElementsNumber = require('../functions/addFormElementsNumber');
|
||||
const getFormElements = require('../functions/getFormElements');
|
||||
|
||||
const pageLoadComplete = async tabID => {
|
||||
let storage;
|
||||
const activeElement = document?.activeElement;
|
||||
|
||||
if (!activeElement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const twofasInput = activeElement.getAttribute('data-twofas-input');
|
||||
|
||||
if (!twofasInput) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
storage = await loadFromLocalStorage([`tabData-${tabID}`, 'extensionID']);
|
||||
} catch (err) {
|
||||
await storeLog('error', 43, err, storage[`tabData-${tabID}`]?.url);
|
||||
}
|
||||
|
||||
storage[`tabData-${tabID}`].lastFocusedInput = twofasInput;
|
||||
|
||||
return saveToLocalStorage({ [`tabData-${tabID}`]: storage[`tabData-${tabID}`] })
|
||||
.catch(err => storeLog('error', 44, err, storage[`tabData-${tabID}`]?.url));
|
||||
addInputListener(getInputs(), tabID);
|
||||
addFormElementsNumber(getFormElements());
|
||||
};
|
||||
|
||||
module.exports = pageLoadComplete;
|
||||
|
@ -23,6 +23,7 @@ const notObservedAttributes = [
|
||||
'data-twofas-input-listener',
|
||||
// CUSTOM
|
||||
'data-ng-animate',
|
||||
'data-submitting',
|
||||
// GLOBAL ATTRIBUTES
|
||||
'href',
|
||||
'acceskey',
|
||||
|
Loading…
Reference in New Issue
Block a user