Created
April 29, 2026 15:35
-
-
Save ExtReMLapin/ddcd002859608593be714671ab0a98c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Unlock seek bar - Gendform [DEBUG] | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.1 | |
| // @description Version debug avec logs détaillés | |
| // @match *://gendform2.gendarmerie.interieur.gouv.fr/* | |
| // @match *://*.gendarmerie.interieur.gouv.fr/* | |
| // @grant none | |
| // @run-at document-start | |
| // @all-frames true | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const TAG = '[UNLOCK-SEEK]'; | |
| const isTopFrame = (window.top === window.self); | |
| const frameInfo = isTopFrame ? 'TOP' : 'IFRAME'; | |
| console.log(`%c${TAG} Script chargé dans ${frameInfo}`, 'color:#0a0;font-weight:bold'); | |
| console.log(`${TAG} URL: ${location.href}`); | |
| console.log(`${TAG} document.readyState au démarrage: ${document.readyState}`); | |
| let tickCount = 0; | |
| let lastSeekFound = false; | |
| let lastReadOnlyState = null; | |
| let lastDisabledState = null; | |
| function unlock() { | |
| tickCount++; | |
| const seek = document.getElementById('seek'); | |
| // Log seulement si l'état change (pour pas spammer la console) | |
| const seekFound = !!seek; | |
| if (seekFound !== lastSeekFound) { | |
| if (seekFound) { | |
| console.log(`%c${TAG} [${frameInfo}] ✅ #seek TROUVÉ (tick #${tickCount})`, 'color:#0a0'); | |
| console.log(`${TAG} Element:`, seek); | |
| console.log(`${TAG} Classes actuelles:`, seek.className); | |
| } else { | |
| console.log(`${TAG} [${frameInfo}] ❌ #seek introuvable (tick #${tickCount})`); | |
| } | |
| lastSeekFound = seekFound; | |
| } | |
| if (!seek) return; | |
| // Vérification de la classe read-only | |
| const hasReadOnly = seek.classList.contains('read-only'); | |
| if (hasReadOnly !== lastReadOnlyState) { | |
| console.log(`${TAG} [${frameInfo}] read-only état changé: ${lastReadOnlyState} → ${hasReadOnly}`); | |
| lastReadOnlyState = hasReadOnly; | |
| } | |
| if (hasReadOnly) { | |
| seek.classList.remove('read-only'); | |
| console.log(`%c${TAG} [${frameInfo}] 🔓 read-only RETIRÉ (tick #${tickCount})`, 'color:#fa0;font-weight:bold'); | |
| console.log(`${TAG} Classes après suppression:`, seek.className); | |
| } | |
| // Vérification de l'input disabled | |
| const input = seek.querySelector('input[type="range"]'); | |
| if (input) { | |
| const isDisabled = input.hasAttribute('disabled'); | |
| if (isDisabled !== lastDisabledState) { | |
| console.log(`${TAG} [${frameInfo}] input disabled changé: ${lastDisabledState} → ${isDisabled}`); | |
| lastDisabledState = isDisabled; | |
| } | |
| if (isDisabled) { | |
| input.removeAttribute('disabled'); | |
| console.log(`%c${TAG} [${frameInfo}] 🔓 input disabled RETIRÉ (tick #${tickCount})`, 'color:#fa0;font-weight:bold'); | |
| } | |
| } else { | |
| console.log(`${TAG} [${frameInfo}] ⚠️ input[type="range"] introuvable dans #seek`); | |
| } | |
| } | |
| // Recherche dans toutes les frames pour debug | |
| function reportFrames() { | |
| console.log(`${TAG} [${frameInfo}] Nombre d'iframes sur la page: ${document.querySelectorAll('iframe').length}`); | |
| document.querySelectorAll('iframe').forEach((iframe, i) => { | |
| console.log(`${TAG} iframe #${i}:`, { | |
| src: iframe.src, | |
| id: iframe.id, | |
| class: iframe.className | |
| }); | |
| }); | |
| } | |
| // Cherche #seek partout (même via querySelector, au cas où) | |
| function deepScan() { | |
| console.log(`${TAG} [${frameInfo}] === DEEP SCAN ===`); | |
| const byId = document.getElementById('seek'); | |
| const byQuery = document.querySelector('#seek'); | |
| const byClass = document.querySelectorAll('.cs-seekcontrol'); | |
| const allReadOnly = document.querySelectorAll('.read-only'); | |
| console.log(`${TAG} getElementById('seek'):`, byId); | |
| console.log(`${TAG} querySelector('#seek'):`, byQuery); | |
| console.log(`${TAG} querySelectorAll('.cs-seekcontrol'): ${byClass.length} éléments`, byClass); | |
| console.log(`${TAG} querySelectorAll('.read-only'): ${allReadOnly.length} éléments`, allReadOnly); | |
| reportFrames(); | |
| } | |
| // 1) Scan régulier | |
| setInterval(unlock, 500); | |
| console.log(`${TAG} [${frameInfo}] setInterval(500ms) lancé`); | |
| // 2) MutationObserver | |
| const observer = new MutationObserver((mutations) => { | |
| // Log uniquement quand quelque chose touche à #seek ou ses enfants | |
| for (const m of mutations) { | |
| const target = m.target; | |
| if (target && (target.id === 'seek' || (target.closest && target.closest('#seek')))) { | |
| console.log(`${TAG} [${frameInfo}] 🔔 Mutation détectée sur/dans #seek:`, m.type, m.attributeName || ''); | |
| break; | |
| } | |
| } | |
| unlock(); | |
| }); | |
| function startObserver() { | |
| if (document.body) { | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true, | |
| attributes: true, | |
| attributeFilter: ['class', 'disabled'] | |
| }); | |
| console.log(`${TAG} [${frameInfo}] MutationObserver démarré sur document.body`); | |
| unlock(); | |
| } else { | |
| console.log(`${TAG} [${frameInfo}] document.body pas encore prêt, retry...`); | |
| requestAnimationFrame(startObserver); | |
| } | |
| } | |
| startObserver(); | |
| // 3) Deep scan à différents moments clés | |
| document.addEventListener('DOMContentLoaded', () => { | |
| console.log(`%c${TAG} [${frameInfo}] DOMContentLoaded`, 'color:#08f;font-weight:bold'); | |
| deepScan(); | |
| }); | |
| window.addEventListener('load', () => { | |
| console.log(`%c${TAG} [${frameInfo}] window.load`, 'color:#08f;font-weight:bold'); | |
| deepScan(); | |
| }); | |
| // 4) Deep scan toutes les 5 secondes pour les premières 30 secondes | |
| let deepScanCount = 0; | |
| const deepScanInterval = setInterval(() => { | |
| deepScanCount++; | |
| console.log(`${TAG} [${frameInfo}] Deep scan périodique #${deepScanCount}`); | |
| deepScan(); | |
| if (deepScanCount >= 6) clearInterval(deepScanInterval); | |
| }, 5000); | |
| // 5) Expose une fonction manuelle pour tester depuis la console | |
| window.__unlockSeekDebug = { | |
| unlock, | |
| deepScan, | |
| reportFrames, | |
| getSeek: () => document.getElementById('seek'), | |
| getTickCount: () => tickCount | |
| }; | |
| console.log(`${TAG} [${frameInfo}] Tape window.__unlockSeekDebug dans la console pour debug manuel`); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment