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