Kittens Game AutoPlay Loader

Add-on for the wonderful incremental browser game: https://kittensgame.com/web/

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        Kittens Game AutoPlay Loader
// @namespace   E4gle
// @description Add-on for the wonderful incremental browser game: https://kittensgame.com/web/
// @icon        https://kitten-science.com/assets/images/organization-logo64.png
// @match       https://kittensgame.com/web/
// @match       https://kittensgame.com/beta/
// @match       https://kittensgame.com/alpha/
// @version      1.0
// @grant       none
// @license MIT
// ==/UserScript==
(function () {
  'use strict';

  const SCRIPT_URL = 'https://dandcvs.github.io/KGAutoPlay/kitg.js';
  const FLAG = '__KG_AUTOPLAY_LOADED__';

  if (window[FLAG]) {
    console.log('[KG AutoPlay] already loaded');
    return;
  }

  let tries = 0;
  const maxTries = 60; // ~30 Sekunden

  const waitForGame = setInterval(() => {
    tries++;

    if (window.gamePage && document.readyState === 'complete') {
      clearInterval(waitForGame);

      const script = document.createElement('script');
      script.src = SCRIPT_URL;
      script.onload = () => {
        window[FLAG] = true;
        console.log('[KG AutoPlay] successfully loaded');
      };

      document.body.appendChild(script);
    }

    if (tries >= maxTries) {
      clearInterval(waitForGame);
      console.warn('[KG AutoPlay] Kittens Game not detected');
    }
  }, 500);
})();