#1501 getInputs - FIX for URL change (hey.com)

This commit is contained in:
GrzegorzZajac000 2024-02-14 11:54:51 +01:00
parent ce0c2e1846
commit 1aab30e921
3 changed files with 21 additions and 26 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -23,6 +23,7 @@ const notObservedAttributes = [
'data-twofas-input-listener',
// CUSTOM
'data-ng-animate',
'data-submitting',
// GLOBAL ATTRIBUTES
'href',
'acceskey',