Giter Site home page Giter Site logo

mudachyo / hamster-kombat Goto Github PK

View Code? Open in Web Editor NEW
118.0 8.0 20.0 2.75 MB

Running Hamster Kombat in your browser | Запуск Hamster Kombat в браузере

JavaScript 100.00%
bot coin farm hamster how-to javascript kombat telegram web windows

hamster-kombat's Introduction

Привет, я mudachyo

🌱 Хотелось бы выжить хотя бы.

hamster-kombat's People

Contributors

mudachyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hamster-kombat's Issues

No need to replace telegram-web-app.js library

// bypass the platform through proxying to open via the telegram web version
if (unsafeWindow && unsafeWindow.Telegram && unsafeWindow.Telegram.WebApp) {
    unsafeWindow.Telegram.WebApp = new Proxy(unsafeWindow.Telegram.WebApp, {
        get(target, prop) {
            // Перехватываем обращение к свойству 'platform'
            if (prop === 'platform') {
                return 'ios';
            }
            // Перехватываем вызовы методов
            if (typeof target[prop] === 'function') {
                return function(...args) {
                    console.log(`Method ${prop} called with arguments:`, args);

                    // Изменяем поведение метода 'exampleMethod'
                    if (prop === 'exampleMethod') {
                        // Модифицируем аргументы или выполняем другие действия
                        args[0] = 'modified argument';
                    }

                    // Вызываем оригинальный метод
                    return target[prop].apply(this, args);
                };
            }

            return target[prop];
        }
    });
}

install https://www.tampermonkey.net/

and add this script

