How to populate a text field on a webpage with a chrome extension?

it’s good @m_hutley I solved the problem thank you Very much on the other hand I always block to make the condition IF and I hope that you help me please

I… dont understand?

I want to make the condition if in the popup.js function to show a message if the user does not type the correct code this is the only thing that is blocking me now.

switch(request.functionnum) {
  case "1":
    ....
  break;
  case "2":
    ....
   break;
   default:
      alert(stuff);
 }

excuse me @m_hutley because it’s really too complicated for me, I did like

chrome.runtime.onMessage.addListener(
  switch(request.functionnum) {
  case "1":
	let functions = {
	1: function () { document.getElementsByName('q')[0].value = 'test'; },
	2: function () { alert(2); },
	3: function () { alert(3); },
	4: function () { alert(4); },
	5: function () { alert(5); },
	6: function () { alert(6); },
	break;
   default:
      alert(stuff);
 }
	functions[request.functionnum]();
});

that but it doesn’t work

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.