// ==UserScript==

// @name         test-ap-ux-improver
// @namespace    https://test-anfragen-pool.swrapp.net/*
// @version      2024-05-07_15-14

// @resource     DASHBOARD_CSS https://gitlab.ard.de/Jan.Seipel/test-ap-ux-improver/-/raw/main/stylesheets/test-ap-style-dashboard.css
// @resource     TICKETZOOM_CSS https://gitlab.ard.de/Jan.Seipel/test-ap-ux-improver/-/raw/main/stylesheets/test-ap-style-ticketzoom.css
// @resource     TICKETFREETEXT_CSS https://gitlab.ard.de/Jan.Seipel/test-ap-ux-improver/-/raw/main/stylesheets/test-ap-style-ticketfreetext.css
// @resource     TICKETPHONE_CSS https://gitlab.ard.de/Jan.Seipel/test-ap-ux-improver/-/raw/main/stylesheets/test-ap-style-ticketphone.css

// @description  passt den IDA-Anfragen-Pool an die Anforderungen von IDA-Desk an
// @author       Jan Seipel
// @match        https://test-anfragen-pool.swrapp.net/*

// @grant        GM_getResourceText
// @grant        GM_addStyle

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

    // ====== CUSTOM STYLESHEETS HINZUFÜGEN ======

    // Checke, auf welcher Seite du dich befindest um
    // jeweils ein anderes Stylesheet zu laden
    const URL = document.URL

    // Alle verfügbaren Stylesheets & deren URL-Identifier
    const stylings = [
        {"id": "AgentTicketZoom", "stylesheet": "TICKETZOOM_CSS"},
        {"id": "AgentTicketFreeText", "stylesheet": "TICKETFREETEXT_CSS"},
        {"id": "AgentTicketPhone", "stylesheet": "TICKETPHONE_CSS"},
    ]

    // Dashboard-Stylesheet auf allen Seiten laden,
    // damit überall die Labels angezeigt werden
    GM_addStyle(GM_getResourceText("DASHBOARD_CSS"))

    // Zusätzliche Stylesheets je nach URL laden
    for (let style of stylings) {
        URL.includes(style.id) && GM_addStyle(GM_getResourceText(style.stylesheet))
    }

    // ====== WEITERE JAVASCRIPT FUNKTIONEN ======

    // Erfassungsmaske Telefonticket immer
    // im neuen Fenster öffnen
    document.querySelector("#ToolBar li.PhoneTicket > a").setAttribute("target","_blank")

    // Einhorn hinter Lorenz' Namen
    const lorenz = [...document.querySelectorAll("div[title='Lorenz Bockisch']")]
    lorenz.map((e)=>e.innerText += " 🦄")


}, false);