Google Forms - Full Width Fix

Force la largeur à 100% de manière dynamique sur Google Forms

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu betiği yüklemek için bir betik yöneticisi eklentisi yüklemeniz gerekecektir.

(Zaten bir betik yöneticim var, hadi yükleyelim!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Google Forms - Full Width Fix
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Force la largeur à 100% de manière dynamique sur Google Forms
// @author       Kyorai
// @match        https://docs.google.com/forms/*
// @grant        none
// @run-at       document-start
// @license MIT 
// ==/UserScript==

(function() {
    'use strict';

    function forceFullWidth() {
        // 1. On cible le formulaire principal (vue utilisateur)
        const form = document.querySelector('form[action*="formResponse"]');
        if (form && form.parentElement) {
            form.parentElement.style.setProperty('width', '100%', 'important');
            form.parentElement.style.setProperty('max-width', '100%', 'important');
        }

        // 2. On cible l'éditeur / vue des réponses (vue créateur - tes captures d'écran)
        // On cherche le conteneur principal qui a une largeur max définie par Google (généralement 770px ou 90vw)
        const containers = document.querySelectorAll('div[jsname]');
        containers.forEach(el => {
            const style = window.getComputedStyle(el);
            // Si l'élément a une largeur max ou une largeur fixe définie par Google, on la fait sauter
            if (style.width.includes('px') && parseInt(style.width) > 600 && parseInt(style.width) < 800) {
                 el.style.setProperty('width', '100%', 'important');
                 el.style.setProperty('max-width', '100%', 'important');
            }
        });

        // 3. Ciblage direct des conteneurs de structure majeurs de Google Forms
        const structuralDivs = document.querySelectorAll('div[role="main"], div[jsname="scpA6d"], div[jsname="le6uub"]');
        structuralDivs.forEach(div => {
            div.style.setProperty('width', '100%', 'important');
            div.style.setProperty('max-width', '100%', 'important');
            // On applique aussi aux enfants directs si nécessaire
            if (div.firstElementChild) {
                div.firstElementChild.style.setProperty('width', '100%', 'important');
                div.firstElementChild.style.setProperty('max-width', '100%', 'important');
            }
        });
    }

    // On lance une observation du DOM pour appliquer le style dès que les éléments s'affichent
    const observer = new MutationObserver((mutations) => {
        forceFullWidth();
    });

    // On commence à observer dès que le document est prêt
    document.addEventListener('DOMContentLoaded', () => {
        forceFullWidth();
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });

})();