populateField(inputId, inputValue) {// other code here but I console.log and logic gets to the below command// I also wrapped in try catch and no error logged$(inputId).val(inputValue);}populateField("#\\32 63val-field_1\\.3\\.7--input", "test");When I call the populateField() within the content script it's not updating the value of the input field, however, if I try the code below in the Chrome console, it works fine and assigns the value in the input field.$( "#\\32 63val-field_1\\.3\\.7--input" ).val("test");The HTML has the input field ID as "263val-field_1.3.7--input".Please note that other JQuery commands work within the content script.I have of course JQuery loaded in manifest.json using the "content_scripts". Also, I am trying to test this on a page where the content script is loaded (based on "matches").1. Any ideas why it might not be working or what am I missing?2. Can someone explain what the "\\3" part means (got the whole query selector from copy JS path with Chrome)?Thank you for the help.
I tried the setInterval() and setTimeout() and don't work in the content script, but work in chrome console. I cannot get MutationObserver to work because it needs a node, and guess what?, it's not finding the node of one of the input fields that I'm trying to populate.I'm trying to populate Zendesk input fields on a new ticket. I thought maybe it's using frames, so I specified "all_frames": true under "content_scripts" in manifest.json. No difference.It's strange because in the content script I have the below and they work. The first fills in an email address fine, and the second clicks the "take it" link.$("div.ember-view.form_field.requester.agent.requester_id > div.zd-searchmenu.zd-searchmenu-root > input").val("exa...@example.com");$("[id^=ember] > div.LRbr > button").click();But the input fields aren't being populated (probably because they are not found / undefined), yet the same code works in the chrome console.If these input fields are dynamically created, shouldn't the content script have access to them when I can see the input fields on the page?Any ideas on how to fix this?Thank you.On Friday, September 24, 2021 at 7:17:14 AM UTC-6 Lawrence wrote:Hi, thank you for your reply. I agree it's probably created dynamically. The content script is fully loaded. I can visually see the input fields displayed (this is actually for a Zendesk ticket). I manually activate when to populate the input fields via pressing a button from the popup script (which is after I can see the input fields on the form/page). So, I don't think that's it but of course, I'm willing to give MutationObserver a try. Thank you for #2 answer too, that makes sense.
Yes, I'm always reloading the extension and refreshing pages that I'm testing this on. The content script may run once but it waits until it's triggered by my extension popup. I click a button from the extension popup (and send message) to initiate in the content script to try to populate the fields. Yes, I have the correct current tab and I can only get two fields to work so far (the ones already mentioned)Thanks about the match_about_blank. It is using frames, so I added that to manifest.json, but it didn't make any difference. I'm not sure why you have me try those three statements in the console since the JQuery already works in the content script.The focus and insertText I tried in the console and don't work unless I first manually click and put the cursor in the input box. The MouseEvent line/command works but as mentioned, the JQuery works already within the content script.How does it help to observe from the body element? I have not tried this yet. I did within the content script $("input field query in here").get(0) to try and return the nodes of the input fields I'm interested in and checked if they're an instanceOf Node and all came back false. So these dynamic or input fields are not being seen by the content script which means I cannot populate them?
Sorry, no, this is for Zendesk (ZD) ticketing system for businesses. One needs to have an account. A business can create custom input fields per their needs.Main site (free trial available):Support site:Every time a new ticket is created, ZD changes the value of the HTML ID's. The HTML ID's don't stay the same from new ticket to ticket. I'm having to grab all the labels, checking for the ones I want (e.g. first name, last name, phone, etc.) in order to know the HTML ID of its associated input ID. That's working fine (I'm logging to console log to confirm). So, I'm confused why the content script can access/query the labels, but not find or populate the input fields. I take the code to query and populate input fields from the content script and run it in the console and it works fine.Example: ZD label ID for a phone field could be "263val-field_1.3.7--label" when a new ticket is created and its corresponding input field would be "263val-field_1.3.7--input". The next time you create a new ticket the phone field ID label number could be anything like "186val-field_1.3.7--label" and its corresponding input field would be "186val-field_1.3.7--input".Yes, ZD uses its own JQuery too (v2.4+). I'm loading a newer version 3.6+ in the content script.
Thank you for the help.