pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.17k stars 3.62k forks source link

fix: change the logic of wweb version retrieving #3299

Open alechkos opened 19 hours ago

alechkos commented 19 hours ago

PR Details

The PR fixes an issue where the WhatsApp Web version is stuck on v2.2413.51 in #2616 and does not automatically update the version in Constants.js, README.md and .version.

How Has This Been Tested

const fetch = require('node-fetch');

async function main() {
    let response = await fetch('https://web.whatsapp.com/', {
        headers: {
            'user-agent':
                'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
            'accept-language': 'en-US,en;q=1',
            'sec-fetch-mode': 'navigate',
            'cache-control': 'no-cache',
            cookie: 'wa_lang_pref=en;wa_build=c',
            pragma: 'no-cache',
        },
    });

    let text = await response.text();

    if (text) {
        const matches = text.match(/"client_revision"\s*:\s*(\d+)/) || [];

        if (matches[1]) {
            return `2.3000.${matches[1]}`;
        }
    }

    return null;
}

main().then((r) => console.log(r));

Types of changes

Checklist