I have a CSV file of users (with email and name). Google Chrome stores its autofill data and you can add them manually here: chrome://settings/addresses
Is it possible to import the data automatically from the file?
The settings UI uses an internal API chrome.autofillPrivate.saveAddress
(source).
chrome://settings/addresses
for (const el of document.querySelectorAll('body > input'))
el.remove();
Object.assign(document.body.appendChild(document.createElement('input')), {
type: 'file',
style: 'position:absolute; top:2ex; right:0; z-index:999',
onchange(e) {
if (!this.files[0])
return;
const fr = new FileReader();
fr.readAsText(this.files[0], 'UTF-8');
fr.onload = () => {
for (const line of fr.result.split(/\r?\n/)) {
const [name, email] = line.split(',');
chrome.autofillPrivate.saveAddress({
emailAddresses: [email],
fullNames: [name],
});
}
};
fr.onerror = console.error;
},
});