Iframe Fullscreen Artist

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

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==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);
})();