How to call JS functions from a text field with chrome extension?

I’m creating my first chrome extension and I’m having trouble calling JS functions from a text field, but it doesn’t work if you have any suggestions please and thank you, here are the codes I have for the moment :slight_smile:

**manifest.json** ---------------- { "name": "Zero ■■■■■■", "version": "1.0", "manifest_version": 3, "description": "Auto fill form GRC", "icons": { "16": "icon/icon.png", "48": "icon/icon.png", "128": "icon/icon.png" }, "action": { "default_popup": "index.html", "default_icon": "icon/icon.png" }, "options_page": "options.html", "content_scripts": [ { "matches" : [ "http://*/*", "https://*/*" ], "js": ["jquery-3.6.0.min.js", "injector.js"] } ], "permissions": [ "clipboardWrite", "activeTab", "notifications", "contextMenus", "storage", "scripting", "tabs" ] }

index.html

<!doctype html> <html> <head> <style> body { min-width: 120px; overflow-x: hidden; font-family: Arial, sans-serif; font-size: 12px; } input, textarea { width: 140px; } input#save { font-weight: bold; width: auto; } </style> </head> <body> <h1>GRC</h1> <center><form> <div> <label><b>Veuillez saisir un code</b></label> <input name="inpt" id="inpt" autocomplete="off"/> <p> <button id="btn">Enter</button> <script src="popup.js"></script> </p> </div> </form></center> </body> </html>

popup.js

const button = document.getElementById('btn'); const input = document.getElementById('inpt'); button.onclick = async evt => { const [tab] = await chrome.tabs.query({ active: true, currentWindow: true }); await chrome.scripting.executeScript({ target: { tabId: tab.id }, files: ['injector.js'], }); await chrome.scripting.executeScript({ target: { tabId: tab.id }, func: inPage, args: [input.value], }); window.close(); }; function inPage(index) { functions[index](); }

injector.js

functions = { 1 : function(){alert(1);}, 2 : function(){alert(2);}, 3 : function(){alert(3);}, 4 : function(){alert(4);}, 5 : function(){alert(5);}, 6 : function(){alert(6);}, } function(f){ functions[f](); }