noyarc / Enable Button in WaifuGame

// ==UserScript==
// @name         Enable Button in WaifuGame
// @namespace    http://tampermonkey.net/
// @match        *://waifugame.com/quests/*
// @match        *://waifugame.com/battle/*
// @grant        none
// @version      1.3
// @description  Enables the disabled fight button on quest and battle pages
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to enable the button
    function enableButton() {
        var button = document.querySelector('button.btn.btn-secondary.btn-block.mt-4');
        if (button) {
            button.removeAttribute('disabled');
        }
    }

    // Run the function initially
    enableButton();

    // Listen for popstate event (back/forward navigation)
    window.addEventListener('popstate', function(event) {
        setTimeout(enableButton, 500); // Delay to ensure the DOM is fully loaded
    });

    // Listen for pageshow event (back/forward navigation)
    window.addEventListener('pageshow', function(event) {
        setTimeout(enableButton, 500); // Delay to ensure the DOM is fully loaded
    });

    // Listen for DOMContentLoaded (initial page load)
    document.addEventListener('DOMContentLoaded', enableButton);
})();