BETSLIX - burning series enhancer

Wechselt automatisch zum VOE- oder Streamtape-Tab auf burning series und öffnet VOE oder Streamtape. Das Tool startet das nächste Video und falls nötig die nächste Staffel, wenn eine Episode beendet wurde.

// ==UserScript==
// @name           BETSLIX - burning series enhancer
// @name:en        BETSLIX - burning series enhancer

// @icon           https://bs.to/favicon.ico
// @author         xtrars
// @description:de Wechselt automatisch zum VOE- oder Streamtape-Tab auf burning series und öffnet VOE oder Streamtape. Das Tool startet das nächste Video und falls nötig die nächste Staffel, wenn eine Episode beendet wurde.
// @description:en Automatically switches to the VOE or Streamtape tab on burning series and opens VOE or Streamtape. The tool starts the next video and if necessary the next season when an episode is finished.
// @version        16.3.4
// @run-at         document-start
// @license        GPL-3.0-or-later
// @namespace      https://greasyfork.org/users/140785

// @compatible     chrome Chrome
// @compatible     firefox Firefox
// @compatible     opera Opera
// @compatible     edge Edge
// @compatible     safari Safari

// @grant          GM_setValue
// @grant          GM_getValue
// @grant          GM_addValueChangeListener
// @grant          GM_removeValueChangeListener
// @grant          GM_download
// @grant          GM_info
// @grant          GM_addStyle
// @grant          GM_getResourceText
// @grant          window.close
// @grant          window.focus

// @match          https://bs.to/*
// @match          https://burningseries.co/*
// @match          https://burningseries.sx/*
// @match          https://burningseries.vc/*
// @match          https://burningseries.ac/*
// @match          https://burningseries.cx/*
// @match          https://burningseries.nz/*
// @match          https://burningseries.se/*

// @match          https://dood.yt/*
// @match          https://d0000d.com/*

// @match          https://streamtape.com/*
// @match          https://streamadblocker.xyz/*
// @match          https://*.tapecontent.net/*

// @match          https://*.vidoza.net/*
// @match          https://*.videzz.net/*

// @match          https://*.voe-network.net/*
// @match          https://voe.sx/*
// @match          https://*.jamessoundcost.com/*

// @require        https://unpkg.com/video.js@latest/dist/video.min.js
// @require        https://unpkg.com/hls.js@latest/dist/hls.min.js

// @description Wechselt automatisch zum VOE- oder Streamtape-Tab auf burning series und öffnet VOE oder Streamtape. Das Tool startet das nächste Video und falls nötig die nächste Staffel, wenn eine Episode beendet wurde.
// ==/UserScript==


/**
 * The CBaseHandler class provides basic helper functions for handling DOM elements and URLs.
 * @class
 */
class CBaseHandler {

    /**
     * Returns the hoster as a string
     * @param {number} iIndex - 0: VOE, 1: Streamtape, 2: Doodstream, 3: Vidoza
     * @param {boolean} bAllLowerCase - If true, returns the hoster name in all lowercase
     * @returns {string} - The hoster name
     */
    getHoster(iIndex, bAllLowerCase = false) {
        const aHoster = ['VOE', 'Streamtape', 'Doodstream', 'Vidoza'];
        return bAllLowerCase ? aHoster[iIndex].toLowerCase() : aHoster[iIndex];
    }

    /**
     * Waits for an element to be available in the DOM and resolves with the element
     * @param {string} sSelector - The CSS selector of the element to wait for
     * @param {boolean} bWaitUnlimited - If true, waits indefinitely for the element. If false, waits for a maximum of 3 seconds
     * @returns {Promise<HTMLElement>} - A promise that resolves with the element when it becomes available in the DOM
     */
    waitForElement(sSelector, bWaitUnlimited = true) {
        return new Promise(async resolve => {
            if (document.querySelector(sSelector)) {
                return resolve(document.querySelector(sSelector));
            }

            const oObserver = new MutationObserver(() => {
                if (document.querySelector(sSelector)) {
                    resolve(document.querySelector(sSelector));
                    oObserver.disconnect();
                }
            });

            if (document.body) {
                oObserver.observe(document.body, {
                    childList: true, subtree: true,
                });
            }

            if (!bWaitUnlimited) {
                setTimeout(() => {
                    resolve(document.querySelector(sSelector));
                    oObserver.disconnect();
                }, 3000);
            }
        });
    }

    /**
     * Checks if the current URL contains all the selectors in the given array
     * @param {Array<RegExp>} aSelector - An array of URL selectors to check
     * @returns {boolean} - True if the URL contains all the selectors, false otherwise
     */
    hasUrl(aSelector) {
        let bIsAvailable = true;
        for (let rSelector of aSelector) {
            bIsAvailable = document.location.href.search(rSelector) !== -1;
            if (!bIsAvailable) {
                return false;
            }
        }
        return true;
    }

    /**
     * Reloads the current page after the specified delay
     * @param {number} iDelay - The delay in milliseconds before reloading the page
     */
    reload(iDelay = 300) {
        setTimeout(() => {
            window.location.reload();
        }, iDelay);
    }

    /**
     * Returns the first element matching the given CSS selector and attribute that matches the specified regular expression
     * @param {string} sSelector - The CSS selector to search for
     * @param {string} sAttribute - The attribute to match the regular expression against
     * @param {RegExp} rRegex - The regular expression to match against the attribute value
     * @returns {HTMLElement|boolean} - The first matching element, or false if no matching element is found
     */
    querySelectorAllRegex(sSelector = '*', sAttribute = 'name', rRegex = /.*/) {
        for (const oElement of document.querySelectorAll(sSelector)) {
            if (rRegex.test(oElement[sAttribute])) {
                return oElement;
            }
        }
        return false;
    }

    restartAnimation(oEl) {
        oEl.style.animation = 'none';
        oEl.offsetHeight; /* trigger reflow */
        oEl.style.animation = null;
    }
}

/**
 The CBurningSeriesHandler class extends the CBaseHandler class and provides methods for handling and enhancing
 the Burning Series website. This class is responsible for building the settings window that is displayed when
 the settings button is clicked.
 @class
 @extends CBaseHandler
 */
class CBurningSeriesHandler extends CBaseHandler {

    /**
     Initializes the values for the user script's settings.
     */
    initGMVariables() {
        const oVariables = [
            {name: 'bActivateEnhancer', defaultValue: false},
            {name: 'bAutoplayNextSeason', defaultValue: true},
            {name: 'bAutoplayRandomEpisode', defaultValue: false},
            {name: 'bSelectHoster', defaultValue: this.getHoster(0, true)},
            {name: 'bSkipStart', defaultValue: false},
            {name: 'bSkipEnd', defaultValue: false},
            {name: 'iSkipEndTime', defaultValue: 0},
            {name: 'iSkipStartTime', defaultValue: 0},
            {name: 'bFirstStart', defaultValue: true},
            {name: 'sLastActiveTab', defaultValue: ''},
            {name: 'bIsSettingsWindowOpen', defaultValue: false},
            {name: 'oSettingsWindowPosition', defaultValue: {}}
        ];

        for (const o of oVariables) {
            GM_setValue(o.name, GM_getValue(o.name) ?? o.defaultValue);
        }
    }

    /**
     Determines whether another hoster is available for the current episode.
     @returns {boolean} Whether another hoster is available.
     */
    hasAnotherHoster() {
        return this.hasUrl([new RegExp(`https:\\/\\/(bs.to|burningseries.[a-z]{2,3})\\/.*[0-9]{1,3}\\/[0-9]{1,3}-.*\\/[a-z]+\\/(?!${this.getHoster(0)}|${this.getHoster(1)}|${this.getHoster(2)}|${this.getHoster(3)}).*`, 'g')]);
    }

