Generals.io Add warning

Plays a sound that warns you about Add

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Generals.io Add warning
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Plays a sound that warns you about Add
// @author       z33r0x
// @match        *://generals.io/*
// @icon         https://generals.io/favicon/favicon-32x32.png
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Variables

    var WarningSound = new Audio('https://raw.githubusercontent.com/RunDTM/scripts/main/kick-short-boomy.wav')
    var TheSound = new Audio('https://raw.githubusercontent.com/RunDTM/scripts/main/kick-warm-boomy.wav')

    WarningSound.loop = false
    TheSound.loop = false

    // Functions

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

    function GetTurnCounter() {
        var TurnCounter = document.getElementById('turn-counter')

        if (!TurnCounter) return

        return Number(TurnCounter.textContent.split(' ')[1].split('.')[0])
    }

    function PlaySound(sound) {
        if (!sound.paused) {
            sound.pause()
            sound.currentTime = 0
        }

        sound.play()
    }

    async function Main() {
        var PreviousTurns

        while (true) {

            var Turns = GetTurnCounter()

            if (Turns != PreviousTurns && Turns) {
                PreviousTurns = Turns

                for (let i = 1; i <= 4; i++) {
                    var New = (Turns + i) / 25

                    if (Math.floor(New) == New) {
                        PlaySound(WarningSound)
                    }
                }

                var NewX = Turns / 25
                if (Math.floor(NewX) == NewX || (Turns == 10 || Turns == 15)) {
                    PlaySound(TheSound)
                }
            }

            await sleep(10)
        }
    }

    // Main

    Main()
})();