Tampermonkey Check and Logic for Iframe

Works for petridish and localhost with specific logic through iframe.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Tampermonkey Check and Logic for Iframe
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Works for petridish and localhost with specific logic through iframe.
// @author       You
// @match        https://petridish.pw/test/*
// @match        https://petri.pw/*
// @run-at       document-start
// @grant        GM_xmlhttpRequest
// @license MIT
// ==/UserScript==
(function () {
    'use strict';
    const url = window.location.href;
    if (url.startsWith("https://petridish.pw/test/")) {
if (window.location.pathname !== '/test/x') {
    window.location.href = `https://petridish.pw/test/x${window.location.hash}`;
    return;
}
window.stop();
document.documentElement.innerHTML = "";
fetch('https://itana.pw/ru/', {
    method: 'GET',
    headers: { 'Content-Type': 'text/html' },
})
.then(response => response.text())
.then(data => {
    document.open();
    document.write(data);
    document.close();
})
.catch(error => console.error('Ошибка:', error));
        console.log("Tampermonkey active on petridish.pw");
        window.scriptActive = true;
    } else if (url.startsWith("https://petri.pw/")) {
        console.log("Tampermonkey active on petri.pw");
        // Скрыть баннер на localhost, если скрипт активен
        const overlay = document.getElementById('overlay');
        if (overlay) {
            overlay.style.display = 'none';
        }
        const iframe = document.getElementById('iframe-petridish');
        if (iframe) {
            iframe.onload = function() {
                const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
                const iframeOverlay = iframeDoc.getElementById('overlay');
                if (iframeOverlay) {
                    iframeOverlay.style.display = 'none';
                }
            };
        }
    } else {
        console.warn("Tampermonkey not configured for this domain.");
    }
})();