Integrating Web to Lead form in chrome extension popup

SuiteCRM version: 7.13.4

Good evening,

I am trying to develop a google chrome extension from which to submit leads to SuiteCRM.
I seem to be unable to get the form to send the data to the CRM. On the CRM side, I have:
-made a campaign
-created a web to lead form for that campaign

After downloading and putting the form html in my extension’s popup.html (or rather, setting things up so that the form becomes the popup after a configuration stage where the user submits a json file which contains some key information for the form, such as the campaign id, the assigned user id, and the url of the form action (the entry point).
If I just import the form, the submit button isn’t functional (even if I straight up use the downloaded form as the popup).
I tried letting javascript handle the submission with the following code:

   form.addEventListener('submit', function (e) {
        e.preventDefault();
        function submit_form() {
            if (typeof (validateCaptchaAndSubmit) != 'undefined') {
                validateCaptchaAndSubmit();
            } else {
                check_webtolead_fields();
                //document.WebToLeadForm.submit();
            }
        }
        function check_webtolead_fields() {
            if (document.getElementById('bool_id') != null) {
                var reqs = document.getElementById('bool_id').value;
                bools = reqs.substring(0, reqs.lastIndexOf(';'));
                var bool_fields = new Array();
                var bool_fields = bools.split(';');
                nbr_fields = bool_fields.length;
                for (var i = 0; i < nbr_fields; i++) {
                    if (document.getElementById(bool_fields[i]).value == 'on') {
                        document.getElementById(bool_fields[i]).value = 1;
                    } else {
                        document.getElementById(bool_fields[i]).value = 0;
                    }
                }
            }
        }
        submit_form();
        (async function (){
            const formData = new FormData(form);
            const url = (await chrome.storage.local.get(["entrypoint"])).entrypoint;

            fetch(url, {
                method: "POST",
                body: formData  
            })
                .then(response => response.text())
                .then(data => {
                    console.log("Form submitted successfully:", data);
                    
                })
                .catch(error => {
                    console.error("Error submitting form:", error);
                    // Handle any errors that occurred during form submission
                });
        })()

        form.reset();

        
    });

I tried to take the javascript functions in the form html and put them in a .js content script which I put in the form’s body, but that didn’t help. When I click the submit button, the console logs a response, where “data” is HTML code for the crm’s login page (which I think is odd).
Does anyone know how the Web to Lead form handles submission in detail and how I can emulate that behaviour?

If you need any more info feel free to ask