Google Forms - Full Width Fix

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

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

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

})();