Код для автоматизации фарма подписок HeyGen

Код для автоматизации фарма подписок HeyGen

-

(async function bruteHeyGenPromoEnterFastBeep() {

  'use strict';


  const PREFIX = 'HP3FREE-T';

  const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

  const DELAY_MS = 3000; // 3 секунды между попытками


  // Тихий пик

  function playBeep() {

    try {

      const audioCtx = new (window.AudioContext || window.webkitAudioContext)();

      const oscillator = audioCtx.createOscillator();

      const gainNode = audioCtx.createGain();

      oscillator.connect(gainNode);

      gainNode.connect(audioCtx.destination);

      oscillator.frequency.value = 800;

      oscillator.type = 'sine'; // мягкий тон

      gainNode.gain.value = 0.2; // тихая громкость

      oscillator.start();

      setTimeout(() => {

        oscillator.stop();

        audioCtx.close();

      }, 200);

    } catch (e) {

      console.log('Не удалось издать звук, но код найден!');

    }

  }


  const getPromoInput = () => {

    const inputs = document.querySelectorAll('input');

    for (let inp of inputs) {

      if (inp.placeholder && /promo|код|code/i.test(inp.placeholder)) return inp;

    }

    return document.querySelector('input[name="promo"], input[id*="promo"], input[data-testid="promoCode"]');

  };


  function generateCode() {

    let suffix = '';

    for (let i = 0; i < 4; i++) suffix += CHARS[Math.floor(Math.random() * CHARS.length)];

    return PREFIX + suffix;

  }


  function checkSuccess() {

    const error = document.querySelector('.Error, .invalid-feedback, [data-testid="promoCodeError"]');

    if (error && error.textContent.trim()) return false;

    const success = document.querySelector('.Success, .valid-feedback, [data-testid="promoCodeSuccess"]');

    if (success && success.textContent.trim()) return true;

    const totalEl = document.querySelector('[data-testid="total-amount"], .total-amount, [class*="total"]');

    if (totalEl && window.__originalTotal && totalEl.textContent !== window.__originalTotal) return true;

    return null;

  }


  const totalElement = document.querySelector('[data-testid="total-amount"], .total-amount, [class*="total"]');

  if (totalElement) window.__originalTotal = totalElement.textContent;


  let attempt = 0;

  while (true) {

    const code = generateCode();

    attempt++;

    console.log(`[${attempt}] Пробуем: ${code}`);


    const input = getPromoInput();

    if (!input) {

      console.error('Поле ввода промокода не найдено. Обнови страницу.');

      break;

    }


    input.focus();

    input.select();

    document.execCommand('selectAll', false, null);

    document.execCommand('insertText', false, code);


    await new Promise(r => setTimeout(r, 150));

    input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', keyCode: 13, which: 13, bubbles: true }));

    await new Promise(r => setTimeout(r, 50));

    input.dispatchEvent(new KeyboardEvent('keyup', { key: 'Enter', keyCode: 13, which: 13, bubbles: true }));


    let success = null;

    for (let i = 0; i < 10; i++) { // ждём до 10 секунд

      await new Promise(r => setTimeout(r, 1000));

      const result = checkSuccess();

      if (result === true) {

        success = true;

        break;

      } else if (result === false) {

        success = false;

        break;

      }

    }


    if (success === true) {

      playBeep(); // тихий пик

      console.log('%c ВАЛИДНЫЙ КОД: ' + code + ' ', 'background: green; color: white; font-size: 24px;');

      alert('КОД: ' + code);

      localStorage.setItem('heygen_promo_code', code);

      break;

    } else {

      input.select();

      document.execCommand('delete');

      await new Promise(r => setTimeout(r, DELAY_MS));

    }

  }

})();

Report Page