Wall Barb

Hotkeyy

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Wall Barb
// @version      3
// @description  Hotkeyy
// @include      https://*/game.php*screen=place*
// @namespace https://greasyfork.org/users/1388863
// ==/UserScript==

(function() {
    'use strict';

    // Tambahkan event listener untuk mendeteksi tombol keyboard yang ditekan
    document.addEventListener('keydown', function(event) {
        // Periksa apakah tombol yang ditekan adalah "."
        if (event.key === ".") {
            // Pilih elemen <a> di dalam baris tabel dengan kelas "row_a"
            const element = document.querySelector('tr.row_a td a.troop_template_selector');

            if (element) {
                element.click(); // Memicu klik pada elemen tersebut
                console.log('Element clicked successfully!');
            } else {
                console.error('Element not found!');
            }
        }

        // Periksa apakah tombol yang ditekan adalah "Enter"
        if (event.key === "Enter") {
            // Pilih elemen pertama yang cocok dari dua elemen target
            const attackButton = document.querySelector('#target_attack');
            const confirmButton = document.querySelector('#troop_confirm_submit');

            if (attackButton) {
                attackButton.click(); // Klik tombol "Attack"
                console.log('Attack button clicked!');
            } else if (confirmButton) {
                confirmButton.click(); // Klik tombol "Send attack"
                console.log('Confirm button clicked!');
            } else {
                console.error('No target button found!');
            }
        }
    });
})();