Devast io autorun

Devast.io auto run

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Devast io autorun
// @namespace    http://tampermonkey.net/
// @version      2024-09-26
// @description  Devast.io auto run
// @author       You
// @match        https://devast.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=devast.io
// @grant        none
// ==/UserScript==

// Створюємо контейнер для GUI
var guiContainer = document.createElement('div');
guiContainer.style.position = 'fixed';
guiContainer.style.top = '10px';
guiContainer.style.right = '10px';
guiContainer.style.padding = '10px';
guiContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
guiContainer.style.color = 'white';
guiContainer.style.borderRadius = '5px';
guiContainer.style.zIndex = '1000';
guiContainer.style.fontFamily = 'Arial, sans-serif';

// Додаємо заголовок "Autorun"
var guiTitle = document.createElement('h2');
guiTitle.innerText = 'Autorun press "L" ';
guiTitle.style.margin = '0';
guiTitle.style.paddingBottom = '10px';
guiTitle.style.fontSize = '16px';
guiTitle.style.borderBottom = '1px solid white';

// Додаємо кнопку "Auto shift"
var shiftButton = document.createElement('button');
shiftButton.innerText = 'Auto shift';
shiftButton.style.padding = '5px 10px';
shiftButton.style.fontSize = '14px';
shiftButton.style.cursor = 'pointer';
shiftButton.style.backgroundColor = '#007bff';
shiftButton.style.color = 'white';
shiftButton.style.border = 'none';
shiftButton.style.borderRadius = '3px';
shiftButton.style.marginTop = '10px';

// Змінна для відстеження стану авто-шифта
var autoShiftActive = false;

// Додаємо обробник події для кнопки "Auto shift"
shiftButton.onclick = function() {
    toggleAutoShift();
};

// Функція для перемикання авто-шифта
function toggleAutoShift() {
    autoShiftActive = !autoShiftActive; // Перемикаємо стан авто-шифта

    if (autoShiftActive) {
        shiftButton.innerText = 'Stop Auto shift'; // Змінюємо текст кнопки
        pressKey(16); // Натискаємо Shift
        // Утримуємо Shift
        document.addEventListener('keydown', holdShift);
    } else {
        shiftButton.innerText = 'Auto shift Press "L"'; // Повертаємо текст кнопки
        releaseKey(16); // Відпускаємо Shift
        document.removeEventListener('keydown', holdShift); // Зупиняємо утримання
    }
}

// Функція для натискання клавіші
function pressKey(keyCode) {
    var event = new KeyboardEvent('keydown', {keyCode: keyCode, which: keyCode, bubbles: true});
    document.dispatchEvent(event);
}

// Функція для відпускання клавіші
function releaseKey(keyCode) {
    var event = new KeyboardEvent('keyup', {keyCode: keyCode, which: keyCode, bubbles: true});
    document.dispatchEvent(event);
}

// Функція для утримання Shift
function holdShift(event) {
    if (event.keyCode === 16) {
        event.preventDefault(); // Запобігаємо стандартній поведінці
    }
}

// Додаємо обробник для гарячої клавіші "L"
document.addEventListener('keydown', function(event) {
    if (event.key.toLowerCase() === 'l') { // Перевіряємо, чи натиснута клавіша "L"
        toggleAutoShift(); // Викликаємо функцію перемикання авто-шифта
    }
});

// Додаємо елементи до контейнера
guiContainer.appendChild(guiTitle);
guiContainer.appendChild(shiftButton);

// Додаємо контейнер GUI до сторінки
document.body.appendChild(guiContainer);