with interceptBufferProtocol deprecated, how would I utilize protocol.handle to intercept http & https?

Within my electron application, I was wanting to create a captcha harvester pop up window and I came across a git repo, specifically this https://github.com/sashapisdets/Captcha-Solver and fresh after the clone, it works fine, but the problem is, it utilizes an extremely old version of Electron while my personal application utilizes the latest. A main core function within the harvester is that it intercepts the http protocol and has a callback to display an html, but with the new version of electron, interceptBufferProtocol is deprecated and got replaced with .handle, but no matter what I do, I can’t seem to get it to intercept the http protocol using protocol.handle, does anyone have any ideas on how I’d go about updating it?

Original Function

function SetupIntercept() {
    protocol.interceptBufferProtocol('http', (req, callback) => {
        if(req.url == 'https://www.google.com/recaptcha/api2/demo') {
            fs.readFile(__dirname + '/captcha.html', 'utf8', function(err, html){
                callback({mimeType: 'text/html', data: Buffer.from(html)});
            });
        }else{
            const request = net.request(req)
            request.on('response', res => {
                const chunks = []
    
                res.on('data', chunk => {
                    chunks.push(Buffer.from(chunk))
                })
    
                res.on('end', async () => {
                    const file = Buffer.concat(chunks)
                    callback(file)
                })
            })
    
            if (req.uploadData) {
                req.uploadData.forEach(part => {
                    if (part.bytes) {
                        request.write(part.bytes)
                    } else if (part.file) {
                        request.write(readFileSync(part.file))
                    }
                })
            }
    
            request.end()
        }
    })
};

Updated Function

function SetupIntercept() {
    protocol.handle('http', async (req) => {
        if (req.url === 'http://supremenewyork.com/') {
            try {
                const html = await fs.promises.readFile(__dirname + '/captcha.html', 'utf8');
                return {
                    mimeType: 'text/html',
                    data: Buffer.from(html),
                };
            } catch (err) {
                console.error('Error reading captcha.html:', err);
                return {
                    mimeType: 'text/plain',
                    data: Buffer.from('Error loading page'),
                };
            }
        } else {
            return new Promise((resolve, reject) => {
                const request = net.request(req);
                request.on('response', (res) => {
                    const chunks = [];
        
                    res.on('data', (chunk) => {
                    chunks.push(Buffer.from(chunk));
                    });
        
                    res.on('end', () => {
                    const file = Buffer.concat(chunks);
                    resolve({ data: file });
                    });
        
                    res.on('error', (error) => {
                    console.error('Error in response:', error);
                    reject({
                        mimeType: 'text/plain',
                        data: Buffer.from('Error loading page'),
                    });
                    });
                });
        
                if (req.uploadData) {
                    req.uploadData.forEach((part) => {
                    if (part.bytes) {
                        request.write(part.bytes);
                    } else if (part.file) {
                        request.write(readFileSync(part.file));
                    }
                    });
                }
        
                request.end();
            });
        }
    });
}