// ==UserScript==
// @name         Hamster kombat clicer prod
// @namespace    http://tampermonkey.net/
// @version      2024-06-09
// @description  ...
// @author       atamg1994
// @include *://hamsterkombat.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=telegram.org
// @resource         sound https://gist.githubusercontent.com/Atamg1994/a050c648388bf5c1ec1d1926452f2f5a/raw/e0c7f1f80f2be4a1c90f8bbbe94a7634844a9cef/sound
// @grant            GM_getResourceText
// ==/UserScript==
//
(function() {
    'use strict';

    /*
     const response = await fetch('https://gist.githubusercontent.com/Atamg1994/a050c648388bf5c1ec1d1926452f2f5a/raw/e0c7f1f80f2be4a1c90f8bbbe94a7634844a9cef/sound');
    const sound = await response.text();


    */
// disable all logs
const customConsole = {
  log: function() {
    // Оставьте эту функцию пустой, чтобы отключить все логи
    // или замените её на оригинальную функцию console.log
    // console.log.apply(console, arguments);
  }
};
// Переназначаем console на нашу обертку
unsafeWindow.console = customConsole;
window.console = customConsole;



// bypass the platform through proxying to open via the telegram web version
if (unsafeWindow && unsafeWindow.Telegram && unsafeWindow.Telegram.WebApp) {
    unsafeWindow.Telegram.WebApp = new Proxy(unsafeWindow.Telegram.WebApp, {
        get(target, prop) {
            // Перехватываем обращение к свойству 'platform'
            if (prop === 'platform') {
                return 'ios';
            }
            // Перехватываем вызовы методов
            if (typeof target[prop] === 'function') {
                return function(...args) {
                    console.log(`Method ${prop} called with arguments:`, args);

                    // Изменяем поведение метода 'exampleMethod'
                    if (prop === 'exampleMethod') {
                        // Модифицируем аргументы или выполняем другие действия
                        args[0] = 'modified argument';
                    }

                    // Вызываем оригинальный метод
                    return target[prop].apply(this, args);
                };
            }

            return target[prop];
        }
    });
}



function dispatchPointerEvent(target, currentTarget, eventType, options) {
  const event = new PointerEvent(eventType, options);

  // Переопределение свойств target и currentTarget, если необходимо
  if (event.target !== target) {
    Object.defineProperty(event, 'target', { value: target });
  }
  if (event.currentTarget !== currentTarget) {
    Object.defineProperty(event, 'currentTarget', { value: currentTarget });
  }
  if (event.srcElement !== target) {
    Object.defineProperty(event, 'srcElement', { value: target });
  }

  currentTarget.dispatchEvent(event);
  console.log(`Dispatched ${eventType} event on element:`, currentTarget);
}


function pointer(element, element1 = false, element2 = false) {
  if (!element1) element1 = element;
  if (!element2) element2 = element;

  // Получаем координаты элемента
  const rect = element.getBoundingClientRect();
  const x = rect.left + (rect.width / 2);
  const y = rect.top + (rect.height / 2);

  // Функция для генерации случайных координат вокруг исходной точки
  function getRandomCoords(baseX, baseY, range) {
    return {
      clientX: baseX + (Math.random() * range * 2 - range),
      clientY: baseY + (Math.random() * range * 2 - range)
    };
  }

  // Функция для генерации случайного угла высоты
  function getRandomAltitudeAngle(minAngle, maxAngle) {
    const minRadians = minAngle * (Math.PI / 180);
    const maxRadians = maxAngle * (Math.PI / 180);
    return minRadians + Math.random() * (maxRadians - minRadians);
  }

  // Функция для генерации случайного значения в заданном диапазоне
  function getRandomInRange(min, max) {
    return min + Math.random() * (max - min);
  }

  // Диапазон случайных отклонений (в пикселях)
  const range = 80;
  const randomCoords = getRandomCoords(x, y, range);

  // Генерация случайного угла высоты между 60 и 90 градусами
  const randomAltitudeAngle = getRandomAltitudeAngle(60, 90);

  // Генерация случайного давления, ширины и высоты
  const randomPressure = getRandomInRange(0.1, 1); // давление от 0.1 до 1
  const randomWidth = getRandomInRange(5, 15); // ширина касания от 5 до 15 пикселей
  const randomHeight = getRandomInRange(5, 15); // высота касания от 5 до 15 пикселей

  const options = {
    bubbles: true,
    cancelable: true,
    clientX: randomCoords.clientX,
    clientY: randomCoords.clientY,
    button: 0,
    buttons: 1, // кнопка нажата
    composed: true,
    pointerId: 1,
    pointerType: 'touch', // Изменено на 'touch' для имитации пальца
    pressure: randomPressure, // давление пальца
    width: randomWidth, // ширина касания
    height: randomHeight, // высота касания
    tiltX: 0,
    tiltY: 0,
    twist: 0,
    altitudeAngle: randomAltitudeAngle,
    azimuthAngle: 0,
    view: unsafeWindow
  };

  const targetElement = element1;
  const currentTargetElement = element2;

  if (targetElement && currentTargetElement) {
    // Создание события pointerdown
    dispatchPointerEvent(targetElement, currentTargetElement, 'pointerdown', options);

    // Генерация случайного смещения для pointermove
    const moveRange = 10; // диапазон смещения
    const moveCoords = getRandomCoords(randomCoords.clientX, randomCoords.clientY, moveRange);

    // Вероятность выполнения смещения (например, 50%)
    const shouldMove = Math.random() > 0.5;

    if (shouldMove) {
      const moveOptions = {
        ...options,
        clientX: moveCoords.clientX,
        clientY: moveCoords.clientY,
      };

      // Создание события pointermove
      dispatchPointerEvent(targetElement, currentTargetElement, 'pointermove', moveOptions);
      console.log('Pointer move event on element:', element, 'to coordinates:', moveCoords);
    }

    // Создание события pointerup
    dispatchPointerEvent(targetElement, currentTargetElement, 'pointerup', options);
    console.log('Pointer event on element:', element, 'at coordinates:', randomCoords, 'with altitudeAngle:', randomAltitudeAngle, 'pressure:', randomPressure, 'width:', randomWidth, 'height:', randomHeight);
  } else {
    console.log('Target or currentTarget element not found');
  }
}


function clickElement(element) {
  // Получаем координаты элемента
  const rect = element.getBoundingClientRect();
  const x = rect.left + (rect.width / 2); // Центр по горизонтали
  const y = rect.top + (rect.height / 2); // Центр по вертикали

  // Создаем событие MouseEvent с координатами
  const event = new MouseEvent('click', {
    view: unsafeWindow,
    bubbles: true,
    cancelable: true,
    clientX: x,
    clientY: y
  });

  // Отправляем событие клика
  element.dispatchEvent(event);
  console.log('Clicked element:', element);
}

// Функция для выполнения тапа по элементу на Android
function tapElement(element) {
  // Получаем координаты элемента
  const rect = element.getBoundingClientRect();
  const x = rect.left + (rect.width / 2); // Центр по горизонтали
  const y = rect.top + (rect.height / 2); // Центр по вертикали

  // Создаем объект Touch с координатами
  const touchObj = new Touch({
    identifier: Date.now(),
    target: element,
    clientX: x,
    clientY: y,
    radiusX: 2.5,
    radiusY: 2.5,
    rotationAngle: 10,
    force: 0.5
  });

  // Создаем события TouchEvent с координатами
  const touchStartEvent = new TouchEvent('touchstart', {
    bubbles: true,
    cancelable: true,
    touches: [touchObj],
    targetTouches: [touchObj],
    changedTouches: [touchObj],
    shiftKey: true
  });

  const touchEndEvent = new TouchEvent('touchend', {
    bubbles: true,
    cancelable: true,
    touches: [],
    targetTouches: [],
    changedTouches: [touchObj],
    shiftKey: true
  });

  // Отправляем события тапа
  element.dispatchEvent(touchStartEvent);
  element.dispatchEvent(touchEndEvent);
  console.log('Tapped element:', element);
}

// Функция для эмуляции ввода текста в contenteditable элемент
function typeText(element, text) {
  const inputEvent = new Event('input', { bubbles: true });
  const changeEvent = new Event('change', { bubbles: true });

  // Сохраняем предыдущее значение
  const lastValue = element.value || element.innerText;

  if (element.hasAttribute('contenteditable')) {
    // Для элементов с contenteditable используем innerText
    element.innerText = text;
  } else {
    // Для обычных input и textarea используем value
    element.value = text;
  }

  // hack React
  const isReactVersion16 = !!element._valueTracker;
  const isReactVersion15 = !!element._valueTracker || !!element._wrapperState;

  if (isReactVersion16 || isReactVersion15) {
    if (isReactVersion15) {
      inputEvent.simulated = true;
      element._wrapperState = { initialValue: lastValue };
    }

    if (isReactVersion16) {
      const tracker = element._valueTracker;
      if (tracker) {
        tracker.setValue(lastValue);
      }
    }
  }

  element.dispatchEvent(inputEvent);
  element.dispatchEvent(changeEvent);

  console.log('Typed text:', text);
}

// Главная функция для старта взаимодействия
function action(selector, method = 'click', text = '') {
  return new Promise((resolve, reject) => {
    const element = document.querySelector(selector);
    if (element) {
      if (method === 'click') {
        clickElement(element);
       resolve('Element found');
      } else if (method === 'tap') {
        tapElement(element);
        resolve('Element found');
      } else if (method === 'pointer') {
        pointer(element);
       resolve('Element found');
      } else if (method === 'type' && text) {
        typeText(element, text);
        resolve('Element found');
      }
    } else {
      console.log('Element not found');
      reject('Element not found');
    }
  });
}

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}




    function playRepeatedAudio(durationInSeconds) {
    const audio = new Audio();
    audio.src = GM_getResourceText("sound");
    audio.volume = 0.15;
    audio.play();
    const intervalx = setInterval(() => {
        audio.currentTime = 0;
        audio.play();
    }, 2000);
    }



function getEnergyValue() {
  const energyElement = document.querySelector('.user-tap-energy p');
  if (energyElement) {
    const energyText = energyElement.innerText;
    const [currentEnergy] = energyText.split(' / ').map(Number);
    return currentEnergy;
  } else {
    return 0; // Возвращаем значение 1000, если элемент не найден
  }
}

function getPriceValue() {
  const priceElement = document.querySelector('.price-value');
  if (priceElement) {
    const priceText = priceElement.innerText;
    const priceValue = parseInt(priceText.replace('+', ''), 10);
    return priceValue;
  } else {
    return 9999; // Возвращаем 0, если элемент не найден
  }
}




var click=true;


// Главная функция для старта
function startInteracting(selector, method = 'pointer', interval = 500) {
  const intervalId = setInterval(async function() {
	 const currentEnergy = getEnergyValue();
    const priceValue = getPriceValue();
      if (click) {
          const element = document.querySelector(selector);
        if (element) {
          await action(selector, method);
        } else {
          console.log('Element not found:', selector);
        }
      }

   let wait_sum = priceValue*100;
      if (currentEnergy < priceValue && click) {
          click=false;
       }else{
           if (currentEnergy < wait_sum && !click) {
               console.log(`Not enough energy to perform the action wait ${wait_sum} `);
            }
        }
      if (currentEnergy > wait_sum && !click) {
               click=true;
           }
    }, interval);
  // Возвращаем функцию для остановки интервала
  return function stopInteracting() {
    clearInterval(intervalId);
    console.log('Stopped interacting');
  };
}
// Главная функция для старта


// Пример использования
setTimeout(()=>{
 const element = document.querySelector('.user-tap-button-circle');
    if (element){
playRepeatedAudio(2);
const stop = startInteracting('.user-tap-button-circle', 'pointer',150);
}
},10000)


})();

Upgrade Issue with “21,000,000 CEOs” Card After Level 7

Hello HamsterKombat Team,

I’ve encountered an issue within the game that I hope can be addressed. After successfully referring a friend, I unlocked the “21,000,000 CEOs” card and began upgrading it. However, upon reaching level 7, I ran into a bug. Instead of displaying the button for further upgrades, the game now shows the message “Вы владеете этой картой” (“You own this card”), and I am unable to proceed with any more upgrades. This seems to be an error since the option to continue upgrading should be available.

Could you please look into this matter and provide a fix? It is hindering my progress in the game, and I would greatly appreciate your assistance.

For reference, my Telegram account is @v3nms.

Thank you for your time and support.

Screenshot_20240524_075554_Telegram

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.