Skip to content
Snippets Groups Projects
Select Git revision
  • 29d59f972da9828efcf7a1e2bd3c981342a30bcc
  • master default
  • develop
  • map_stuff
  • bullet
  • player_stuff
  • enemy
  • login_page
  • mob_stuff
  • register_page
10 results

index.js

Blame
  • VCLScript.js 2.63 KiB
    // ==UserScript==
    // @name         VM Warning Dialog Script with Specific Fullscreen Button
    // @namespace    http://tampermonkey.net/
    // @version      0.6
    // @description  Show a warning dialog and click specific fullscreen button for VM
    // @match        https://your-vm-site-url.com/*
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
    
        function debug(message) {
            console.log('VM Warning Script Debug: ' + message);
        }
    
        function clickFullscreenButton() {
            debug('Attempting to click fullscreen button');
            // Target the specific fullscreen button based on its structure
            var fullscreenButton = document.querySelector('span.ms-Button-flexContainer[data-automationid="splitbuttonprimary"] i[data-icon-name="FullScreenRegular"]');
            if (fullscreenButton) {
                // Click the parent button element, not just the icon
                var parentButton = fullscreenButton.closest('button');
                if (parentButton) {
                    parentButton.click();
                    debug('Fullscreen button clicked');
                } else {
                    debug('Parent button not found');
                }
            } else {
                debug('Fullscreen button not found');
            }
        }
    
        function showWarningDialog() {
            debug('Showing warning dialog');
            var dialog = document.createElement('div');
            dialog.id = 'vm-warning-dialog';
            dialog.style.cssText = `
                position: fixed;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                background-color: white;
                padding: 20px;
                border: 2px solid black;
                z-index: 10000;
                text-align: center;
            `;
    
            dialog.innerHTML = `
                <h2>Warning</h2>
                <p>Data is not saved after this session. Please use OneDrive to save your files.</p>
                <button id="okButton">OK</button>
            `;
    
            document.body.appendChild(dialog);
    
            document.getElementById('okButton').addEventListener('click', function() {
                dialog.remove();
                debug('Dialog closed');
                
                // Attempt to click the fullscreen button
                setTimeout(clickFullscreenButton, 1000); // Delay to ensure page is ready
            });
        }
    
        window.addEventListener('load', showWarningDialog);
    
        // Fallback
        setTimeout(function() {
            if (!document.getElementById('vm-warning-dialog')) {
                debug('Dialog not shown after load event, attempting to show now');
                showWarningDialog();
            }
        }, 2000);
    })();