I'm trying my hand at a simple Chrome Extension, but I've hit a snag.
I'm trying to autofill a login form (username and password). (As backup in case the chrome autofill functionality is disabled)
I've managed to inject a script into the page and I can console.log the input I'm targeting. But it won't set the value.
Manifest.json
{
"manifest_version": 2,
"name": "Test Extension",
"description": "Test Extension",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "index.html"
},
"content_scripts": [
{
"matches": [ "*://*.domain.net/*" ],
"js": [ "autofill.js" ]
}
],
"permissions": [
"tabs",
"*://*.domain.net/*"
]
}
autofill.js
console.log( "Script properly injected into page" );
let usernameInput = document.querySelector( 'input[name="username"]' );
let passwordInput = document.querySelector( 'input[name="password"]' );
console.log( usernameInput );
usernameInput.value = "test";
What am I missing here?