Iframe Fullscreen Artist

중첩된 iframe의 목적지까지 전체화면으로 변경

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

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

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         Iframe Fullscreen Artist
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  중첩된 iframe의 목적지까지 전체화면으로 변경
// @match        https://play.games.dmm.co.jp/*
// @match        https://osapi.dmm.com/gadgets/*
// @match        https://minasigo-no-shigoto-pd-r-client.orphans-order.com/*
// @author       You
// @match        *://*/*
// @grant        none
// @license MIT
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // 1. 강제 전체화면 스타일 정의
    // !important를 붙여 기존 사이트의 스타일을 무시합니다.
    const fullScreenCSS = `
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 2147483647 !important; /* 최대 z-index */
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        visibility: visible !important;
        display: block !important;
        background: black; /* 여백 보정용 */
    `;

    const targetIds = ['game_frame', 'game-iframe', 'Cocos2dGameContainer', 'GameDiv'];

    // 2. 스타일 주입 함수
    function applyStyles() {
        targetIds.forEach(id => {
            const el = document.getElementById(id);
            if (el) {
                el.style.cssText += fullScreenCSS;

                // 부모 요소들의 overflow를 제거하여 잘림 방지
                let parent = el.parentElement;
                while (parent) {
                    parent.style.overflow = 'visible';
                    parent.style.position = 'static';
                    parent = parent.parentElement;
                }
            }
        });
    }

    // 3. 로딩 시점 및 동적 생성 대응
    applyStyles();
    const observer = new MutationObserver(applyStyles);
    observer.observe(document.documentElement, { childList: true, subtree: true });
    // 허용하고 싶은 시스템 단축키 목록
    const allowKeys = ['F11', 'F12', 'F5'];

    window.addEventListener('keydown', function(e) {
        if (allowKeys.includes(e.key)) {
            // 이벤트 전파를 중단시켜 게임 엔진이 preventDefault()를 호출하지 못하게 함
            e.stopPropagation();
        }
    }, true); // true: 캡처링 모드로 설정하여 가장 먼저 이벤트를 가로챔

    window.addEventListener('keyup', function(e) {
        if (allowKeys.includes(e.key)) {
            e.stopPropagation();
        }
    }, true);
})();