Autodarts - Auto Fullscreen

Enables auto fullscreen-mode after game start

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Autodarts - Auto Fullscreen
// @namespace    http://tampermonkey.net/
// @version      0.15
// @description  Enables auto fullscreen-mode after game start
// @author       benebelter
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @match        https://play.autodarts.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=autodarts.io
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    $(document).on('click', 'button:contains("Start game"), .enter_fullscreen, .rematch_button, .css-1cd9b6o, .css-1b1zesg, .css-u7txwc',  function(){
        // collapse side bar

        $('.enter_fullscreen').hide();
        if( $('.css-17xejub').width() > 100 ){
            $('[aria-label="Collapse side bar"]').click();
        }

        if( window.innerHeight != screen.height) {
            document.querySelector("html").requestFullscreen();
            $('.exit_fullscreen').show();

        }

        $(document).on('click', '.exit_fullscreen', function(){
            $('.exit_fullscreen').show();
            $('.exit_fullscreen').hide();
        })

        if ($('.exit_fullscreen').length < 1) {
            $('.css-1jc8v6r').last().after('<a class="exit_fullscreen" class="chakra-menu__menuitem css-1jc8v6r" onclick="document.exitFullscreen();  ">Exit Fullscreen</a>');
        }

    })


    let timeout = setTimeout (
        function () {
            if ($('.enter_fullscreen').length < 1 && $('#button_play').length < 1 ){
                $('.css-1jc8v6r').last().after('<a class="enter_fullscreen" class="chakra-menu__menuitem css-1jc8v6r" onclick="">Fullscreen</a>');

// Button nach Next auf Spielseite einfügen
                $('.css-1b1zesg').last().after('<button id="button_play" class="chakra-button css-1b1zesg enter_fullscreen" onclick="">Fullscreen</button>');
                 console.log('add enter_fullscreen');

            }
            else {
                clearTimeout(timeout);
            console.log('clear Timeout');}



            document.addEventListener("fullscreenchange", () => {
                console.log("Fullscreen:", !!document.fullscreenElement);
            });
        }, 3000);


})();