How to make GET requests to multiple links at the same time and obtain the values ​of the returned results in sequence for conditional judgment?

Make requests for multiple links at the same time, and conditionally judge the value of the first returned result.

If the conditions are met, the values ​​of subsequent request results will not be obtained.

If they are not met, the values ​​of the second and third returned results will be obtained in sequence.

Perform conditional judgment. If the conditions are met, the subsequent values ​​will not be obtained. If the conditions are not met, the subsequent values ​​will also be obtained.

I wrote a piece of code using AI. Looking at the comments and actual results, it seems that it first obtains a request result, performs judgment, and then waits for all remaining result requests to be completed, and then performs conditional judgment.

It does not wait for the requested results to be obtained in sequence and then perform conditions.

Promise.all() will wait for all the results then do the judgment, and I think I should not use it.

    const promises = [];
    // List of links to request
    var urlavl = 'https://www.aaa.com'; 
    var urlero = 'https://www.bbb.com';
    var urlkuti = 'https://www.ccc.com';

    var urls = [urlwiki,urlero,urlkuti]; 
    // Traverse the linked list, initiate a request and store Promise and corresponding conditions
    urls.forEach((url) => {
        promises.push(new Promise((resolve, reject) => {
            GM_xmlhttpRequest({
                method: "GET",
                url: url,
                onload: function(response) {
                    let domNew = new DOMParser().parseFromString(response.responseText, 'text/html');
                    resolve(domNew);
                },
                onerror: function(error) {
                    resolve('ERROR' + url); 
                }
            });
        }));
    });
    Promise.race(promises)
        .then((data) => {
        // Determine whether the first completed request meets the corresponding conditions
        if(data.indexOf('#') > -1) {
            console.log(data);
            
            // Cancel other outstanding requests
            promises.forEach(promise => {
                if (promise.cancel) {
                    promise.cancel();
                }
            });
        } else {
            // console.log(`The link does not meet the conditions, waiting for other results...`);

            // Promise.all() Wait for all requests to complete
            Promise.all(promises)
                .then(results => {
                // Traverse all results and find results that meet the corresponding conditions
                console.log('Search again')
                results.forEach((data) => {
                    if(data.indexOf('#') > -1) {
                        console.log(data);
                    // console.log(`The link meets the conditions:`, response);
                    }
                });
            })
                .catch(error => {
                console.error("ERROR:", error);
            });
        }
    })
        .catch(error => {
        console.error("ERROR:", error);
    });