closeBanner

try to take over the world!

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         closeBanner
// @namespace    http://tampermonkey.net/
// @version      0.2.3
// @description  try to take over the world!
// @author       anonym
// @grant        none
// @include        https://alpha.e-sim.org/battle.html?id=*
// @include        https://primera.e-sim.org/battle.html?id=*
// ==/UserScript==
const closeBanners = () => {
    const banners = document.querySelectorAll('.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-draggable.ui-dialog-buttons');

    const closeBanner = (banner) => {
    const observer = new MutationObserver(mutationRecords => {
    const display = mutationRecords[0].target.style.display;
        if(display === 'block') {
        const btnYes = banner.querySelectorAll('.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-text-only')[0];
    const event = new Event('click');
    console.log('banner');
    btnYes.dispatchEvent(event);
        }
 
});

  observer.observe(banner, {
  attributes: true
});

};
    let i;
    if(document.URL.indexOf('primera') > 0){
        i = 0;
    } else {
       i = 1;
    }

    for(i; i< banners.length; i++) {
        closeBanner(banners[i]);
    }
}

let script = document.createElement('script');
	script.textContent = '(' + closeBanners + ')(jQuery, window);';
	document.body.appendChild(script);