Intake SOM

Intake inladen voor SOM

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Advertisement:

// ==UserScript==
// @name         Intake SOM
// @namespace    http://tampermonkey.net/
// @version      1.3.0
// @description  Intake inladen voor SOM
// @match        *://*/*
// @grant        none
// ==/UserScript==



// ⚠️ VEROUDERD: Dit script is verouderd en wordt niet meer onderhouden.
// De API-koppeling (whisper.anzwerz.ai) is verwijderd; gebruik een nieuwere versie indien beschikbaar.

(function() {
    'use strict';
window.addEventListener('load', function() {



    function getClientNumber() {
        console.log('window.parent.parent.frames.length:', window.parent.parent.frames.length);

            // Pak de derde frame (index 2) uit het frameset
            const mainframe = window.parent.parent.frames[2]; // of window.frames['mainframe']

            if (!mainframe) {
                console.error('Mainframe (derde frame) niet gevonden');
                return null;
            }

            // Pak het document uit de frame
            const frameDoc = mainframe.document;

            if (!frameDoc) {
                console.error('Kan niet bij frame document');
                return null;
            }

            console.log('Frame document gevonden');
            const container = frameDoc.getElementById('tab_contents3');
            console.log(container);

        if (!container) return null;

        // Zoek de tweede <tr> binnen de container
        const rows = container.querySelectorAll('table tbody tr');
            try {
                if (rows.length >= 2) {
                    const secondRow = rows[1];
                    const lastCell = secondRow.lastElementChild;

                    if (lastCell) {
                        const text = (lastCell.textContent || lastCell.innerText).trim();
                        const numberMatch = text.match(/\d+/);
                        if (numberMatch) {
                            return numberMatch[0];
                        }
                    }
                }
            } catch (err) {
                console.error(err);
                return null;
            }

        return null;
    }


    function storeConsultDate(){
        const datumEl = document.getElementById('t202_datumaanmelding');
        if (datumEl){
            console.log("element gevonden");
            sessionStorage.setItem('consultDate', datumEl.value);

        }
    }
    
    const clientNumber = getClientNumber();
    storeConsultDate()
    const dateConsult = sessionStorage.getItem('consultDate');

    if (clientNumber === null){
    console.log("kan clientnummer niet vinden");
    } else if (dateConsult == null) {
        console.log("kan datum niet vinden");
    } else {
        console.log("haal data op");
        // Fetches naar whisper.anzwerz.ai verwijderd
    }
}, false);
})();