#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 contentOnMessage = require('./events/contentOnMessage');
const { loadFromLocalStorage, saveToLocalStorage } = require('../localStorage'); const { loadFromLocalStorage, saveToLocalStorage } = require('../localStorage');
const storeLog = require('../partials/storeLog'); const storeLog = require('../partials/storeLog');
const delay = require('../partials/delay');
let tabData; let tabData;
let storage; let storage;
@ -36,7 +37,19 @@ const contentScriptRun = async () => {
} }
try { 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) { } catch (e) {
throw new Error(e); throw new Error(e);
} }

View File

@ -17,33 +17,14 @@
// along with this program. If not, see <https://www.gnu.org/licenses/> // along with this program. If not, see <https://www.gnu.org/licenses/>
// //
const { loadFromLocalStorage, saveToLocalStorage } = require('../../localStorage'); const addInputListener = require('../functions/addInputListener');
const storeLog = require('../../partials/storeLog'); const getInputs = require('../functions/getInputs');
const addFormElementsNumber = require('../functions/addFormElementsNumber');
const getFormElements = require('../functions/getFormElements');
const pageLoadComplete = async tabID => { const pageLoadComplete = async tabID => {
let storage; addInputListener(getInputs(), tabID);
const activeElement = document?.activeElement; addFormElementsNumber(getFormElements());
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));
}; };
module.exports = pageLoadComplete; module.exports = pageLoadComplete;

View File

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