Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change the logic of wweb version retrieving #3299

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

alechkos
Copy link
Collaborator

@alechkos alechkos commented Sep 28, 2024

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

Tested on a private repository created specially for this:

The update-version (click to expand)

#!/usr/bin/env node

const puppeteer = require('puppeteer');
const args = [
    '--autoplay-policy=user-gesture-required',
    '--disable-background-networking',
    '--disable-background-timer-throttling',
    '--disable-backgrounding-occluded-windows',
    '--disable-breakpad',
    '--disable-client-side-phishing-detection',
    '--disable-component-update',
    '--disable-default-apps',
    '--disable-dev-shm-usage',
    '--disable-domain-reliability',
    '--disable-extensions',
    '--disable-features=AudioServiceOutOfProcess',
    '--disable-hang-monitor',
    '--disable-ipc-flooding-protection',
    '--disable-notifications',
    '--disable-offer-store-unmasked-wallet-cards',
    '--disable-popup-blocking',
    '--disable-print-preview',
    '--disable-prompt-on-repost',
    '--disable-renderer-backgrounding',
    '--disable-speech-api',
    '--disable-sync',
    '--disable-gpu',
    '--disable-accelerated-2d-canvas',
    '--hide-scrollbars',
    '--ignore-gpu-blacklist',
    '--metrics-recording-only',
    '--mute-audio',
    '--no-default-browser-check',
    '--no-first-run',
    '--no-pings',
    '--no-zygote',
    '--password-store=basic',
    '--use-gl=swiftshader',
    '--use-mock-keychain',
    '--disable-setuid-sandbox',
    '--no-sandbox',
    '--disable-blink-features=AutomationControlled',
    '--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'
];

const getWWebVersion = async () => {
    const browser = await puppeteer.launch({
        args: args
    });
    const page = await browser.newPage();
    await page.goto('https://web.whatsapp.com', {
        waitUntil: 'load',
        timeout: 0,
        referer: 'https://whatsapp.com/',
    });

    await page.waitForFunction(() => window.require && window.require('WAWebBuildConstants'));

    const versionString = await page.evaluate(() => {
        return window.require('WAWebBuildConstants').VERSION_STR;
    });

    await browser.close();
    return versionString;
};

(async () => {
    console.log(`Current version: ${await getWWebVersion()}`);
})();

The update.yml workflow (click to expand)

name: Update

on:
  workflow_dispatch:

jobs:
  update:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: .

    steps:
      - uses: actions/checkout@v2
      - name: Install node v16
        uses: actions/setup-node@v2
        with:
          node-version: '16'
      - name: Install dependencies
        run: npm install
      - name: Make update-version executable
        run: chmod +x ./update-version
      - name: Run Updater
        run: ./update-version

The output (click to expand)

Types of changes

  • Dependency change
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • I have updated the documentation accordingly (index.d.ts).

@alechkos
Copy link
Collaborator Author

alechkos commented Oct 4, 2024

Tested and works as expected, all the info in the PR description.

@alechkos alechkos requested a review from pedroslopez October 4, 2024 04:02
@pedroslopez pedroslopez merged commit 17d63a5 into pedroslopez:main Oct 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants