refillNewFields function
Last updated: 2026-03-04T23:21:38.393Z
Location
Metrics
LOC: 38
Complexity: 4
Params: 1
Signature
refillNewFields(previousSignature: string): : Promise<void>
Summary
Re-fills only the new fields that appeared after a DOM change. Compares the previous signature against current fields to identify which fields are new and fills only those.
Source Code
async function refillNewFields(previousSignature: string): Promise<void> {
isFillingInProgress = true;
try {
const oldKeys = parseSignature(previousSignature);
const { fields } = await detectAllFieldsAsync();
const newFields = fields.filter((f) => {
const key = `${f.selector}:${f.fieldType}`;
return !oldKeys.has(key);
});
if (newFields.length === 0) {
log.debug("No truly new fields to fill");
return;
}
const url = window.location.href;
const ignoredFields = await getIgnoredFieldsForUrl(url);
const ignoredSelectors = new Set(ignoredFields.map((f) => f.selector));
const fieldsToFill = newFields.filter(
(f) => !ignoredSelectors.has(f.selector),
);
if (fieldsToFill.length === 0) {
log.debug("Todos os novos campos são ignorados — skip");
return;
}
log.info(`Filling ${fieldsToFill.length} new field(s) only`);
for (const field of fieldsToFill) {
await fillSingleField(field);
}
lastFieldSignature = getCurrentFieldSignature();
} finally {
isFillingInProgress = false;
}
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| parseSignature | calls |
| detectAllFieldsAsync | calls |
| fillSingleField | calls |
| getCurrentFieldSignature | calls |
Impact (Incoming)
| Source | Type |
|---|---|
| handleMutations | calls |