Chrome addon/extension. 1. Fill fields input[type="text"]
Table of contents
Here’s a fresh Chrome extension that aggressively fills all input fields, selects, and radio buttons on a webpage with predefined values.
1. manifest.json
{
"manifest_version": 3,
"name": "AutoFill Fields",
"version": "1.0",
"permissions": [
"tabs",
"activeTab",
"scripting"
],
"background": {
"service_worker": "background.js"
},
"action": {},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["contentScript.js"],
"run_at": "document_start"
}
]
}
2. background.js
console.log("Background service worker started");
chrome.action.onClicked.addListener((tab) => {
console.log("Addon activated, injecting content script...");
chrome.scripting.executeScript({
target: {tabId: tab.id},
files: ['contentScript.js']
});
});
3. contentScript.js
(function () {
console.log("AutoFill Addon started");
// Value to fill in text inputs
const fillValue = "filled";
// Fill ONLY text input fields
document.querySelectorAll('input[type="text"]').forEach(input => {
input.value = fillValue;
input.dispatchEvent(new Event('input', { bubbles: true }));
input.dispatchEvent(new Event('change', { bubbles: true }));
console.log(`Filled text input: ${input.name || input.id || 'unknown'} with "${fillValue}"`);
});
})();
How It Works:
- Fills all input[type="text"] fields are filled .
- Automatically triggers change and input events.