Dead Frontier at work

This script will show your token to authenticate into Inner City. This script was made to make it easier for people who want to play Dead Frontier 3D on computers they don't have Administrator privileges to install programs.

// ==UserScript==
// @name         Dead Frontier at work
// @namespace    df3datwork
// @version      1.2.7
// @description  This script will show your token to authenticate into Inner City. This script was made to make it easier for people who want to play Dead Frontier 3D on computers they don't have Administrator privileges to install programs.
// @author       ils94
// @match        https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=21
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const hideWindow = false; //change this to true if you do not want the window to appear. Your token will still be copied.

    // Create a custom dialog box
    const dialog = document.createElement('div');
    dialog.style.position = 'fixed';
    dialog.style.top = '50%';
    dialog.style.left = '50%';
    dialog.style.transform = 'translate(-50%, -50%)';
    dialog.style.padding = '20px';
    dialog.style.width = '600px';
    dialog.style.height = '100px';
    dialog.style.background = 'grey';
    dialog.style.color = 'white';
    dialog.style.border = '1px solid white';
    dialog.style.zIndex = '9999';
    dialog.style.textAlign = 'center';
    dialog.style.fontSize = '16px';
    dialog.style.borderRadius = '10px';
    dialog.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';

    // Create a title element
    const title = document.createElement('div');
    title.textContent = 'Dead Frontier 3D at Work Script';
    title.style.position = 'absolute';
    title.style.top = '0';
    title.style.left = '0';
    title.style.width = '100%';
    title.style.height = '40px';
    title.style.lineHeight = '40px';
    title.style.backgroundColor = '#444';
    title.style.color = 'white';
    title.style.fontWeight = 'bold';
    title.style.fontSize = '20px';
    title.style.borderBottom = '1px solid white';
    title.style.borderTopLeftRadius = '10px';
    title.style.borderTopRightRadius = '10px';

    // Create a close "X" button
    const closeButton = document.createElement('span');
    closeButton.textContent = '✖';
    closeButton.style.position = 'absolute';
    closeButton.style.top = '5px';
    closeButton.style.right = '10px';
    closeButton.style.cursor = 'pointer';
    closeButton.style.color = 'white';
    closeButton.style.fontSize = '18px';
    closeButton.style.fontWeight = 'bold';

    // Create a textarea
    const textArea = document.createElement('textarea');
    textArea.style.width = '100%';
    textArea.style.height = '70px';
    textArea.style.marginTop = '30px';
    textArea.style.resize = 'none';
    textArea.style.background = 'white';
    textArea.style.color = 'black';
    textArea.readOnly = true;

    // Append elements to the dialog
    dialog.appendChild(title);
    dialog.appendChild(closeButton);
    dialog.appendChild(textArea);

    // Get the button element
    const button = document.querySelector('button[onclick^="window.location.href = \\"deadfrontier:"]');

    // Add click event listener to the button
    button.addEventListener('click', function() {
        // Extract token
        const buttonText = button.getAttribute('onclick').match(/deadfrontier:([^"]+)/)[1];

        // Construct the dialog message
        const dialogMessage = `Your token has been automatically copied. You can paste it into the Dead Frontier 3D at Work GUI. If it didn’t copy automatically, you can manually copy your token below:

${buttonText}`;

        // Copy token to clipboard
        navigator.clipboard.writeText('token' + buttonText).then(() => {
            console.log('Token copied to clipboard:', buttonText);
        }).catch(err => {
            console.error('Failed to copy token to clipboard:', err);
        });

        if (!hideWindow) {
            // Set dialog message
            textArea.value = dialogMessage;

            // Append dialog to document body
            document.body.appendChild(dialog);

            // Close dialog when X is clicked
            closeButton.addEventListener('click', function() {
                document.body.removeChild(dialog);
            });
        }
    });
})();