    /**
     Determines whether the current page is a series page.
     @returns {boolean} Whether the page is a series page.
     */
    isSeries() {
        return this.hasUrl([/^https:\/\/(bs.to|burningseries.[a-z]{2,3})\/serie\//g]);
    }

    /**
     Determines whether the current page is an episode page.
     @returns {boolean} Whether the page is an episode page.
     */
    isEpisode() {
        return this.hasUrl([/^https:\/\/(bs.to|burningseries.[a-z]{2,3})/g, /[0-9]{1,3}\/[0-9]{1,3}-/g]);
    }

    /**
     Clicks the play button on the current episode page.
     @async
     @returns {Promise<void>} A promise that resolves when the button has been clicked.
     */
    async clickPlay() {
        return new Promise(async resolve => {
            let oPlayerElem = await this.waitForElement('section.serie .hoster-player')
                .catch(() => null);
            let iNumberOfClicks = 0;
            let iClickInterval = setInterval(async () => {
                if (oPlayerElem) {
                    if (
                        document.querySelector('section.serie .hoster-player > a') ||
                        document.querySelector('section.serie .hoster-player > iframe') ||
                        iNumberOfClicks > 120 ||
                        this.querySelectorAllRegex('iframe', 'title', /recaptcha challenge/)
                    ) {
                        clearInterval(iClickInterval);
                        resolve();
                    }
                    iNumberOfClicks++;
                    let oClickEvent = new Event('click');
                    oClickEvent.which = 1;
                    oClickEvent.pageX = 6;
                    oClickEvent.pageY = 1;
                    oPlayerElem.dispatchEvent(oClickEvent);
                }
            }, 500);
        });
    }

    /**
     Plays the next episode if the current video has ended.
     @param {boolean} [bSetEvent=true] - Whether to set the event listener to play the next episode.
     */
    playNextEpisodeIfVideoEnded(bSetEvent = true) {
        if (!bSetEvent) {
            GM_removeValueChangeListener('isLocalVideoEnded');
            return;
        }
        GM_addValueChangeListener('isLocalVideoEnded', () => {
            if (GM_getValue('isLocalVideoEnded')) {
                GM_setValue('isLocalVideoEnded', false);
                window.focus();
                if (GM_getValue('bAutoplayRandomEpisode')) {
                    let oRandomEpisode = document.querySelector('#sp_right > a');
                    document.location.replace(oRandomEpisode.href);
                }
                else {
                    let oNextEpisode = document
                        .querySelector('.serie .frame ul li[class^="e"].active ~ li:not(.disabled) a');
                    if (oNextEpisode) {
                        document.location.replace(oNextEpisode.href);
                    }
                    else if (GM_getValue('bAutoplayNextSeason')) {
                        let oNextSeason = document
                            .querySelector('.serie .frame ul li[class^="s"].active ~ li:not(.disabled) a');
                        if (oNextSeason) {
                            GM_setValue('clickFirstSeason', true);
                            document.location.replace(oNextSeason.href);
                        }
                    }
                }
            }
        });
    }

    /**
     Appends custom styles to the current page.
     */
    appendOwnStyle() {
        const oStyle = document.createElement('style');
        oStyle.id = 'xtrars-style';

        // language=HTML
        oStyle.innerHTML = `<style>
              :root {
              --inner-pl: 14px;
              --inner-bc-before: #2FB536;
              --inner-bc-after: #12A6F6;
              --color: white;
              --xtrars-bs-img: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9biyIVh1ZQcchQnSxIFXHUKhShQqgVWnUwufQLmjQkKS6OgmvBwY/FqoOLs64OroIg+AHi6OSk6CIl/i8ptIjx4Lgf7+497t4B/kaFqWbXBKBqlpFOJoRsblXofkUQYQxgCHGJmfqcKKbgOb7u4ePrXYxneZ/7c/QpeZMBPoF4lumGRbxBPL1p6Zz3iSOsJCnE58TjBl2Q+JHrsstvnIsO+3lmxMik54kjxEKxg+UOZiVDJZ4ijiqqRvn+rMsK5y3OaqXGWvfkLwzltZVlrtMcQRKLWIIIATJqKKMCCzFaNVJMpGk/4eEfdvwiuWRylcHIsYAqVEiOH/wPfndrFibjblIoAQRfbPtjFOjeBZp12/4+tu3mCRB4Bq60tr/aAGY+Sa+3tegR0L8NXFy3NXkPuNwBBp90yZAcKUDTXygA72f0TTkgfAv0rrm9tfZx+gBkqKvUDXBwCIwVKXvd4909nb39e6bV3w+a5XK3MBuglgAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+YFExUkBoTjADYAA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Ud+mLds5cMiLBYH6Xv1vGzIl3N/p3bHTNIqlvkdwkJObhyNq16ry81+3MZ3tjmnpDgc6BJE8JUiMEiQqIkwhIIg66UqOiMTsn0Iz9V4JoohIPPTa2NNDoqV0qVV7qHmlGiSk6HvzYzodP4h4cvjI0BFRlzvw2LQ1g62bN9aFCAIKCgtRIzk5ZHKrGiQIqJmcrIsQJISSHEqQIKHJUfXNst836EIEGKvXbwr5NZUgQcLJx7czTw/XLrtAonP7NiF3CdQHCQE0ohUAQQ1T/4tqkBA93G9+/E0Xwk/c9OBzq3UVYgDdrrjHFYWLEXX883Nvh1X7qokVBnw2ay4vu/AsXQiXmlVKEJfgt2Vp7H5iJ10Il5JDCeISZO3Zywb16+pCACgsKkJyUpJr5FKddBeg4ZH1jDHG7MzcE9Pr8MuSNFeRQzWIS/HDgsXs3bOrmlRKEEUlTA4mJiQoMdTEUvhCUmKiMcaY0RM+jzpiRNJwbkUE4YtvfozInMbi5au1okARWgwa+jqz9+W4lhQHcvPY7bI7e+qTUrgCL709lmnrNoWVFJ/N+l41hSJy0O/6+1NS5yxgfn5gjxRcs2ETp82czf63PTpFV1mhUCgUCoVCoVAoFAqFQqEIF/4fbNAlnifq5NEAAAAASUVORK5CYII=);
            }
            
            @font-face { 
              font-family: "IEC symbols Unicode";
              src: url(data:font/woff2;base64,d09GMgABAAAAAARMAA4AAAAACNAAAAPvAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0ZGVE0cGh4GVgCCYhEICoUUhDABNgIkAygLFgAEIAWDdAeBFz93ZWJmBhtcB8iOxDgmcsRI5UX+Q571flJmrKx1G3faMbWgT8JJaVcQD/8/5u77M4malrZknsbpZlk8EgqZQ00kC4UUGTycdp7gnef436GyhAI+52tgAcacBezsL21O4FUACIDLl3TCAeCK6cpHpq4t/UPsNdoAU8AgECghkPXdAiSdSAMQIyteJF4GkC1+Y68jLRkCg5wckpDHQwH3yhQ405kVIUn7l4ajMpD0wQGAVQXWIWgMLwRdFrveXFNE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il8lKDQhCPFAAA=);
            }
            
            .run-circleToWindow-animation {
                animation: 500ms linear 0s 1 normal none running xtrarsSlideIn, 
                           500ms linear 0s 1 normal none running xtrarsCircleToWindow;
                animation-fill-mode: forwards;
            }            
            
            .run-windowToCircle-animation {
                animation: 500ms linear 0s 1 normal none running xtrarsSlideIn, 
                           500ms linear 0s 1 normal none running xtrarsWindowToCircle;
                animation-fill-mode: forwards;
            }
            
            @keyframes xtrarsSlideIn {
                0%   {transform: translate(0, 0);}
                40%  {transform: translate(0, 0);}
                99.99% {transform: translate(0, 0);}
                100% {transform: translate(0, 0);}
            }    
           
            
            @keyframes xtrarsCircleToWindow {
                0%   {clip-path: circle(35px at center); opacity: .2;}
                60%  {clip-path: circle(35px at center); opacity: 1;}
                99.99% {clip-path: circle(270px at center);}
                100% {}
            }
             
             @keyframes xtrarsWindowToCircle {
                0%   {clip-path: circle(290px at center);}
                40%  {clip-path: circle(35px at center); opacity: 1;}
                99.99% {clip-path: circle(35px at center); opacity: .2;}
                100% {clip-path: circle(35px at center); display: none;}
            }         
            
            .xtrars-power-symbol {
                font-family: 'IEC symbols Unicode',sans-serif;
                font-style: normal;
            }
            
            #xtrars-settings-window {
                overflow: hidden;
            }
            
            .xtrars-donate {
                background-color:#12a6f6;
                border-radius:21px;
                border:1px solid #11a4e3;
                display:inline-block;
                cursor:pointer;
                font-weight:bold;
                padding:3px 12px;
                text-decoration:none;
                color: white;
            }
            
            .xtrars-donate:hover, button.tab:hover, a.tab:hover {
                text-decoration:none;
                background-color:#11a4e3;
            }
            
            button.tab, a.tab {
                background-color: transparent;
                color: white;
                float: left;
                border: none;
                outline: none;
                cursor: pointer;
                padding: 7px 10px 8px;
                user-select: none;
            }
            
            @keyframes shake {
                10%, 90% {transform: translate3d(-.5px, 0, 0);}
                20%, 80% {transform: translate3d(1px, 0, 0);}
                30%, 50%, 70% {transform: translate3d(-2px, 0, 0);}
                40%, 60% {transform: translate3d(2px, 0, 0);}
            }
            
            #Streaming .onoffswitch {
                min-width: 357px;
            }
            
            #BS .onoffswitch {
                min-width: 272px;
            }
            
            .onoffswitch {
                z-index: 161;
                position: relative; 
                width: 100%;
            }

            .onoffswitch-inner {
                display: inline-block; 
                width: 200%; 
                margin-left: -100%;
                transition: margin 0.3s ease-in 0s;
                position: relative;
                bottom: 0;
                transform: translateY(-40%);
                top: 50%;
            }
            
            .onoffswitch-inner span {
                padding-left: 10px;
            }           
             
             .onoffswitch-inner > span {
                display: inline-block;
                width: calc(50% - 3px);
            }

            .xtrars-toggle:has(> .onoffswitch-checkbox:checked) + .label-wrapper > .onoffswitch-inner {
                margin-left: 0;
            }
            
            .workaroundChecked {
                margin-left: 0;
            }
            
            .label-wrapper {
                font-size: 11px;
                font-family: Trebuchet, Arial, sans-serif;
                position: relative;
                white-space: nowrap;
                overflow: hidden;
                display: inline-block;
                width: calc(100% - 34px);
                height: 16px;
            }
            
            input.skip-start, input.skip-end {
                position: absolute; 
                right: 0; 
                top: 0; 
                height: 16px; 
                min-width: 0; 
                width: 50px; 
                display: none;
            }
            
            .onoffswitch-checkbox.disabled {
                pointer-events: none;
                -webkit-user-select: none; /* Safari */
                user-select: none;
            }
            
            #xtrars-btn {
               position: relative;
               left: calc(100% - 70px);
               background: #12a6f6;
               border-radius: 50%;
               width: 70px;
               height: 70px;
               line-height: 81px;
               text-align: center;
               cursor: pointer;
               transition: transform 0.2s ease, box-shadow 0.1s ease;
           }
            #xtrars-btn:hover {
                transform: scale(100.7%);
                box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
                transition: transform .3s ease, box-shadow .2s ease;
            }
            
            #xtrars-menu {
               right: 4px;
            }
            
            .xtrars-donation-container {
                display: flex;
                align-items: center;
            }

            .xtrars-donation-text {
                flex: 1; 
                margin-right: 10px; 
            }
            
            #xtrars-pp-qr {
               width: 90px;
               height: 90px;
               display: inline-block;
               background: no-repeat center url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs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gQOBGzDFe+kFlbm1QzRMLqU3blelltv6w4OLKiazuQSDSZxxrfZsSTwJGGKw6tOWH+hc3G9RVpVTl+TInkKbhQ9FFxUYhPZHwvAQyHVglgHAyRw9yh0pkCXARoRBfacRBhQgTIMH8vAYSTPgqNwwiwokvyXARYO9ET1Y+KAIphrr5GfaEwXc3LUdk0fuRWjMK0C+dGJyKyf18U0aKxqtSbLWRMqiI5MBqGLwJ0ECIS6qaHfvO3AJ1/5xBgSfLu+sKZXlTdLUj+PR7r89J6r8+JAFX99uqNiAAtg1VynhoBAl566Vl/9e9/obkkIZKuyscAAAAASUVORK5CYII=');
               background-size: contain;
            }
            
            #xtrars-btn-icon {
               width: 70px;
               height: 70px;
               display: inline-block;
               background: no-repeat center var(--xtrars-bs-img);
               background-size: contain;
               clip-path: circle(34px at center);
            }
            
            .onoffswitch-checkbox {
                float: left;
                margin-top: 3px;
                cursor: pointer;
            }
            
            .onoffswitch.disabled { 
                color: grey;            
            }
            
            .disabled:after {
                background-color: darkgrey !important;
            }
            
            .disabled:before {
                background-color: darkgrey !important;
            }
            
            .hidden {
                visibility: hidden !important;
            }
            
            .xtrars-tabcontent::-webkit-scrollbar {
                width: 10px;
            }
            
            .xtrars-tabcontent::-webkit-scrollbar-track {
                background: #fdfdfd; 
            }
             
            .xtrars-tabcontent::-webkit-scrollbar-thumb {
                background: #12a6f6; 
            }
            
            .xtrars-tabcontent::-webkit-scrollbar-thumb:hover {
                background: #0296d6; 
            }
            
            .xtrars-tabcontent {
                display: none;
                padding: 9px;
                width: 100%;
                height: calc(100% - 60px);
                overflow: auto;
            }
            
            .xtrars-active {
                text-shadow: -1px 0 #12a6f6 !important; 
                color: #12a6f6 !important; 
                background-color: rgb(253, 253, 253) !important;
            }
            
            #xtrars-settings-toolbar {
                height: 30px; 
                width: 100%; 
                color: white; 
                line-height: 30px;
                background: #12a6f6 var(--xtrars-bs-img) no-repeat center left 5px;
                background-size: auto 25px;
            }
            
            .xtrars-toolbar-text {
                display: inline-block; 
                margin-left: 10px;
                padding-left: 25px; 
                user-select: none; 
                width: calc(100% - 65px);
                text-overflow: ellipsis; 
                overflow: hidden; 
                white-space: nowrap;
                transition: width .7s;
            }
            
            .xtrars-toolbar-text:has(~ .xtrars-search input:not(:placeholder-shown) + div svg), 
            .xtrars-toolbar-text:has(~ .xtrars-search input:focus + div svg) {
                width: calc(100% - 125px);
                transition: width 0.5s;
            }
            
            .xtrars-select {
                display: inline; 
                font-size: 11px; 
                padding: 0 8px; 
                border-radius: 0;
                outline: none;
            }
            
            /*Thanks to halvves https://codepen.io/halvves/pen/ExjxaKj*/
            .xtrars-toggle {
                cursor: pointer;
                display: inline-block;
                isolation: isolate;
                position: relative;
                height: 14px;
                width: 30px;
                border-radius: 7px;
                overflow: hidden;
                box-shadow:
                    -4px -2px 4px 0 #ffffff,
                    4px 2px 6px 0 #d1d9e6,
                    2px 2px 2px 0 #d1d9e6 inset,
                    -2px -2px 2px 0 #ffffff inset;
            }
            
            .xtrars-toggle-state {
                display: none;
            }
            
            .xtrars-indicator {
                height: 100%;
                width: 200%;
                background: #12a6f6;
                border-radius: 7px;
                transform: translate3d(-75%, 0, 0);
                transition: transform .4s cubic-bezier(0.85, 0.05, 0.18, 1.35);
                box-shadow:
                    -4px -2px 4px 0 #ffffff,
                    4px 2px 6px 0 #d1d9e6;
            }
            
            
            @media (max-width: 270px) {
                #xtrars-settings-tabs .xtrars-settings-tabs, #xtrars-settings-tabs .xtrars-update-button {
                    padding-left: 3px !important;
                    padding-right: 3px !important;
                }
            }      
                  
            @media (max-width: 208px) {             
                #xtrars-settings-tabs .onoffswitch {
                    margin-right: 3px !important;
                }
            }
            
            #xtrars-settings-tabs {
                height: 30px; 
                width: 100%;
                background-color: #12a6f6; 
                color: white; 
                line-height: 33px; 
                overflow: clip
            }
            
            #xtrars-settings-tabs .onoffswitch {
                float: right;
                margin-right: 10px;
                width: 30px !important;
                min-width: 30px !important;
                display: inline-block;
            }
            
            #xtrars-settings-tabs .xtrars-indicator {
                box-shadow: none;
                background: #ecf0f3;
            }
            
            #xtrars-settings-tabs .xtrars-toggle {
                display: inline-block;
                isolation: isolate;
                position: relative;
                height: 14px;
                width: 30px;
                border-radius: 7px;
                overflow: hidden;
                box-shadow: none;
                outline: #ecf0f3 1px solid;
            }
            
            #xtrars-settings-tabs .xtrars-toggle-state:checked ~ .xtrars-indicator span {
                transform: translateX(2px) translateY(-28%);
                color: white;
            }          
              
            #xtrars-settings-tabs .xtrars-toggle-state ~ .xtrars-indicator span {
                transition: transform .4s cubic-bezier(0.85, 0.05, 0.18, 1.35);
                transform: translateX(47px) /*60 (indicator) - 11 (own width) - 2 (same space to borders as active state)*/ translateY(-28%);
                font-size: 10px;
                width: 11px;
                position: absolute;
                color: white;
                text-align: center;
            }
            
            #xtrars-settings-tabs .xtrars-toggle-state:checked ~ .xtrars-indicator {
                background-color: #0D4F8B;
            }
            
            #xtrars-settings-tabs .xtrars-toggle-state ~ .xtrars-indicator {
                background-color: #d06e6e;
            }
                                   
            .disabled .xtrars-indicator {
                background: #ecf0f3;
            }
            
            .xtrars-toggle-state:checked ~ .xtrars-indicator {
                transform: translate3d(25%, 0, 0);
            }
            
            /*Thanks to Aaron Iker https://codepen.io/aaroniker/pen/XyXzYp*/
            .xtrars-search {
                display: inline-table;
                float: right;
                margin-right: 10px;
                margin-top: 2px;
            }
            .xtrars-search input {
                box-shadow: none;
                border-radius: 0;
                -moz-border-radius: 0;
                -webkit-border-radius: 0;
                background: none;
                border: none;
                outline: none;
                width: 14px;
                min-width: 0;
                padding: 0;
                z-index: 1;
                position: relative;
                line-height: 10px;
                margin: 8px 0;
                font-size: 11px;
                -webkit-appearance: none;
                transition: all .6s ease;
                cursor: pointer;
                color: #fff;
            }
            .xtrars-search input + div {
                position: relative;
                height: 14px;
                width: 100%;
                margin: -21px 0 0 0;
            }
            .xtrars-search input + div svg {
                display: block;
                position: absolute;
                height: 14px;
                width: 79px;
                right: 0;
                top: 0;
                fill: none;
                stroke: #fff;
                stroke-width: 1px;
                stroke-dashoffset: 271.908;
                stroke-dasharray: 59 212.908;
                transition: all .6s ease;
            }
            .xtrars-search input:not(:-ms-input-placeholder) {
                width: 80px;
                padding: 0 4px;
                cursor: text;
            }
            .xtrars-search input:not(:placeholder-shown), .xtrars-search input:focus {
                width: 80px;
                padding: 0 4px;
                cursor: text;
            }
            .xtrars-search input:not(:placeholder-shown) + div svg {
                stroke-dasharray: 150 212.908;
                stroke-dashoffset: 300;
            }
            .xtrars-search input:not(:-ms-input-placeholder) + div svg {
                stroke-dasharray: 150 212.908;
                stroke-dashoffset: 300;
            }
            .xtrars-search input:not(:placeholder-shown) + div svg, .xtrars-search input:focus + div svg {
                stroke-dasharray: 150 212.908;
                stroke-dashoffset: 300;
            }
            
            @media (max-width: 320px) {
                .xtrars-update-button span {
                    display: none;
                }
                
                .xtrars-update-button .icon {
                    margin-right: 0 !important;
                }
            }

            .xtrars-update-button {
                display: inline-flex;
                align-items: center;
                background-color: #007bff; /* Same blue color as in the image */
                color: white;
                padding: 10px 15px;
                border-radius: 5px;
                height: 30px;
                font-size: 13px;
                text-decoration: none;
                transition: background-color 0.3s ease;
            }
            
            .xtrars-update-button .icon {
                width: 20px;
                height: 20px;
                margin-right: 10px;
            }
            
            #xtrars-settings-close-btn {
                user-select: none; 
                float: right; 
                margin-top: 6px; 
                background-color: transparent; 
                border: none; 
                margin-right: 10px; 
                cursor: pointer; 
                font-weight: bolder; color: white;
            }
            `.replace('<style>', '');
        document.head.appendChild(oStyle);
    }

    /**
     Creates a button element and appends it to the document.
     It waits for the element with class "infos" to be loaded and then appends the button to it as the first child.
     @async
     @returns {Promise<void>} A promise that resolves when the button is successfully added to the document.
     */
    async buildButton() {
        const oButton = document.createElement("div");
        oButton.id = 'xtrars-btn';
        oButton.innerHTML = '<i id="xtrars-btn-icon"></i>';
        await this.waitForElement('.infos').catch(() => null);
        document.getElementsByClassName('infos')[0]
            .insertBefore(oButton, document.getElementsByClassName('infos')[0].firstChild);

        if (GM_getValue('bFirstStart')) {
            GM_setValue('bFirstStart', false);
            oButton.style.animation = 'shake 1s ease 1s 1 normal;'
        }
    }

    /**
     This method builds the settings window that is displayed when the settings button is clicked. It creates and
     appends various DOM elements to the settings window such as tabs, checkboxes, and labels.
     */
    buildSettingsWindow() {
        const oSettingsWindow = document.createElement("div");
        oSettingsWindow.innerHTML = `
            <div id="xtrars-settings-toolbar">
                <div class="xtrars-toolbar-text">BETSLIX - Settings</div>
                <button id="xtrars-settings-close-btn">✕</button>
                
                <div class="xtrars-search">
                    <input class="xtrars-search-input" type="text" placeholder=" ">
                <div>
                        <svg>
                            <use xlink:href="#path">
                        </svg>
                    </div>
                </div>
                    
                <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
                    <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 28" id="path">
                        <path d="M32.9418651,-20.6880772 C37.9418651,-20.6880772 40.9418651,-16.6880772 40.9418651,-12.6880772 C40.9418651,-8.68807717 37.9418651,-4.68807717 32.9418651,-4.68807717 C27.9418651,-4.68807717 24.9418651,-8.68807717 24.9418651,-12.6880772 C24.9418651,-16.6880772 27.9418651,-20.6880772 32.9418651,-20.6880772 L32.9418651,-29.870624 C32.9418651,-30.3676803 33.3448089,-30.770624 33.8418651,-30.770624 C34.08056,-30.770624 34.3094785,-30.6758029 34.4782612,-30.5070201 L141.371843,76.386562" transform="translate(83.156854, 22.171573) rotate(-225.000000) translate(-83.156854, -22.171573)"></path>
                    </symbol>
                </svg>            
            </div>
            <div id="xtrars-settings-tabs">                
                <button 
                    class="tab xtrars-settings-tabs ${GM_getValue('sLastActiveTab') === 'BS' || GM_getValue('sLastActiveTab') === '' ? 'xtrars-active' : ''}" 
                    data-tab="BS">BS
                </button>
                <button 
                    class="tab xtrars-settings-tabs ${GM_getValue('sLastActiveTab') === 'Streaming' ? 'xtrars-active' : ''}" 
                    data-tab="Streaming">Streaming
                </button>
                <button 
                    class="tab xtrars-settings-tabs ${GM_getValue('sLastActiveTab') === 'Info' ? 'xtrars-active' : ''}" 
                    data-tab="Info">Info
                </button>
                
                <div class="onoffswitch">
                    <label class="onoffswitch-label" data-search="">
                        <div class="xtrars-toggle">
                            <input class="onoffswitch-checkbox xtrars-onoffswitch xtrars-toggle-state" 
                            type="checkbox" name="xtrars-onoffswitch" value="check" />
                            <div class="xtrars-indicator">
                                <span class="xtrars-power-symbol">&#x23FB;</span>
                            </div>
                        </div>
                    </label>
                </div>
  
                <a href="https://update.greasyfork.org/scripts/429666/BETSLIX%20-%20burning%20series%20enhancer.user.js" rel="nofollow" class="tab xtrars-update-button">
                    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC40lEQVR4nO2Zy2oUQRSGSxPjdZOgwYjGN/ASkRAQ3LgwLsQRQdciivGyUBQvKAgJbhIwER9BRUVEEi/vIC4mKi4UI06MTLwhgia6+OTgCXSKms70TJVQ0h8MDNVT5++/e6rq1CljcnJycrIAzAc2A+eBO8Az4BMwDfwCvgCjwF3gDNApfUxogF3AJFAGdqb8rh3oBSbIzjugD1gV0sj7hOC443orcFWfeL1MAUNAcwgjs7Cu7QU+4p9JoBDcCNAIXEu5kW/ADeCAjpcVQBOwQL9L22HgIfAzJc4Q0BDECLAIeFRB+BWwH1iSIf5SoMf6Cye5DywMYWTE0fYDOCVvqg6dxTqLucbavXpiVzJi8xpYV5fIbL0umVQcOgMhjRRl1vJlIqG5Enjh0CuEfCMzjAHdHs2sdaxJH4CW0EaEki8jArBJ15Yk/SY2IwJw2dKQ6brNZCWDiTfA9swCc+svcwz+CyZGgOP2QzMxwt9sQDLnJOtNjAAPLCMnTIwAxywj102MAFssI09MjABrLCMTWTpv06z0M7Av6J1Wt4UuJ4wUs3R+mej41dveoEaA3Zq2SDq0NUtHO9dZbWIEeGoZ6TIxAty0jPSYGAFOWkaGTYwAGywjv0NspIIDzAPeWmaOmhgBLlpGSpJaB9DZodNqVdQi0OaoPfUFMOIqOFSkVpF+K45sPzs8G5E3XTWmRpEW3fgnkcWy3aORbt1lhjOiQgVHvOdSuvFlxioHjQYxogIDjpjjPld8YGM1g75ekUYtX9pImfNslpqvI7YUuc9VKGoPezWSEJTCsgsZN0ekMJ2xSnIwZXyMSBHbuxEVbwAGU968zGqP1VSnHgY16Q21atsh4DbwPSXO4EzxOogRawKQQxnflIE9llY4IyrQDFxxlDZrYUpjLXfojP2TupZOmb2O3KwaZDG8JPvyOdaZkn68VzQrJZpytHZaj6eLuuef1ic+qW239GCnQ/oEv7GcnJz/iz/Wmk6MdR/K1gAAAABJRU5ErkJggg==" alt="Update Icon" class="icon">
                    <span>Update</span>
                </a>
            </div>
            <!-- Tab content -->
            <div id="BS" class="xtrars-tabcontent" style="display: block; overflow: auto;">
                <div class="onoffswitch">
                    <label class="onoffswitch-label"
                        data-search="nächste,folgende,episode,wird,zufällig,abgespielt">
                        <div class="xtrars-toggle">
                            <input class="onoffswitch-checkbox xtrars-onoffswitch xtrars-toggle-state" 
                            type="checkbox" name="xtrars-onoffswitch" value="check" />
                            <div class="xtrars-indicator"></div>
                        </div>
                    </label>
                    <div class="label-wrapper">
                        <span class="onoffswitch-inner auto-random-episode">
                            <span>Nächste <strong>folgende</strong> Episode wird abgespielt</span>
                            <span>Nächste Episode wird <strong>zufällig</strong> abgespielt</span>
                        </span>
                    </div>
                </div>
                <div class="onoffswitch">
                    <label class="onoffswitch-label"
                        data-search="nächste,staffel,wird,automatisch,manuell,abgespielt">
                        <div class="xtrars-toggle">
                            <input class="onoffswitch-checkbox xtrars-onoffswitch xtrars-toggle-state" 
                            type="checkbox" name="xtrars-onoffswitch" value="check" />
                            <div class="xtrars-indicator"></div>
                        </div>
                    </label>
                    <div class="label-wrapper">
                        <span class="onoffswitch-inner auto-next-season">
                            <span>Nächste Staffel wird <strong>automatisch</strong> abgespielt</span>
                            <span>Nächste Staffel wird <strong>manuell</strong> abgespielt</span>
                        </span>
                    </div>
                </div>
                <div class="onoffswitch">
                    <label for="xtrars-onoffswitch" class="onoffswitch-label"
                        data-search="wechselt,zum,${this.getHoster(0, true)},${this.getHoster(1, true)},${this.getHoster(2, true)},${this.getHoster(3, true)},tab" 
                        style="font-size: 11px; float: left; height: 21px; padding-top: 4px;">
                        Wechselt zum
                        <select name="" class="xtrars-select xtrars-onoffswitch" style="width: 100px; max-width: 40%">
                            <option value="${this.getHoster(3, true)}">
                                ${this.getHoster(3, false)}
                            </option>
                            <option value="${this.getHoster(0, true)}">
                                ${this.getHoster(0, false)}
                            </option>
                            <option value="${this.getHoster(1, true)}">
                                ${this.getHoster(1, false)}
                            </option>
                            <option value="${this.getHoster(2, true)}">
                                ${this.getHoster(2, false)}
                            </option>
                        </select>
                        -Tab
                    </label>
                </div>
            </div>
            
            <div id="Streaming" class="xtrars-tabcontent">
                <div class="onoffswitch">
                    <label class="onoffswitch-label"
                        data-search="video,überspringt,ueberspringt,uberspringt,x,sekunden,anfang,spielt,von,überspringen,ueberspringen,uberspringen">
                        <div class="xtrars-toggle">
                            <input class="onoffswitch-checkbox xtrars-onoffswitch xtrars-toggle-state" type="checkbox" 
                                name="xtrars-onoffswitch" value="check" />
                            <div class="xtrars-indicator"></div>
                        </div>
                    </label>
                    <div class="label-wrapper">
                        <span class="onoffswitch-inner skip-start">
                            <span>Anfang des Videos wird <strong>x Sekunden übersprungen</strong></span>
                            <span>Video spielt <strong>von Anfang an</strong></span>
                        </span>
                         <input class="skip-start" type="text"
                        size="3" maxlength="3" 
                        value="${isNaN(GM_getValue('iSkipStartTime')) ? '' : GM_getValue('iSkipStartTime')}">
                    </div>
                </div>
                <div class="onoffswitch">
                    <label class="onoffswitch-label"
                        data-search="video,wird,x,sekunden,vor,ende,beendet,spielt,bis,zum,überspringen,ueberspringen,uberspringen,überspringt,ueberspringt,uberspringt">
                        <div class="xtrars-toggle">
                            <input class="onoffswitch-checkbox xtrars-onoffswitch xtrars-toggle-state" type="checkbox" 
                                name="xtrars-onoffswitch" value="check" />
                            <div class="xtrars-indicator"></div>
                        </div>
                    </label>
                    <div class="label-wrapper">
                        <span class="onoffswitch-inner skip-end">
                            <span>Video wird <strong>x Sekunden vor Ende</strong> beendet</span>
                
                        <span>Video spielt <strong>bis zum Ende</strong></span></span>
                         <input class="skip-end" type="text"
                        size="3" maxlength="3" 
                        value="${isNaN(GM_getValue('iSkipEndTime')) ? '' : GM_getValue('iSkipEndTime')}">
                    </div>
                </div>
            </div>
            
            <div id="Info" class="xtrars-tabcontent" style="font-size: 11px;">
                <div  class="xtrars-donation-container">
                    <div class="xtrars-donation-text">
                        <span style="font-weight: bold;">BETSLIX - burning series enhancer by xtrars</span> <br> 
                        Du magst meine Arbeit und das Projekt erleichtert dir dein Streaming-Leben? 
                        Dann gib mir doch ein leckeren Tee aus, denn so kann das Projekt immer weiter optimiert werden
                        und am Leben bleiben:
                        <a class="xtrars-donate" href="https://www.paypal.com/donate/?hosted_button_id=H76K9EAMTW7X8" 
                            target="_blank">Spenden</a>
                        Danke dir :)
                    </div>
                    <i id="xtrars-pp-qr"></i>
                </div>
            </div>
        `;
        oSettingsWindow.style.cssText = 'display: none;';
        oSettingsWindow.id = 'xtrars-settings-window';
        oSettingsWindow.classList.add('run-circleToWindow-animation');
        document.getElementById('root')?.appendChild(oSettingsWindow);
    }

    /**
     Handles the start of the drag operation on the settings window.
     @param {MouseEvent|TouchEvent} o - The event object for the drag start.
     */
    dragStart(o) {
        document.settingsWindowActive = true;
        let oSettingsWindow = document.getElementById('xtrars-settings-window');
        let iSettingsWindowLeft = parseInt(window.getComputedStyle(oSettingsWindow).left);
        let iSettingsWindowTop = parseInt(window.getComputedStyle(oSettingsWindow).top);

        if (o.type === "touchstart" && o.touches?.length) {
            document.settingsWindowInitialX = o.touches[0].clientX - iSettingsWindowLeft;
            document.settingsWindowInitialY = o.touches[0].clientY - iSettingsWindowTop;
        }
        else {
            document.settingsWindowInitialX = o.clientX - iSettingsWindowLeft;
            document.settingsWindowInitialY = o.clientY - iSettingsWindowTop;
        }
    }

    /**
     Handles the end of the drag operation on the settings window.
     */
    dragEnd() {
        document.settingsWindowActive = false;
        let oSettingsWindow = document.getElementById('xtrars-settings-window');
        let iPixels = 2;
        let iPositionInterval = setInterval(() => {
            if (parseInt(window.getComputedStyle(oSettingsWindow).left) <= 0) {
                oSettingsWindow.style.left = parseInt(oSettingsWindow.style.left) + iPixels + 'px';
            }
            else if (parseInt(window.getComputedStyle(oSettingsWindow).top) <= 0) {
                oSettingsWindow.style.top = parseInt(oSettingsWindow.style.top) + iPixels + 'px';
            }
            else if (parseInt(window.getComputedStyle(oSettingsWindow).right) <= 0) {
                oSettingsWindow.style.left = parseInt(oSettingsWindow.style.left) - iPixels + 'px';
            }
            else if (parseInt(window.getComputedStyle(oSettingsWindow).bottom) <= 0) {
                oSettingsWindow.style.top = parseInt(oSettingsWindow.style.top) - iPixels + 'px';
            }
            else {
                clearInterval(iPositionInterval);
                if (oSettingsWindow.style.top !== '' && oSettingsWindow.style.left !== '') {
                    GM_setValue('oSettingsWindowPosition', {
                        x: oSettingsWindow.style.left,
                        y: oSettingsWindow.style.top,
                    });
                }
            }
        }, 1);
    }

    /**
     Handles the dragging of the settings window.
     @param {Event} o - The event object for the drag.
     */
    drag(o) {
        if (!document.settingsWindowActive) return;

        o.preventDefault();

        let oSettingsWindow = document.getElementById('xtrars-settings-window');
        let iCurrentX;
        let iCurrentY;
        if (o.type === "touchmove") {
            iCurrentX = (o.touches[0].clientX - document.settingsWindowInitialX);
            iCurrentY = (o.touches[0].clientY - document.settingsWindowInitialY);
        }
        else {
            iCurrentX = (o.clientX - document.settingsWindowInitialX);
            iCurrentY = (o.clientY - document.settingsWindowInitialY);
        }

        oSettingsWindow.style.top = iCurrentY + 'px';
        oSettingsWindow.style.left = iCurrentX + 'px';
    }

    /**
     Shows the settings window.
     */
    showSettingsWindow(bWithSlideIn = false) {
        const oSettingsWindow = document.getElementById('xtrars-settings-window');


        if (bWithSlideIn) {
            this.#slideInAndOpenOrSlideOutAndCloseWindow();
            oSettingsWindow.classList.remove('run-windowToCircle-animation');
            oSettingsWindow.classList.add('run-circleToWindow-animation');
        }

        // Vorher schonmal setzen, damit korrekte Breite und Höhe berechnet werden kann
        oSettingsWindow.style.cssText = `height: ${this.#nSettingsWindowHeight}px; width: ${this.#nSettingsWindowWidth}px; max-width: calc(100% - 5px); 
            max-height: calc(100% - 5px); display: block; position: fixed;`;
        oSettingsWindow.style.cssText = `height: ${this.#nSettingsWindowHeight}px; width: ${this.#nSettingsWindowWidth}px; max-width: calc(100% - 5px); 
            max-height: calc(100% - 5px); display: block; position: fixed; 
            top: ${GM_getValue('oSettingsWindowPosition').y ?? "calc(50% - " + (parseInt(window.getComputedStyle(oSettingsWindow).height) / 2) + "px)"};
            left: ${GM_getValue('oSettingsWindowPosition').x ?? "calc(50% - " + (parseInt(window.getComputedStyle(oSettingsWindow).width) / 2) + "px)"};
            background-color: #fdfdfd; box-shadow: rgba(0, 0, 0, .4) 1px 1px 10px 5px; z-index: 161;`

        if (!GM_getValue('bIsSettingsWindowOpen')) {
            this.restartAnimation(oSettingsWindow);
        }

        document.addEventListener("touchmove", this.drag, {passive: false});
        document.addEventListener("mousemove", this.drag, {passive: false});

        GM_setValue('bIsSettingsWindowOpen', true);
        GM_setValue('oSettingsWindowPosition', {
            x: window.getComputedStyle(oSettingsWindow).left,
            y: window.getComputedStyle(oSettingsWindow).top,
        });
    }

    /**
     Shows the content of the specified tab.
     @param {string} sTab - The ID of the tab to show.
     */
    showTabContent(sTab) {
        let oTabContent = document.querySelectorAll('.xtrars-tabcontent');
        oTabContent.forEach(oItem => {
            oItem.style.display = 'none';
        });

        document.getElementById(sTab).style.display = 'block';
        GM_setValue('sLastActiveTab', sTab);
    }

    /**
     Initializes the events and buttons that appear in the extension.
     */
    initEvents() {
        const oButton = document.getElementById('xtrars-btn');
        const oToolbar = document.getElementById('xtrars-settings-toolbar');
        const oSettingsWindow = document.getElementById('xtrars-settings-window');
        const oTabs = document.querySelectorAll('.xtrars-settings-tabs');

        const oActivateEnhancer = document.querySelector('#xtrars-settings-tabs .xtrars-onoffswitch');

        const oBsCheckboxes = document.querySelectorAll('#BS .xtrars-onoffswitch');
        const oStreamingCheckboxes = document.querySelectorAll('#Streaming .xtrars-onoffswitch');

        const oAutoplayRandomEpisode = oBsCheckboxes[0]; //auto-random-episode
        const oAutoplayNextSeason = oBsCheckboxes[1]; //auto-next-season
        const oSelectHoster = oBsCheckboxes[2]; // select-hoster

        const oSkipStart = oStreamingCheckboxes[0]; //skip-start
        const oSkipEnd = oStreamingCheckboxes[1]; //skip-end

        const oSkipStartInput = document.querySelector('input.skip-start');
        const oSkipEndInput = document.querySelector('input.skip-end');

        const oSearchInput = document.querySelector('.xtrars-search-input');

        oTabs.forEach(oItem => {
            oItem.addEventListener('click', e => {
                oTabs.forEach(oTab => {
                    oTab.classList.remove('xtrars-active');
                });
                e.target.classList.add('xtrars-active');
                this.showTabContent(e.target.dataset.tab);
            });
        });
        //
        // oUpdate.addEventListener('click', () => {
        //     window.open('https://update.greasyfork.org/scripts/429666/BETSLIX%20-%20burning%20series%20enhancer.user.js')
        // })

        // Öffne Settings
        !oButton || oButton.addEventListener('click', () => {

            if (this.#bButtonDisabled === true) return;

            this.#bButtonDisabled = true;
            setTimeout(() => {
                this.#bButtonDisabled = false;
            }, 500);

            if (GM_getValue('bIsSettingsWindowOpen') === true) {
                this.#closeSettingsWindow(oSettingsWindow);
            }
            else {
                this.showSettingsWindow(true);
                if (GM_getValue('bFirstStart')) {
                    GM_setValue('bFirstStart', false);
                    document.getElementsByClassName('xtrars-switch')[0].style.animation = 'shake 1s ease 1s 1 normal;'
                }
                document.addEventListener("touchmove", this.drag, {passive: false});
                document.addEventListener("mousemove", this.drag, {passive: false});
            }
        });

        !oToolbar || oToolbar.addEventListener("touchstart", this.dragStart, {passive: false});
        !oToolbar || oToolbar.addEventListener("mousedown", this.dragStart, {passive: false});
        document.addEventListener("touchend", this.dragEnd, {passive: false});
        document.addEventListener("mouseup", this.dragEnd, {passive: false});
        document.addEventListener("contextmenu", this.dragEnd, {passive: false});

        // Schließe Settings
        if (document.getElementById('xtrars-settings-close-btn')) {
            document.getElementById('xtrars-settings-close-btn').addEventListener('click', () => {
                this.#closeSettingsWindow(oSettingsWindow);
            });
        }


        let oManagedButtons = {
            'activateEnhancer': oActivateEnhancer,
            'autoplayRandomEpisode': oAutoplayRandomEpisode,
            'autoplayNextSeason': oAutoplayNextSeason,
            'selectHoster': oSelectHoster,
            'skipStart': oSkipStart,
            'skipEnd': oSkipEnd,
        };

        this.manageButtonState(oManagedButtons);

        !oActivateEnhancer || oActivateEnhancer.addEventListener('change', () => {
            GM_setValue('bActivateEnhancer', oActivateEnhancer ? oActivateEnhancer.checked : false);
            this.manageButtonState(oManagedButtons);
            this.reload();
        });

        !oAutoplayRandomEpisode || oAutoplayRandomEpisode.addEventListener('change', () => {
            GM_setValue('bAutoplayRandomEpisode', oAutoplayRandomEpisode ? !oAutoplayRandomEpisode.checked : false);
            this.manageButtonState(oManagedButtons);
        });

        !oAutoplayNextSeason || oAutoplayNextSeason.addEventListener('change', () => {
            GM_setValue('bAutoplayNextSeason', oAutoplayNextSeason ? oAutoplayNextSeason.checked : false);
        });

        !oSelectHoster || oSelectHoster.addEventListener('change', () => {
            GM_setValue('bSelectHoster', oSelectHoster.value);
        });

        !oSkipStart || oSkipStart.addEventListener('change', () => {
            GM_setValue('bSkipStart', oSkipStart ? oSkipStart.checked : false);
            let oSkipStartInput = document.querySelector('input.skip-start');
            (oSkipStart ? oSkipStart.checked : false) ?
                oSkipStartInput.style.display = "block" :
                oSkipStartInput.style.display = "none";
        });

        !oSkipEnd || oSkipEnd.addEventListener('change', () => {
            GM_setValue('bSkipEnd', oSkipEnd ? oSkipEnd.checked : false);
            let oSkipEndInput = document.querySelector('input.skip-end');
            (oSkipEnd ? oSkipEnd.checked : false) ?
                oSkipEndInput.style.display = "block" :
                oSkipEndInput.style.display = "none";
        });

        !oSkipEndInput || oSkipEndInput.addEventListener('keyup', (e) => {
            e.target.value = isNaN(parseInt(e.target.value)) ? '' : parseInt(e.target.value);
            GM_setValue('iSkipEndTime', parseInt(e.target.value));
        });

        !oSkipStartInput || oSkipStartInput.addEventListener('keyup', (e) => {
            e.target.value = isNaN(parseInt(e.target.value)) ? '' : parseInt(e.target.value);
            GM_setValue('iSkipStartTime', parseInt(e.target.value));
        });


        let iPixels = 2;
        window.addEventListener('resize', () => {
            let iPositionInterval = setInterval(() => {
                if (parseInt(window.getComputedStyle(oSettingsWindow).left) <= 0) {
                    oSettingsWindow.style.left = parseInt(oSettingsWindow.style.left) + iPixels + 'px';
                }
                else if (parseInt(window.getComputedStyle(oSettingsWindow).top) <= 0) {
                    oSettingsWindow.style.top = parseInt(oSettingsWindow.style.top) + iPixels + 'px';
                }
                else if (parseInt(window.getComputedStyle(oSettingsWindow).right) <= 0) {
                    oSettingsWindow.style.left = parseInt(oSettingsWindow.style.left) - iPixels + 'px';
                }
                else if (parseInt(window.getComputedStyle(oSettingsWindow).bottom) <= 0) {
                    oSettingsWindow.style.top = parseInt(oSettingsWindow.style.top) - iPixels + 'px';
                }
                else {
                    clearInterval(iPositionInterval);
                }
            }, 1);
        });

        !oSearchInput || oSearchInput.addEventListener('keyup', this.search);
        !oSearchInput || oSearchInput.addEventListener('mousemove', (e) => e.stopPropagation());
        !oSearchInput || oSearchInput.addEventListener('mousedown', (e) => e.stopPropagation());
        !oSkipStartInput || oSkipStartInput.addEventListener('mousemove', (e) => e.stopPropagation());
        !oSkipEndInput || oSkipEndInput.addEventListener('mousemove', (e) => e.stopPropagation());

        // Label-Workaround
        document.querySelectorAll('input[type="checkbox"][class~="onoffswitch-checkbox"]')
            .forEach(oElement => {
                labelWorkaround(oElement);
                oElement.addEventListener('change', o => {
                    labelWorkaround(o.target)
                });
            });

        function labelWorkaround(oElement) {
            let oInputTextElement = oElement.closest('.onoffswitch').querySelector('.label-wrapper > .onoffswitch-inner');

            if (!oInputTextElement) return;

            if (oElement.checked) {
                oInputTextElement.classList.add('workaroundChecked');
            }
            else {
                oInputTextElement.classList.remove('workaroundChecked');
            }
        }
    }

    /**
     This function searches for a keyword in a list of elements and highlights the matching elements with a red dashed outline.
     It also highlights the corresponding tab of the matched element with a red color.
     The search is case-insensitive and supports searching for multiple words separated by spaces.
     @param {Event} o - The event object passed to the function, which contains the search keyword in its target value.
     @returns {void}
     */
    search(o) {
        let bHasSearchWord;
        let iIndex = -1;
        let iTabIndex = 0;
        let oTabs = document.querySelectorAll('.xtrars-settings-tabs');

        for (const oTab of oTabs) {
            oTab.style.removeProperty('color');
        }

        for (const oElement of document.querySelectorAll('.onoffswitch-label')) {
            oElement.style.removeProperty('outline');
            bHasSearchWord = true;
            for (const sSearchWord of o.target.value.toLowerCase().split(' ').filter((s) => s !== '')) {
                let aSearchKeywords = oElement.dataset.search.toLowerCase().split(',')
                iIndex = 0;
                for (const sSearchKeyword of aSearchKeywords) {
                    iIndex++;
                    if (bHasSearchWord && sSearchKeyword.includes(sSearchWord)) {
                        break;
                    }
                    if (iIndex >= aSearchKeywords.length) {
                        oElement.style.removeProperty('outline');
                        bHasSearchWord = false;
                    }
                }
            }
            if (bHasSearchWord && iIndex !== -1) {
                oElement.style.setProperty('outline', '1px dashed red', 'important');
                let sTab = oElement.parentElement.parentElement.getAttribute('id');
                for (const oTab of oTabs) {
                    if (sTab === oTab.dataset.tab) {
                        oTab.style.color = 'red';
                        if (iTabIndex === 0) {
                            oTab.click();
                        }
                        iTabIndex++;
                    }
                }
            }
        }
    }

    /**
     Manages the state of the buttons in the setting window.
     @param {Object} oManagedButtons - The object containing the list of all the managed buttons.
     */
    manageButtonState(oManagedButtons) {
        let oActivateEnhancer = oManagedButtons.activateEnhancer;
        let oAutoplayRandomEpisode = oManagedButtons.autoplayRandomEpisode;
        let oAutoplayNextSeason = oManagedButtons.autoplayNextSeason;
        let oSelectHoster = oManagedButtons.selectHoster;
        let oSkipStart = oManagedButtons.skipStart;
        let oSkipEnd = oManagedButtons.skipEnd;

        !oActivateEnhancer || (oActivateEnhancer.checked = GM_getValue('bActivateEnhancer'));
        !oAutoplayRandomEpisode || (oAutoplayRandomEpisode.checked = !GM_getValue('bAutoplayRandomEpisode'));
        !oAutoplayNextSeason || (oAutoplayNextSeason.checked = GM_getValue('bAutoplayNextSeason'));
        !oSelectHoster || (oSelectHoster.value = GM_getValue('bSelectHoster'));
        !oSkipStart || (oSkipStart.checked = GM_getValue('bSkipStart'));
        !oSkipEnd || (oSkipEnd.checked = GM_getValue('bSkipEnd'));

        let oSkipStartInput = document.querySelector('input.skip-start');
        !oSkipStart || (oSkipStart.checked ? oSkipStartInput.style.display = "block" : oSkipStartInput.style.display = "none");
        let oSkipEndInput = document.querySelector('input.skip-end');
        !oSkipEnd || (oSkipEnd.checked ? oSkipEndInput.style.display = "block" : oSkipEndInput.style.display = "none");

        if (oActivateEnhancer ? !oActivateEnhancer.checked : false) {
            this.disableButton(oAutoplayNextSeason);
            this.disableButton(oAutoplayRandomEpisode);
            this.disableButton(oSelectHoster);
            this.disableButton(oSkipStart);
            this.disableButton(oSkipEnd);
            oSkipStartInput.style.display = "none";
            oSkipEndInput.style.display = "none";
        }
        else {
            this.enableButton(oSelectHoster);
            this.enableButton(oAutoplayRandomEpisode);
            this.enableButton(oSelectHoster);
            this.enableButton(oSkipStart);
            this.enableButton(oSkipEnd);
            !oSkipStart || (oSkipStart.checked ? oSkipStartInput.style.display = "block" : oSkipStartInput.style.display = "none");
            !oSkipEnd || (oSkipEnd.checked ? oSkipEndInput.style.display = "block" : oSkipEndInput.style.display = "none");

            if (oAutoplayRandomEpisode ? !oAutoplayRandomEpisode.checked : false) {
                this.disableButton(oAutoplayNextSeason);
            }
            else {
                this.enableButton(oAutoplayNextSeason);
            }
        }
    }

    /**
     Disables a given settings slider.
     @param {Element} oElement - The element to be disabled.
     */
    disableButton(oElement) {
        if (!oElement) return;

        if (oElement && oElement.parentElement.childNodes[3] &&
            oElement.parentElement.childNodes[3].childNodes[1] &&
            oElement.parentElement.childNodes[3].childNodes[1].classList.contains('auto-next-episode')) {
            this.playNextEpisodeIfVideoEnded(false);
        }

        oElement.classList.add('disabled');
        oElement.parentElement.classList.add('disabled');
        oElement.disabled = true;
    }

    /**
     Enables a given settings slider.
     @param {Element} oElement - The element to be enabled.
     */
    enableButton(oElement) {
        if (!oElement) return;

        oElement.classList.remove('disabled');
        oElement.parentElement.classList.remove('disabled');
        oElement.disabled = false
    }

    /**
     Skips the unavailable hosters.
     @async
     @param {Array} aHosterOrder - The list of hosters to try in the given order.
     @returns {Promise} A Promise that resolves when all unavailable hosters have been skipped.
     */
    async skipUnavailable(aHosterOrder) {
        let oHoster = await this.waitForElement(`.hoster-tabs .hoster.${aHosterOrder[0]}`, false);
        if (oHoster !== null) {
            document.location.replace(document.location.href + '/' + aHosterOrder[0]);
        }
        else {
            oHoster = await this.waitForElement(`.hoster-tabs .hoster.${aHosterOrder[1]}`, false);
            if (oHoster !== null) {
                document.location.replace(document.location.href + '/' + aHosterOrder[1]);
            }
            else {
                document.location.replace(document.location.href + '/' + aHosterOrder[2]);
            }
        }
    }

    /**
     Handles the video element for the given streaming hoster.
     @async
     @param {string} sActiveTab - The active tab.
     @param {Array} aToBeChecked - An array of regular expressions to check against.
     @returns {Promise<void>} A Promise that resolves after the video element is handled.
     */
    async handleBsVideo(sActiveTab, aToBeChecked) {
        for (const regexHoster of aToBeChecked) {
            if (regexHoster.test(sActiveTab)) {
                let oIframe = await this.waitForElement('section.serie .hoster-player > iframe');
                let sSrc = oIframe.src;
                window.open(sSrc, '_blank').focus();
                oIframe.remove();
                let oHosterPlayer = await this.waitForElement('.hoster-player');
                oHosterPlayer.innerHTML = `
                    <h2 class="">Dein Stream ist jetzt bereit</h2>
                    <div class="play" style="display: none;"></div>
                    <div class="loading" style="display: none;">
                        <div class="wrapper">
                            <div class="line"></div>
                        </div>
                        <div class="wrapper">
                            <div class="line"></div>
                        </div>
                        <div class="wrapper">
                            <div class="line"></div>
                        </div>
                        <div class="wrapper">
                            <div class="line"></div>
                        </div>
                        <div class="wrapper">
                            <div class="line"></div>
                        </div>
                    </div>
                    <a href="${sSrc}" target="_blank" rel="noreferrer">${sSrc}</a>
                `;
                break;
            }
        }
    }

    #slideInAndOpenOrSlideOutAndCloseWindow() {
        const rStartX = /(?<=@keyframes\s*xtrarsSlideIn\s*{\s*?0%\s*{transform: translate\()-?(0|\d+(\.|\d)*?px)/;
        const rStartY = /(?<=@keyframes\s*xtrarsSlideIn\s*{\s*0%\s*{transform: translate\(-?\d+(\.|\d)*(px)?,\s?)-?(0|\d+(\.|\d)*?px)/;
        const rHalfWayX = /(?<=@keyframes\s*xtrarsSlideIn\s*{(\s|.)*?40%\s*{transform: translate\()-?(0|\d+(\.|\d)*?px)/;
        const rHalfWayY = /(?<=@keyframes\s*xtrarsSlideIn\s*{(\s|.)*?40%\s*{transform: translate\(-?\d+(\.|\d)*px,\s?)-?(0|\d+(\.|\d)*?px)/;
        const rBeforeEndX = /(?<=@keyframes\s*xtrarsSlideIn\s*{(\s|.)*?99.99%\s*{transform: translate\()-?(0|\d+(\.|\d)*?px)/;
        const rBeforeEndY = /(?<=@keyframes\s*xtrarsSlideIn\s*{(\s|.)*?99.99%\s*{transform: translate\(-?\d+(\.|\d)*(px)?,\s?)-?(0|\d+(\.|\d)*?px)/;
        const rEndX = /(?<=@keyframes\s*xtrarsSlideIn\s*{(\s|.)*?100%\s*{transform: translate\()-?(0|\d+(\.|\d)*?px)/;
        const rEndY = /(?<=@keyframes\s*xtrarsSlideIn\s*{(\s|.)*?100%\s*{transform: translate\(-?\d+(\.|\d)*(px)?,\s?)-?(0|\d+(\.|\d)*?px)/;

        const oXtrarsBtn = document.getElementById('xtrars-btn');

        const oXtrarsBtnCoords = oXtrarsBtn?.getBoundingClientRect();
        const nXtrarsBtnWidth = oXtrarsBtn.getBoundingClientRect().width;
        const oXtrarsStyle = document.getElementById('xtrars-style');

        const nSettingsRealWidth = document.body.clientWidth > this.#nSettingsWindowWidth ? this.#nSettingsWindowWidth : document.body.clientWidth;


        // Damit Button nicht über Fenster ist
        oXtrarsBtn.style.cssText = 'z-index: 162;';
        setTimeout(() => {
            oXtrarsBtn.style.cssText = '';
        }, 600);

        // Ergänzt bestehenden CSS-Code mit den nötigen Koordinaten, um eine Animation mit CSS-Only zu erreichen
        if (oXtrarsBtnCoords && !GM_getValue('bIsSettingsWindowOpen')) {
            oXtrarsStyle.innerHTML = oXtrarsStyle.innerHTML
                .replace(rStartX,
                    (oXtrarsBtnCoords.x - parseInt(GM_getValue('oSettingsWindowPosition').x) -
                        nSettingsRealWidth / 2 + nXtrarsBtnWidth / 2)
                        .toString() + 'px')
                .replace(rStartY,
                    (oXtrarsBtnCoords.y - parseInt(GM_getValue('oSettingsWindowPosition').y) -
                        this.#nSettingsWindowHeight / 2 + nXtrarsBtnWidth / 2)
                        .toString() + 'px')
                .replace(rHalfWayX,
                    ((oXtrarsBtnCoords.x - parseInt(GM_getValue('oSettingsWindowPosition').x) -
                        (nSettingsRealWidth + nXtrarsBtnWidth) / 2) / 2)
                        .toString() + 'px')
                .replace(rHalfWayY,
                    ((oXtrarsBtnCoords.y - parseInt(GM_getValue('oSettingsWindowPosition').y) -
                        (this.#nSettingsWindowHeight + nXtrarsBtnWidth) / 2) / 2)
                        .toString() + 'px')
                .replace(rBeforeEndX, '0')
                .replace(rBeforeEndY, '0')
                .replace(rEndX, '0')
                .replace(rEndY, '0');
        }
        else {
            oXtrarsStyle.innerHTML = oXtrarsStyle.innerHTML
                .replace(rStartX, '0')
                .replace(rStartY, '0')
                .replace(rHalfWayX,
                    ((oXtrarsBtnCoords.x - parseInt(GM_getValue('oSettingsWindowPosition').x) -
                        (nSettingsRealWidth + nXtrarsBtnWidth) / 2) / 2)
                        .toString() + 'px')
                .replace(rHalfWayY,
                    ((oXtrarsBtnCoords.y - parseInt(GM_getValue('oSettingsWindowPosition').y) -
                        (this.#nSettingsWindowHeight + nXtrarsBtnWidth) / 2) / 2)
                        .toString() + 'px')
                .replace(rBeforeEndX, (oXtrarsBtnCoords.x - parseInt(GM_getValue('oSettingsWindowPosition').x) -
                    nSettingsRealWidth / 2 + nXtrarsBtnWidth / 2)
                    .toString() + 'px')
                .replace(rBeforeEndY, (oXtrarsBtnCoords.y - parseInt(GM_getValue('oSettingsWindowPosition').y) -
                    this.#nSettingsWindowHeight / 2 + nXtrarsBtnWidth / 2)
                    .toString() + 'px')
                .replace(rEndX,
                    (oXtrarsBtnCoords.x - parseInt(GM_getValue('oSettingsWindowPosition').x) -
                        nSettingsRealWidth / 2 + nXtrarsBtnWidth / 2)
                        .toString() + 'px')
                .replace(rEndY,
                    (oXtrarsBtnCoords.y - parseInt(GM_getValue('oSettingsWindowPosition').y) -
                        this.#nSettingsWindowHeight / 2 + nXtrarsBtnWidth / 2)
                        .toString() + 'px');
        }
    }

    #closeSettingsWindow(oSettingsWindow) {
        document.removeEventListener("touchmove", this.drag);
        document.removeEventListener("mousemove", this.drag);

        this.#slideInAndOpenOrSlideOutAndCloseWindow();
        oSettingsWindow.classList.remove('run-circleToWindow-animation');
        oSettingsWindow.classList.add('run-windowToCircle-animation');
        this.restartAnimation(oSettingsWindow);


        GM_setValue('bIsSettingsWindowOpen', false);
        GM_setValue('sLastActiveTab', '');
    }

    #nSettingsWindowWidth = 500;
    #nSettingsWindowHeight = 170;
    #bButtonDisabled = false;
}

/**
 The CStreamingHandler class that extends the CBaseHandler class and provides additional functionality for streaming
 video content.
 @class
 @extends CBaseHandler
 */
class CStreamingHandler extends CBaseHandler {
    oTimer;

    /**
     Checks if the given regex matches the current URL and if the element with the given selector exists on the page.
     @async
     @param {RegExp} rRegex - A regular expression to match the URL.
     @param {string} sSelector - A CSS selector for the element.
     @returns {Promise<Boolean>} A Promise that resolves to a Boolean indicating if the element exists.
     */
    async isStreamingHoster(rRegex, sSelector) {
        return this.hasUrl([rRegex]) && await this.waitForElement(sSelector).catch(() => null);
    }

    /**
     Iterates through a list of streaming hosters and finds the current hoster.
     @async
     @param {Array} aHoster - An array of hosters.
     @returns {Promise<void>} A Promise that resolves after the current hoster is found and the stream behavior is set.
     */
    async findOutStreamingHoster(aHoster) {
        for (let oHoster of aHoster) {
            if (await this.isStreamingHoster(oHoster.regex, oHoster.selector)) {
                let oVideo = await this.waitForElement(oHoster.selector)
                    .catch(() => null);
                await this.setStreamBehavior(oHoster, oVideo);
            }
        }
    }

    /**
     Appends custom style to the document head.
     */
    appendOwnStyle() {
        let oStyle = document.createElement('style');
        oStyle.innerHTML = `<style>
            @media screen and (max-width: 800px) {
              #xtrars-warning-window {
                width: calc(100% - 10px)  !important;
              }
            }
            
            .xtrars-copied {
                  padding: 8px 12px;
                  background-color: #4CAF50;
                  color: white;
                  border-radius: 3px;
                  font-size: 14px;
                  display: none;
                  animation-name: xtrars-fadeIn;
                  animation-duration: 1s;
            }
            @keyframes xtrars-fadeIn {
                  from {opacity: 0;}
                  to {opacity: 1;}
            }
            
            #xtrars-warning-window {
                position: absolute; 
                top: 20%; 
                left: 50%;
                transform: translateX(-50%); 
                width: 50%; 
                background-color: white;
            }`.replace('<style>', '');
        document.head.appendChild(oStyle)
    }

    /**
     Detects the current browser type and returns its name.
     @returns {string} A string representing the name of the browser.
     */
    detectBrowser() {
        // BIG thanks to Rob W https://stackoverflow.com/a/9851769/8887112
        let bIsChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
        let isEdge = bIsChrome && (navigator.userAgent.indexOf("Edg") !== -1);
        let bIsFirefox = typeof InstallTrigger !== 'undefined';
        let bIsOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
        let bIsSafari = /constructor/i.test(window.HTMLElement) || (function (p) {
            return p.toString() === "[object SafariRemoteNotification]";
        })(!window.safari || (typeof safari !== 'undefined' && safari.pushNotification));

        if (isEdge) return 'edge';
        if (bIsChrome) return 'chrome';
        if (bIsFirefox) return 'firefox';
        if (bIsOpera) return 'opera';
        if (bIsSafari) return 'safari';
        return 'none';
    }

    /**
     Registers keydown and keyup event listeners for the document object that will apply keyboard shortcuts to local video object
     */
    applyShortcuts(o = undefined) {
        try {
            if (o) {
                o.addEventListener('keydown', (o) => {
                    if (!this.#aKeyCodesToHandle.includes(o.keyCode)) return true;
                    o.stopImmediatePropagation();
                    o.preventDefault();
                    this.initShortcutTimer(o);
                });
                o.addEventListener('keyup', (o) => {
                    if (!this.#aKeyCodesToHandle.includes(o.keyCode)) return true;
                    o.stopImmediatePropagation();
                    o.preventDefault();
                    this.removeShortcutTimers();
                });
                o.addEventListener('click', (o) => {
                    o.stopImmediatePropagation();
                }, true);
                return;
            }

            document.addEventListener('keydown', (o) => {
                if (!this.#aKeyCodesToHandle.includes(o.keyCode)) return true;
                o.stopImmediatePropagation();
                o.preventDefault();
                this.initShortcutTimer(o);
            });

            document.addEventListener('keyup', (o) => {
                if (!this.#aKeyCodesToHandle.includes(o.keyCode)) return true;
                o.stopImmediatePropagation();
                o.preventDefault();
                this.removeShortcutTimers();
            });
        } catch (e) {

        }

    }

    /**
     Initializes a timer for a given keyboard event and calls the 'shortcuts' function every 150ms while the key is being held down.
     @param {Object} o - Keyboard event object that triggered the function
     */
    initShortcutTimer(o) {
        if (this.oTimer) return;
        this.fireShortcut(o);
        this.#bSingleKeyPressed = true;

        // aktiviere nur bei Pfeiltasten das Interval
        if (!(o.keyCode > 36 && o.keyCode < 41)) return;

        // speichere Zustand & pausiere Video
        if (o.keyCode === 37 || o.keyCode === 39) {
            this.#bIsPlaying = !document.localVideo.paused;
            this.#bIsTimeKeyPressed = true;
            document.localVideo.pause();
        }

        this.oTimer = () => {
            this.fireShortcut(o);
            this.#iTimeJumpIndex++;
            if (this.#fTimeout > 20) {
                if (this.#fTimeout === this.#fInitTimeout) {
                    this.#fTimeout = 250;
                }
                if (!(this.#iTimeJumpIndex % 3)) {
                    this.#fTimeout *= 0.9;
                }
            }
            this.#iTimeoutId = setTimeout(this.oTimer, Math.floor(this.#fTimeout));
        }
        this.#iTimeoutId = setTimeout(this.oTimer, Math.floor(this.#fTimeout));
    }

    /**
     Removes any existing keyboard shortcut timers or pauses the video playback if the arrow keys were pressed.
     */
    removeShortcutTimers() {
        clearTimeout(this.#iTimeoutId);
        delete this.oTimer;
        if (this.#bIsPlaying && this.#bIsTimeKeyPressed) {
            document.localVideo.play();
        }
        this.#iTimeJumpIndex = 0;
        this.#iTimeJump = 10;
        this.#fTimeout = this.#fInitTimeout;
        this.#bIsTimeKeyPressed = false;
        this.#bSingleKeyPressed = false;
    }

    /**
     Handles various keyboard shortcuts for the local video object depending on the key pressed.
     @param {Object} o - Keyboard event object.
     */
    fireShortcut(o) {
        if (!o || o.shiftKey || o.ctrlKey || o.altKey || o.metaKey || !document.localVideo) return;

        // noinspection FallThroughInSwitchStatementJS
        switch (o.keyCode) {
            case 37: // Left
                document.localVideo.currentTime -= this.#iTimeJump;
                break;
            case 38: // Up
                if (document.localVideo.volume < 0.9) {
                    document.localVideo.volume += 0.1;
                }
                else {
                    document.localVideo.volume = 1;
                }
                break;
            case 39: // Right
                document.localVideo.currentTime += this.#iTimeJump;
                break;
            case 40: // Down
                if (document.localVideo.volume > 0.1) {
                    document.localVideo.volume -= 0.1;
                }
                else {
                    document.localVideo.volume = 0;
                }
                break;
            case 70: // F
                if (this.#bSingleKeyPressed) break;
                if (!document.fullscreenElement) {
                    document.localVideo.requestFullscreen().catch(() => {
                        document.localVideo.style.width = "100%";
                        document.localVideo.style.height = "100%";
                        document.body.style.margin = "0px";
                        document.body.style['background-color'] = "black";
                    });
                }
                else {
                    document.exitFullscreen().catch(() => null);
                }
                break;
            case 32: // Space
                if (o.target.tagName === 'VIDEO') break;
            case 75: // K
                if (this.#bSingleKeyPressed) break;
                this.#bIsPlaying = document.localVideo.paused;
                if (this.#bIsPlaying) {
                    document.localVideo.play();
                }
                else {
                    document.localVideo.pause();
                }
                break;
            case 77: // M
                if (this.#bSingleKeyPressed) break;
                document.localVideo.muted = !document.localVideo.muted;
                break;
            case 48: // Zahlen 0-9
            case 49:
            case 50:
            case 51:
            case 52:
            case 53:
            case 54:
            case 55:
            case 56:
            case 57:
            case 96:
            case 97:
            case 98:
            case 99:
            case 100:
            case 101:
            case 102:
            case 103:
            case 104:
            case 105:
                if (this.#bSingleKeyPressed) break;
                let fDuration = document.localVideo.duration;
                let iSection = (o.keyCode + (o.keyCode < 96 ? 2 : 4)) % 10;

                document.localVideo.currentTime = fDuration / 10 * iSection;
                break;
        }
    }

    /**
     Waits for the local video object to become available and sets up event listeners to enable keyboard shortcuts.
     */
    async handleLocalVideo() {
        let oVideo = await this.waitForElement('html head ~ body video').catch(() => null);

        // Fängt Event ab und verhindert, dass untergeordnete Elemente auf das Event reagieren können (somit werden Popups verhindert)
        window.addEventListener('click', (o) => {
            o.stopImmediatePropagation();
        }, true);
        document.addEventListener('click', (o) => {
            o.stopImmediatePropagation();
        }, true);
        oVideo.addEventListener('click', (o) => {
            o.stopImmediatePropagation();
        }, true);

        let oWarningWindow = document.getElementById('xtrars-warning-window');

        document.localVideo = oVideo;

        // Ende überspringen
        let iIndex = 0;
        oVideo.addEventListener('timeupdate', () => {
            if (oWarningWindow && iIndex > 2) {
                oWarningWindow.style.display = "none";
            }
            iIndex++;

            if (oVideo.currentTime + (GM_getValue('bSkipEnd') ? (GM_getValue('iSkipEndTime') ?? 1) : 1) >= oVideo.duration) {
                GM_setValue('isLocalVideoEnded', true);
                window.close();
            }
        });

        oVideo.addEventListener('play', () => {
            this.#bIsPlaying = true;
            let oWarningWindow = document.getElementById('xtrars-warning-window');
            if (oWarningWindow) {
                oWarningWindow.style.display = "none";
            }
        });

        oVideo.addEventListener('loadeddata', () => {
            this.applyShortcuts();
            oVideo.currentTime = 0;

            if (GM_getValue('bSkipStart') && GM_getValue('iSkipStartTime')) {
                oVideo.currentTime = GM_getValue('iSkipStartTime');
            }

            if (!GM_getValue('bSkipEnd') || GM_getValue('iSkipEndTime') >= oVideo.duration) {
                oVideo.addEventListener('waiting', () => {
                    if (oVideo.currentTime + (GM_getValue('bSkipEnd') ? (GM_getValue('iSkipEndTime') ?? 1) : 1) >= oVideo.duration) {
                        setTimeout(() => {
                            GM_setValue('isLocalVideoEnded', true);
                            window.close();
                        }, 2e3);
                    }
                });
            }
        });

        // Erlaube Fullscreen durch Doppelklick
        window.addEventListener('dblclick', () => {
            if (window.innerHeight === screen.height) {
                document.exitFullscreen().catch(() => null);
            }
            else {
                oVideo.requestFullscreen().catch(() => null);
            }
        }, true);

        oVideo.style.left = 0;
        oVideo.style.top = 0;
        oVideo.style.position = "fixed";
        oVideo.style.width = "100vw";
        oVideo.style.height = "100vh";
        oVideo.style['z-index'] = 2147483647;
        oVideo.style.backgroundColor = "black";
        document.body.style.margin = "0px";
        document.body.style.backgroundColor = "black";
        document.body.style.overflow = "hidden";
        oVideo.requestFullscreen().catch(() => null);

        oVideo.play().catch(() => {
            // Autoplay wurde blockiert
            this.showAutoplayWarning();
        });
    }

    /**
     Sets the behavior of the video stream based on the hoster and video source
     @async
     @param {object} oHoster - The hoster object containing information on the hoster and its regular expression for
      matching the m3u8 video url
     @param {object} oVideo - The video object whose behavior is being set
     @returns {void}
     */
    async setStreamBehavior(oHoster, oVideo) {
        if (oHoster.hoster === this.getHoster(0, true)) {

            await new Promise(resolve => {
                window.addEventListener('load', async () => resolve(), false);
            });

            let oClickEvent = new Event('click');
            oClickEvent.which = 1;
            oClickEvent.pageX = 6;
            oClickEvent.pageY = 1;
            (await this.waitForElement(oHoster.selector)).dispatchEvent(oClickEvent);

            let oVideoElement = await this.waitForElement(oHoster.selector).catch(() => null);


            // let aMatch = typeof oVideo.src === 'undefined' ? null :
            //     oVideo.src.match(/^blob:https:\/\//g);
            // this.appendOwnStyle();
            //
            // if (aMatch !== null) {
            //     let sText = ''
            //     // Extract m3u8 video url and then
            //     // oVideo.src = Array.from(document.querySelectorAll('script')).filter(oItem => {
            //     //     sText += (oItem.text + "\n\n\n");
            //     //     let match = oItem.text.match(oHoster.m3u8Regex);
            //     //     return match && match.length;
            //     // }).map(oItem => oItem.text.match(oHoster.m3u8Regex)[0]);
            //
            //
            //
            //     if (oHoster.hoster === this.getHoster(0, true)) {
            //         if (Hls.isSupported()) {
            //             let oVideoElement = document.createElement('video');
            //             this.applyShortcuts(oVideoElement);
            //
            //             let videoSrc = oVideo.src;
            //             document.body.innerHTML = '';
            //             document.body.appendChild(oVideoElement);
            //
            //             const config = {
            //                 enableWorker: false,
            //             };
            //             let oHls = new Hls(config);
            //             oHls.loadSource(videoSrc);
            //             oHls.attachMedia(oVideoElement);
            //             oHls.startLoad();
            //
            //             oVideoElement.controls = true;
            //             oVideoElement.preload = true;
            //             oVideoElement.autoplay = true;
            //         }
            //     }
            // }

            // Seite bereinigen
            document.body.prepend(oVideoElement);
            Array.from(document.body.children).forEach(oElement => {
                if (oElement.tagName !== 'VIDEO') {
                    oElement.style.display = 'none';
                }
            });

            oVideoElement.controls = true;
            oVideoElement.preload = true;
            oVideoElement.autoplay = true;
        }
        else if (oHoster.hoster === this.getHoster(1, true)) {
            await new Promise(resolve => {
                document.addEventListener('DOMContentLoaded', () => resolve(), false);
            });
            oVideo.src = 'https:/' + oVideo.innerText;
            window.location.replace(oVideo.src);

        }
        else if (oHoster.hoster === this.getHoster(2, true)) {
            if (/https:\/\/.*\.[a-z]{2,3}\/d\//.test(document.location.href)) {
                window.location.replace(oVideo.src);
            }

            // im embedded mode
            let oVideoElement;
            await new Promise(resolve => {
                window.addEventListener('load', async () => {
                    oVideoElement = await this.waitForElement('.video-js > video').catch(() => null);
                    resolve();
                }, false);
            });


            // Seite bereinigen
            document.body.innerHTML = '';
            document.body.append(oVideoElement);
            window.addEventListener('click', (event) => {
                event.stopImmediatePropagation();
                event.preventDefault();
            }, true);

            oVideoElement.controls = true;
            oVideoElement.preload = true;
            oVideoElement.autoplay = true;
        }
        else if (oHoster.hoster === this.getHoster(3, true)) {
            await new Promise(resolve => {
                window.addEventListener('load', async () => {
                    await this.waitForElement(oHoster.selector + '[src]').catch(() => null);
                    resolve();
                }, false);
            });

            window.location.replace(oVideo.src);
        }
    }

    /**
     Shows a warning message for autoplay and appends custom style to the document head.
     */
    async showAutoplayWarning() {
        this.appendOwnStyle();

        let oContent = {
            chrome: `
                <div style="width: 100%; text-align: center;">
                    <span style="font-weight: bold; font-size: larger;">Autoplay wurde vom Browser blockiert!</span> <br><br>
                    Zum Aktivieren kopiere den Link in die Adressleiste und aktiviere "Ton"
                    (Es muss Zulassen drin stehen. Automatisch reicht nicht.)
                    <br><br>
                    <input id="xtrars-autoplay-input" type="text" style="width: calc(100% - 20px); margin: 5px;"
                    value="chrome://settings/content/siteDetails?site=${window.location.protocol}//${window.location.hostname}">
                </div>
                <div id="xtrars-copied-message"></div>`,
            firefox: `
                <div style="width: 100%; text-align: center; padding: 5px;">
                    <span style="font-weight: bold; font-size: larger;">Autoplay wurde vom Browser blockiert!</span> <br><br>
                    Zum Aktivieren halte dich an die Bildanleitung:
                    <br><br>
                    <img src="data:image/webp;base64,UklGRuohAABXRUJQVlA4IN4hAAAQlgCdASolAsIAPpFEnUolpCMhptOqoLASCWNu4WsAsqP/67ui57+o/tvyg/kXXgePeF/ktybO1szvp8/X/cP9Hf9/6wv9H5l3rv9OXmE/bv1lPTj6BX63+rp/6fZM/pvqP+dt/6/21+I7/Kf9n/d/6P2utWk8z/3f8ZO/3+4/1P9nfPP8d+d/sv5Zf3D2ssyfTnqR/F/tV+C/vf7n/4n3H/tf5b+cvwx/qfyw+AX8m/lv+T/sv4/enb/Zdw7r/+a/zPqC+t3zH/Uf2n8f/Q0/jf7D+6nuh+a/2v/B/bn9gH8n/nf+l/O3+3fL3+i/2XjM/a/857AP8y/s/+3/u/+R/aT6W/4H/q/5b/Yft57Yvzn/Gf9b/I/5b5B/5r/VP+Z/f/a7///uP/c3//+7r+wv//DtCOanS9n/YOfdQCOI/qEBJuYq9OGn92+4VbeAivxpJPD2VYCWuEF7xwyyFHkAaJy0AmeVAQpdceOCuIMz91LXq15IdPrnkPnwS381EVFxdVJbt+OIRECdz3F7oDMLjGUQ90nVhXPdPqjO6q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F7x+ZD4bEpEQTPbXMc8KITI0oRjzWwFqYAAZJAbj7hAwF+JoiEEm8S87Dv0ZYDGH8gSAZpqEPT44svjlxh4J7kOwqwbfXatdPCbARAKgyKnwX1TtscePHl9tGJtTIPdcNWksLk2XAATndkWMEbMXZmFGNGXM069XCRYAAAAAKqAAAAAB6mAAAAAAAAAAAAA=" 
                    alt="Klicke oben im Firefox auf das Blockieren-Symbol und aktiviere Autoplay">
                    <br><br>
                </div>`,
            safari: ``,
            aliases: {
                chrome: 'chrome', edge: 'chrome', firefox: 'firefox', none: 'chrome', opera: 'chrome', safari: 'chrome', // TODO Safari anpassen
            }
        };

        const oWarningWindow = document.createElement("div");
        oWarningWindow.id = 'xtrars-warning-window';
        oWarningWindow.innerHTML = oContent[oContent.aliases[this.detectBrowser()]];
        oWarningWindow.style.cssText = `
            position: absolute; 
            top: 40%; background-color: white;  
            left:50%;
            top: 50%;
            transform: translate(-50%,-50%);
            font-family: Arial, Helvetica, sans-serif;
            padding: 10px;
            z-index: 2147483647;
        `;
        document.body.appendChild(oWarningWindow);

        let autoplayInput = document.getElementById('xtrars-autoplay-input');

        autoplayInput.addEventListener('focus', () => {
            navigator.clipboard
                .writeText(autoplayInput.value)
                .then(() => {
                    let oMessage = document.getElementById("xtrars-copied-message");
                    oMessage.innerHTML = "URL kopiert";
                    oMessage.classList.add("xtrars-copied");
                    oMessage.style.display = "block";
                    setTimeout(() => {
                        oMessage.style.display = "none";
                    }, 2500);
                })
                .catch(() => null);
        });
    }


    /**@type {boolean}*/
    #bIsPlaying = false;
    /**@type {boolean}*/
    #bIsTimeKeyPressed = false;
    /**@type {boolean}*/
    #bSingleKeyPressed = false;
    /**@type {number}*/
    #iTimeJump = 10;
    /**@type {number}*/
    #iTimeJumpIndex = 0;
    /**@type {number}*/
    #iTimeoutId;
    /**@type {number}*/
    #fInitTimeout = 750;
    /**@type {number}*/
    #fTimeout = this.#fInitTimeout;
    /**@type {number[]}*/
    #aKeyCodesToHandle = [
        32, // Space
        37, 38, 39, 40, // Arrow keys (37: Left, 38: Up, 39: Right, 40: Down)
        48, 49, 50, 51, 52, 53, 54, 55, 56, 57, // Number keys 0-9
        70, 75, 77, // 70, 75, 77: Character keys 'F', 'K', 'M'
        96, 97, 98, 99, 100, 101, 102, 103, 104, 105, // Number pad keys 0-9
    ];

}

/**
 An async IIFE that enhances the user experience on Burning Series website
 @async
 @function
 @returns {Promise<void>}
 */
(async function () {
    'use strict';

    /**
     Instance of the CBurningSeriesHandler class used to interact with the Burning Series website.
     @type {CBurningSeriesHandler}
     */
    let cBsHandler = new CBurningSeriesHandler();

    /**
     Instance of the CStreamingHandler class used to handle video streaming.
     @type {CStreamingHandler}
     */
    let cStreamingHandler = new CStreamingHandler();

    if (!cBsHandler.hasUrl([/https:\/\/(bs.to|burningseries.[a-z]{2,3})/])) {
        cStreamingHandler.applyShortcuts();
    }

    await new Promise((resolve) => {
        let iInterval = setInterval(() => {
            if (document.body) {
                clearInterval(iInterval);
                resolve();
            }
        }, 70);
    });

    if (GM_getValue('clickFirstSeason')) {
        GM_setValue('clickFirstSeason', false);
        let sSelector = '.serie > .episodes > tbody > tr:first-child > td:first-child > a:first-child';
        await cBsHandler.waitForElement(sSelector);
        document.location.replace(document.querySelector(sSelector));
    }
    cBsHandler.initGMVariables();

    if (cBsHandler.isSeries()) {
        cBsHandler.appendOwnStyle();
        await cBsHandler.buildButton();
        cBsHandler.buildSettingsWindow();
        cBsHandler.initEvents();

        if (GM_getValue('bIsSettingsWindowOpen')) {
            if (GM_getValue('sLastActiveTab') !== '') {
                cBsHandler.showTabContent(GM_getValue('sLastActiveTab'));
            }
            cBsHandler.showSettingsWindow();
        }

        if (cBsHandler.isEpisode()) {
            if (GM_getValue('bActivateEnhancer') &&
                !cBsHandler.hasAnotherHoster() &&
                !cBsHandler.hasUrl([new RegExp('/' + cBsHandler.getHoster(0))]) &&
                !cBsHandler.hasUrl([new RegExp('/' + cBsHandler.getHoster(1))]) &&
                !cBsHandler.hasUrl([new RegExp('/' + cBsHandler.getHoster(2))]) &&
                !cBsHandler.hasUrl([new RegExp('/' + cBsHandler.getHoster(3))])) {
                if (GM_getValue('bSelectHoster') === cBsHandler.getHoster(0, true)) {
                    await cBsHandler.skipUnavailable([
                        cBsHandler.getHoster(0),
                        cBsHandler.getHoster(3),
                        cBsHandler.getHoster(1),
                        cBsHandler.getHoster(2)
                    ]);
                }
                else if (GM_getValue('bSelectHoster') === cBsHandler.getHoster(1, true)) {
                    await cBsHandler.skipUnavailable([
                        cBsHandler.getHoster(1),
                        cBsHandler.getHoster(3),
                        cBsHandler.getHoster(0),
                        cBsHandler.getHoster(2)
                    ]);
                }
                else if (GM_getValue('bSelectHoster') === cBsHandler.getHoster(2, true)) {
                    await cBsHandler.skipUnavailable([
                        cBsHandler.getHoster(2),
                        cBsHandler.getHoster(3),
                        cBsHandler.getHoster(0),
                        cBsHandler.getHoster(1),
                    ]);
                }
                else if (GM_getValue('bSelectHoster') === cBsHandler.getHoster(3, true)) {
                    await cBsHandler.skipUnavailable([
                        cBsHandler.getHoster(3),
                        cBsHandler.getHoster(0),
                        cBsHandler.getHoster(2),
                        cBsHandler.getHoster(1),
                    ]);
                }
            }

            if (GM_getValue('bActivateEnhancer') && !cBsHandler.hasAnotherHoster() &&
                (cBsHandler.hasUrl([new RegExp('/' + cBsHandler.getHoster(0))]) ||
                    cBsHandler.hasUrl([new RegExp('/' + cBsHandler.getHoster(1))]) ||
                    cBsHandler.hasUrl([new RegExp('/' + cBsHandler.getHoster(2))]) ||
                    cBsHandler.hasUrl([new RegExp('/' + cBsHandler.getHoster(3))]))) {
                GM_setValue('isLocalVideoEnded', false);
                cBsHandler.playNextEpisodeIfVideoEnded();
                let oName = await cBsHandler.waitForElement('.episode > h2');
                GM_setValue('sEpisodeName', oName.outerText);
                let eActiveTab = await cBsHandler.waitForElement('section.serie .hoster-tabs .active a');
                await cBsHandler.clickPlay();
                await cBsHandler.handleBsVideo(eActiveTab.innerText,
                    [
                        new RegExp(cBsHandler.getHoster(0)),
                        new RegExp(cBsHandler.getHoster(1)),
                        new RegExp(cBsHandler.getHoster(2)),
                        new RegExp(cBsHandler.getHoster(3))
                    ]);
            }
        }
    }

    if (GM_getValue('bActivateEnhancer')) {
        const aHoster = [
            {
                regex: /^(https:\/\/(v-*o-*e|[-unblock\d]){1,15}\.[a-z]{2,3}\/.*)|(https:\/\/jamessoundcost\.com\/.*)/g,
                selector: '#voe-player',
                hoster: cBsHandler.getHoster(0, true),
                m3u8Regex: /(?<=sources = {([ \n]|.)*?hls': ')https:\/\/.*(?=',)/g,

            },
            {
                regex: /^https:\/\/(dood)|(ds2play)|(d[0o]+d)\.[a-z]{2,3}\//g,
                selector: '#os_player > iframe, #video_player_html5_api',
                hoster: cBsHandler.getHoster(2, true),
            },
            {
                regex: /^(https:\/\/streamtape\.[a-z]{2,3}\/)|(https:\/\/streamadblocker\.xyz)/g,
                selector: '#robotlink',
                hoster: cBsHandler.getHoster(1, true),
            },
            {
                regex: /^(https:\/\/(vidoza|videzz)\.[a-z]{2,3}\/embed)/g,
                selector: '#player_html5_api',
                hoster: cBsHandler.getHoster(3, true),
            }
        ];
        await cStreamingHandler.findOutStreamingHoster(aHoster);
        await cStreamingHandler.handleLocalVideo();
    }
})();