Greasy Fork is available in English.

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           burning series enhancer
// @name:en        burning series enhancer

// @icon           https://bs.to/favicon.ico
// @author         xtrars
// @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.
// @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        11.0.2
// @run-at         document-body
// @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://streamtape.com/*
// @match          https://*.tapecontent.net/*

// @match          https://*.voe-network.net/*
// @include        /^(https:\/\/(v-*o-*e|[-unblock\d]){1,15}\.[a-z]{2,3}\/.*)|(https:\/\/321naturelikefurfuroid\.com\/.*)/

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

// ==/UserScript==

// TODO Dokumentation verbessern
class BaseHandler {

    /**
     * Gibt den Hoster als String zurück
     * @param iIndex - 0: VOE, 1: Streamtape, 2: Doodstream
     * @param bAllLowerCase
     * @returns {*}
     */
    getHoster(iIndex, bAllLowerCase = false) {
        const aHoster = [
            'VOE',
            'Streamtape',
            'Doodstream',
        ];
        return bAllLowerCase ? aHoster[iIndex].toLowerCase() : aHoster[iIndex];
    }

    waitForElement(sSelector, bWaitUnlimited = true) {
        return new Promise(async resolve => {
            if (document.querySelector(sSelector)) {
                return resolve(document.querySelector(sSelector));

            }

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

            if (document['body']) {
                observer.observe(document['body'], {
                    childList: true, subtree: true,
                });
            }

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

    hasUrl(aSelector) {
        let isAvailable = true;
        for (let selector of aSelector) {
            isAvailable = document['location']['href'].search(selector) !== -1;
            if (!isAvailable) {
                return false;
            }
        }
        return true;
    }

    reload(iDelay = 300) {
        setTimeout(() => {
            window['location'].reload();
        }, iDelay);
    }

    querySelectorAllRegex(sSelector = '*', sAttribute = 'name', rRegex = /.*/) {
        for (const eElement of document.querySelectorAll(sSelector)) {
            if (rRegex.test(eElement[sAttribute])) {
                return eElement;
            }
        }
        return false;
    }
}

class BurningSeriesHandler extends BaseHandler {
    initGMVariables() {
        if (typeof GM_getValue('bActivateEnhancer') === "undefined") {
            GM_setValue('bActivateEnhancer', false);
        }
        if (typeof GM_getValue('bAutoplayNextEpisode') === "undefined") {
            GM_setValue('bAutoplayNextEpisode', true);
        }
        if (typeof GM_getValue('bAutoplayVideo') === "undefined") {
            GM_setValue('bAutoplayVideo', true);
        }
        if (typeof GM_getValue('bAutoplayNextSeason') === "undefined") {
            GM_setValue('bAutoplayNextSeason', true);
        }
        if (typeof GM_getValue('bAutoplayRandomEpisode') === "undefined") {
            GM_setValue('bAutoplayRandomEpisode', false);
        }
        if (typeof GM_getValue('bSelectHoster') === "undefined") {
            GM_setValue('bSelectHoster', this.getHoster(0, true));
        }
        if (typeof GM_getValue('bSkipStart') === "undefined") {
            GM_setValue('bSkipStart', false);
        }
        if (typeof GM_getValue('bSkipEnd') === "undefined") {
            GM_setValue('bSkipEnd', false);
        }
        if (typeof GM_getValue('bSkipEndTime') === "undefined") {
            GM_setValue('bSkipEndTime', 0);
        }
        if (typeof GM_getValue('bSkipStartTime') === "undefined") {
            GM_setValue('bSkipStartTime', 0);
        }
    }

    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)}).*`, 'g')]);
    }

    isEpisode() {
        return this.hasUrl([/^https:\/\/(bs.to|burningseries.[a-z]{2,3})/g, /[0-9]{1,3}\/[0-9]{1,3}-/g]);
    }

    async clickPlay() {
        return new Promise(async resolve => {
            let playerElem = await this.waitForElement('section.serie .hoster-player').catch(() => {
            });
            let iNumberOfClicks = 0;
            let clickInterval = setInterval(async () => {
                if (playerElem) {
                    if (document.querySelector('section.serie .hoster-player > a') ||
                        document.querySelector('section.serie .hoster-player > iframe') ||
                        iNumberOfClicks > 120 ||
                        this.querySelectorAllRegex('iframe', 'title', /recaptcha challenge/)) {
                        clearInterval(clickInterval);
                        resolve();
                    }
                    iNumberOfClicks++;
                    let clickEvent = new Event('click');
                    clickEvent['which'] = 1;
                    clickEvent['pageX'] = 6;
                    clickEvent['pageY'] = 1;
                    playerElem.dispatchEvent(clickEvent);
                }
            }, 500);
        });
    }

    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']);
                        }
                    }
                }
            }
        });
    }

    appendOwnStyle() {
        const style = document.createElement('style');
        style['innerHTML'] = `<style>     
              :root {
              --inner-pl: 14px;
              --inner-bc-before: #2FB536;
              --inner-bc-after: #12A6F6;
              --color: white;
            }

            .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 {
                text-decoration:none;
                background-color:#11a4e3;
            }
            
            button.tab {
                background-color: transparent;
                color: white;
                float: left;
                border: none;
                outline: none;
                cursor: pointer;
                padding: 7px 10px 10px;
                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);}
            }
            
            .onoffswitch {
                z-index: 161;
                position: relative; width: 100%;
            }
            
            .onoffswitch-label {
                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 {
               float: right;
               background: #12a6f6;
               border-radius: 50%;
               width: 70px;
               height: 70px;
               line-height: 81px;
               text-align: center;
               cursor: pointer;
               animation: shake 1s ease 1s 1 normal;
            }
            
            #xtrars-menu {
               right: 4px;
            }
            
            #xtrars-btn-icon {
               width: 70px;
               height: 70px;
               display: inline-block;
               background: no-repeat center 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+a5XK3MBuglgAAAA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BoJ+B0bvnySDJP9K3se/Ng0M6lWbP3n3qLCsiy3klyWFvfBh0wQ1nOXxJSYkSM+K1xzUP93RDUd+mLds5cMiLBYH6Xv1vGzIl3N/p3bHTNIqlvkdwkJObhyNq16ry81+3MZ3tjmnpDgc6BJE8JUiMEiQqIkwhIIg66UqOiMTsn0Iz9V4JoohIPPTa2NNDoqV0qVV7qHmlGiSk6HvzYzodP4h4cvjI0BFRlzvw2LQ1g62bN9aFCAIKCgtRIzk5ZHKrGiQIqJmcrIsQJISSHEqQIKHJUfXNst836EIEGKvXbwr5NZUgQcLJx7czTw/XLrtAonP7NiF3CdQHCQE0ohUAQQ1T/4tqkBA93G9+/E0Xwk/c9OBzq3UVYgDdrrjHFYWLEXX883Nvh1X7qokVBnw2ay4vu/AsXQiXmlVKEJfgt2Vp7H5iJ10Il5JDCeISZO3Zywb16+pCACgsKkJyUpJr5FKddBeg4ZH1jDHG7MzcE9Pr8MuSNFeRQzWIS/HDgsXs3bOrmlRKEEUlTA4mJiQoMdTEUvhCUmKiMcaY0RM+jzpiRNJwbkUE4YtvfozInMbi5au1okARWgwa+jqz9+W4lhQHcvPY7bI7e+qTUrgCL709lmnrNoWVFJ/N+l41hSJy0O/6+1NS5yxgfn5gjxRcs2ETp82czf63PTpFV1mhUCgUCoVCoVAoFAqFQqEIF/4fbNAlnifq5NEAAAAASUVORK5CYII=');
               background-size: contain;
               clip-path: circle(34px at center);
            }
            
            .onoffswitch-checkbox {
                float: left;
                margin-top: 3px;
                cursor: pointer;
            }
            
            .onoffswitch.disabled { 
                color: grey;            
            }
            
            .xtrars-switch {
                position: relative;
                display: inline-block;
                width: 30px;
                height: 17px;
                margin-top: 6px;
                margin-left: 10px;
            }
            
            .xtrars-switch input { 
                opacity: 0;
                width: 0;
                height: 0;
            }
            
            .xtrars-slider {
                position: absolute;
                cursor: pointer;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-color: #ccc;
                -webkit-transition: .4s;
                transition: .4s;
            }
            
            .xtrars-slider:before {
                position: absolute;
                content: "";
                height: 13px;
                width: 15px;
                left: 2px;
                bottom: 2px;
                background-color: white;
                -webkit-transition: .4s;
                transition: .4s;
            }
            
            input:checked + .xtrars-slider {
                background-color: #669900;
            }
            
            input:focus + .xtrars-slider {
                box-shadow: 0 0 1px #669900;
            }
            
            input:checked + .xtrars-slider:before {
                transform: translateX(11px);
            }
            
            .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: 10px;
                width: 100%;
                height: calc(100% - 60px);
                overflow: auto;
            }
            
            .xtrars-active {
                text-shadow: -0.3px 0 #12a6f6, 0.3px 0 #12a6f6 !important; 
                color: #12a6f6 !important; 
                background-color: rgb(253, 253, 253) !important;
            }
            
            #xtrars-settings-toolbar {
                height: 30px; 
                width: 100%; 
                background-color: #12a6f6; 
                color: white; 
                line-height: 30px;
            }
            
            .xtrars-toolbar-text {
                display: inline-block; 
                margin-left: 10px; 
                user-select: none; 
                width: calc(100% - 65px);
                text-overflow: ellipsis; 
                overflow: hidden; 
                white-space: nowrap;
                transition: width 0.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 {
                display: inline-block;
                isolation: isolate;
                position: relative;
                height: 15px;
                width: 30px;
                border-radius: 7.5px;
                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: 7.5px;
                transform: translate3d(-75%, 0, 0);
                transition: transform 0.4s cubic-bezier(0.85, 0.05, 0.18, 1.35);
                box-shadow:
                    -4px -2px 4px 0 #ffffff,
                    4px 2px 6px 0 #d1d9e6;
            }
            
                        
            .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 0.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: 1.5px;
                stroke-dashoffset: 271.908;
                stroke-dasharray: 59 212.908;
                transition: all 0.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;
            }`.replace('<style>', '');
        document.head.appendChild(style);
    }

    async buildButton() {
        const button = document.createElement("div");
        button['id'] = 'xtrars-btn';
        button['innerHTML'] = '<i id="xtrars-btn-icon"></i>';
        await this.waitForElement('.infos').catch(() => {
        });
        document.getElementsByClassName('infos')[0]
            .insertBefore(button, document.getElementsByClassName('infos')[0]['firstChild']);
    }

    buildSettingsWindow() {
        const settingsWindow = document.createElement("div");
        settingsWindow['innerHTML'] = `
            <div id="xtrars-settings-toolbar">
                <div class="xtrars-toolbar-text">burning series enhancer - Settings</div>
                <button id="xtrars-settings-close-btn" style="user-select: none; float: right; margin-top: 6px; background-color: transparent; border: none; 
                margin-right: 10px; cursor: pointer; font-weight: bolder; color: white;">✕</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" 
            style="height: 30px; width: 100%; background-color: #12a6f6; color: white; line-height: 30px">
                <button class="tab xtrars-settings-tabs xtrars-active" data-tab="BS">BS</button>
                <button class="tab xtrars-settings-tabs" data-tab="Streaming">Streaming</button>
                <button class="tab xtrars-settings-tabs" data-tab="Info">Info</button>
                
                <label class="xtrars-switch">
                    <input type="checkbox" class="xtrars-onoffswitch">
                    <span class="xtrars-slider"></span>
                </label>
            </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,episode,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>
                        <div class="label-wrapper">
                            <span class="onoffswitch-inner auto-next-episode">
                                <span>Nächste Episode wird <strong>automatisch</strong> abgespielt</span>
                                <span>Nächste Episode wird <strong>manuell</strong> abgespielt</span>
                            </span>
                        </div>
                    </label>
                </div>
                <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>
                        <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>
                    </label>
                </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>
                        <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>
                    </label>
                </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)},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(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,Autoplay,deaktiviert">
                        <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>
                        <div class="label-wrapper">
                            <span class="onoffswitch-inner autoplay">
                                <span>Video-Autoplay <strong>aktiviert</strong></span>
                                <span>Video-Autoplay <strong>deaktiviert</strong></span>
                            </span>
                        </div>
                    </label>
                </div>
                <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>
                        <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('bSkipStartTime')) ? '' : GM_getValue('bSkipStartTime')}">
                        </div>
                    </label>
                </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>
                        <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('bSkipEndTime')) ? '' : GM_getValue('bSkipEndTime')}">
                        </div>
                    </label>
                </div>
            </div>
            
            <div id="Info" class="xtrars-tabcontent" style="font-size: 11px;">
                <span style="font-weight: bold;">burning series enhancer by xtrars</span> <br><br>       
                Du magst meine Arbeit und das Projekt erleichtert dir dein Streaming-Leben? 
                Dann spende mir doch einen Kaffee! Nur so kann das Projekt noch lange am Leben bleiben:
                <a class="xtrars-donate" href="https://www.paypal.com/donate/?hosted_button_id=H76K9EAMTW7X8" 
                    target="_blank">Spenden</a>
            </div>
        `;
        settingsWindow['style']['cssText'] = 'display: none;';
        settingsWindow['id'] = 'xtrars-settings-window';
        document['body'].appendChild(settingsWindow);
    }

    dragStart(e) {
        let eSettingsWindow = document.getElementById('xtrars-settings-window');
        let iSettingsWindowLeft = parseInt(window.getComputedStyle(eSettingsWindow)['left']);
        let iSettingsWindowTop = parseInt(window.getComputedStyle(eSettingsWindow)['top']);

        if (e['type'] === "touchstart") {
            document['settingsWindowInitialX'] = e['touches'][0]['clientX'] - iSettingsWindowLeft;
            document['settingsWindowInitialY'] = e['touches'][0]['clientY'] - iSettingsWindowTop;
        }
        else {
            document['settingsWindowInitialX'] = e['clientX'] - iSettingsWindowLeft;
            document['settingsWindowInitialY'] = e['clientY'] - iSettingsWindowTop;
        }
        document['settingsWindowActive'] = true;
    }

    dragEnd() {
        document['settingsWindowActive'] = false;
        let eSettingsWindow = document.getElementById('xtrars-settings-window');
        let iPixels = 2;
        let positionInterval = setInterval(() => {
            if (parseInt(window.getComputedStyle(eSettingsWindow)['left']) <= 0) {
                eSettingsWindow['style']['left'] = parseInt(eSettingsWindow['style']['left']) + iPixels + 'px';
            }
            else if (parseInt(window.getComputedStyle(eSettingsWindow)['top']) <= 0) {
                eSettingsWindow['style']['top'] = parseInt(eSettingsWindow['style']['top']) + iPixels + 'px';
            }
            else if (parseInt(window.getComputedStyle(eSettingsWindow)['right']) <= 0) {
                eSettingsWindow['style']['left'] = parseInt(eSettingsWindow['style']['left']) - iPixels + 'px';
            }
            else if (parseInt(window.getComputedStyle(eSettingsWindow)['bottom']) <= 0) {
                eSettingsWindow['style']['top'] = parseInt(eSettingsWindow['style']['top']) - iPixels + 'px';
            }
            else {
                clearInterval(positionInterval);
            }
        }, 1);
    }

    drag(e) {
        e.preventDefault();
        if (!document['settingsWindowActive']) {
            return;
        }
        let eSettingsWindow = document.getElementById('xtrars-settings-window');
        let currentX;
        let currentY;
        if (e['type'] === "touchmove") {
            currentX = (e['touches'][0]['clientX'] - document['settingsWindowInitialX']);
            currentY = (e['touches'][0]['clientY'] - document['settingsWindowInitialY']);
        }
        else {
            currentX = (e['clientX'] - document['settingsWindowInitialX']);
            currentY = (e['clientY'] - document['settingsWindowInitialY']);
        }

        eSettingsWindow['style']['top'] = currentY + 'px';
        eSettingsWindow['style']['left'] = currentX + 'px';
    }

    showSettingsWindow() {
        let eSettingsWindow = document.getElementById('xtrars-settings-window');
        // Vorher schonmal setzen, damit korrekte Breite und Höhe berechnet werden kann
        eSettingsWindow['style']['cssText'] = `height: 170px; width: 500px; max-width: calc(100% - 5px); 
            max-height: calc(100% - 5px); display: block; position: fixed;`;
        eSettingsWindow['style']['cssText'] = `height: 170px; width: 500px; max-width: calc(100% - 5px); 
            max-height: calc(100% - 5px); display: block; position: fixed; 
            top: calc(50% - ${(parseInt(window.getComputedStyle(eSettingsWindow)['height']) / 2) + 'px'}); 
            left: calc(50% - ${(parseInt(window.getComputedStyle(eSettingsWindow)['width']) / 2) + 'px'}); 
            background-color: #fdfdfd; box-shadow: rgba(0, 0, 0, .4) 1px 1px 10px 5px; z-index: 2147483640;`
    }

    showTabContent(sTab) {
        let oTabContent = document.querySelectorAll('.xtrars-tabcontent');
        oTabContent.forEach(item => {
            item['style']['display'] = 'none';
        });

        document.getElementById(sTab)['style']['display'] = 'block';
    }

    initEvents() {
        let oButton = document.getElementById('xtrars-btn');
        let oToolbar = document.getElementById('xtrars-settings-toolbar');
        let oSettingsWindow = document.getElementById('xtrars-settings-window');
        let oTabs = document.querySelectorAll('.xtrars-settings-tabs');

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

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

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

        let oAutoplayVideo = oStreamingCheckboxes[0]; //autoplay
        let oSkipStart = oStreamingCheckboxes[1]; //skip-start
        let oSkipEnd = oStreamingCheckboxes[2]; //skip-end

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

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


        oTabs.forEach(item => {
            item.addEventListener('click', e => {
                oTabs.forEach(tab => {
                    tab['classList'].remove('xtrars-active');
                });
                e['target']['classList'].add('xtrars-active');
                this.showTabContent(e['target']['dataset'].tab);
            });
        });

        !oButton || oButton.addEventListener('click', () => {
            this.showSettingsWindow();
            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});

        !document.getElementById('xtrars-settings-close-btn') || document.getElementById('xtrars-settings-close-btn').addEventListener('click', () => {
            document.removeEventListener("touchmove", this.drag);
            document.removeEventListener("mousemove", this.drag);
            oSettingsWindow['style']['cssText'] = 'display: none;';
        });

        let oManagedButtons = {
            'activateEnhancer': oActivateEnhancer,
            'autoplayNextEpisode': oAutoplayNextEpisode,
            'autoplayRandomEpisode': oAutoplayRandomEpisode,
            'autoplayNextSeason': oAutoplayNextSeason,
            'autoplayVideo': oAutoplayVideo,
            '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();
        });


        !oAutoplayNextEpisode || oAutoplayNextEpisode.addEventListener('change', () => {
            GM_setValue('bAutoplayNextEpisode', oAutoplayNextEpisode ? oAutoplayNextEpisode['checked'] : false);
            this.manageButtonState(oManagedButtons);
        });

        !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);
        });

        !oAutoplayVideo || oAutoplayVideo.addEventListener('change', () => {
            GM_setValue('bAutoplayVideo', oAutoplayVideo ? oAutoplayVideo['checked'] : false);
            this.manageButtonState(oManagedButtons);
        });

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

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

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

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

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


        let iPixels = 2;
        window.addEventListener('resize', () => {
            let positionInterval = 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(positionInterval);
                }
            }, 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', e => {
                    labelWorkaround(e['target'])
                });
            });

        function labelWorkaround(oElement) {
            let oInputTextElement = oElement['parentElement']['nextElementSibling']['firstElementChild'];
            if (!oInputTextElement) return;


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

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

    manageButtonState(oManagedButtons) {
        let oActivateEnhancer = oManagedButtons['activateEnhancer'];
        let oAutoplayNextEpisode = oManagedButtons['autoplayNextEpisode'];
        let oAutoplayRandomEpisode = oManagedButtons['autoplayRandomEpisode'];
        let oAutoplayNextSeason = oManagedButtons['autoplayNextSeason'];
        let oAutoplayVideo = oManagedButtons['autoplayVideo'];
        let oSelectHoster = oManagedButtons['selectHoster'];
        let oSkipStart = oManagedButtons['skipStart'];
        let oSkipEnd = oManagedButtons['skipEnd'];

        !oActivateEnhancer || (oActivateEnhancer['checked'] = GM_getValue('bActivateEnhancer'));
        !oAutoplayNextEpisode || (oAutoplayNextEpisode['checked'] = GM_getValue('bAutoplayNextEpisode'));
        !oAutoplayRandomEpisode || (oAutoplayRandomEpisode['checked'] = !GM_getValue('bAutoplayRandomEpisode'));
        !oAutoplayNextSeason || (oAutoplayNextSeason['checked'] = GM_getValue('bAutoplayNextSeason'));
        !oAutoplayVideo || (oAutoplayVideo['checked'] = GM_getValue('bAutoplayVideo'));
        !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(oAutoplayVideo);
            this.disableButton(oAutoplayNextEpisode);
            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(oAutoplayNextEpisode);
            this.enableButton(oSelectHoster);

            if (oAutoplayNextEpisode ? oAutoplayNextEpisode['checked'] : false) {
                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");
                this.disableButton(oAutoplayVideo);

                if (oAutoplayRandomEpisode ? !oAutoplayRandomEpisode['checked'] : false) {
                    this.disableButton(oAutoplayNextSeason);
                }
                else {
                    this.enableButton(oAutoplayNextSeason);
                }
            }
            else {
                this.disableButton(oAutoplayRandomEpisode);
                this.disableButton(oAutoplayNextSeason);
                this.disableButton(oSelectHoster);
                this.enableButton(oAutoplayVideo);

                if (oAutoplayVideo ? oAutoplayVideo['checked'] : false) {
                    this.enableButton(oSkipStart);
                    !oSkipStart || (oSkipStart['checked'] ? oSkipStartInput['style']['display'] = "block" :
                        oSkipStartInput['style']['display'] = "none");
                    this.enableButton(oSkipEnd);
                    !oSkipEnd || (oSkipEnd['checked'] ? oSkipEndInput['style']['display'] = "block" :
                        oSkipEndInput['style']['display'] = "none");
                }
                else {
                    this.disableButton(oSkipStart);
                    oSkipStartInput['style']['display'] = "none";
                    this.disableButton(oSkipEnd);
                    oSkipEndInput['style']['display'] = "none";
                }
            }
        }
    }

    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;
    }

    enableButton(oElement) {
        if (!oElement) return;

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

    async skipUnavailable(aHosterOrder) {
        let hoster = await this.waitForElement(`.hoster-tabs .hoster.${aHosterOrder[0]}`, false);
        if (hoster !== null) {
            document['location'].replace(document['location']['href'] + '/' + aHosterOrder[0]);
        }
        else {
            hoster = await this.waitForElement(`.hoster-tabs .hoster.${aHosterOrder[1]}`, false);
            if (hoster !== null) {
                document['location'].replace(document['location']['href'] + '/' + aHosterOrder[1]);
            }
            else {
                document['location'].replace(document['location']['href'] + '/' + aHosterOrder[2]);
            }
        }
    }
}

class StreamingHandler extends BaseHandler {
    bIsPlaying = false;
    bIsTimeKeyPressed = false;
    iTimeJump = 1;
    iTimeJumpIndex = 0;
    aKeyCodes = [32, 37, 38, 39, 40, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 70, 75, 77, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,];
    oTimers = {};

    async isStreamingHoster(regex, selector) {
        return this.hasUrl([regex]) && await this.waitForElement(selector).catch(() => {
        });
    }

    async findOutStreamingHoster(aHoster) {
        for (let oHoster of aHoster) {
            if (await this.isStreamingHoster(oHoster['regex'], oHoster['selector'])) {
                let video = await this.waitForElement(oHoster['selector'] + oHoster['detailSelector'])
                    .catch(() => {
                    });

                await this.setStreamBehavior(oHoster, video);
            }
        }
    }

    appendOwnStyle() {
        let style = document.createElement('style');
        style['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(style)
    }

    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';
    }

    async handleBsVideo(sActiveTab, aToBeChecked) {
        for (const regexHoster of aToBeChecked) {
            if (regexHoster.test(sActiveTab)) {
                let eIframe = await this.waitForElement('section.serie .hoster-player > iframe');
                let sSrc = eIframe.src;
                window.open(sSrc, '_blank').focus();
                eIframe.remove();
                let eHosterplayer = await this.waitForElement('.hoster-player');
                eHosterplayer['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;
            }
        }
    }

    applyShortcuts() {
        document.addEventListener('keydown', (e) => {
            if (!this.aKeyCodes.includes(e['keyCode'])) return true;
            e.preventDefault();
            e.stopPropagation();
            this.initShortcutTimer(e);
        });
        document.addEventListener('keyup', (e) => {
            if (!this.aKeyCodes.includes(e['keyCode'])) return true;
            e.preventDefault();
            e.stopPropagation();
            this.removeShortcutTimers();
        });
    }

    initShortcutTimer(event) {
        this.removeShortcutTimers(event['keyCode']);

        if (typeof this.oTimers[event['keyCode']] !== 'undefined') return;

        this.oTimers[event['keyCode']] = null;
        this.shortcuts(event);


        // aktiviere nur bei Pfeiltasten das Interval
        if (!(event['keyCode'] > 36 && event['keyCode'] < 41)) return;

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

        this.oTimers[event['keyCode']] = setInterval(() => {
            this.shortcuts(event);
            this.iTimeJumpIndex++;
            if (!(this.iTimeJumpIndex % 10)) {
                this.iTimeJump *= 2;
            }
        }, 150);
    }

    removeShortcutTimers(sKey = null) {
        for (const sTimerKey in this.oTimers) {
            if (Number(sTimerKey) === sKey) continue;

            if (this.bIsPlaying && this.bIsTimeKeyPressed) {
                document['localVideo'].play();
            }
            this.iTimeJumpIndex = 0;
            this.iTimeJump = 2;
            this.bIsTimeKeyPressed = false;
            clearInterval(this.oTimers[sTimerKey]);
            delete this.oTimers[sTimerKey];
        }
    }

    shortcuts(e) {
        if (!e || e['shiftKey'] || e['ctrlKey'] || e['altKey'] || e['metaKey']) return;

        switch (e['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
                clearInterval(this.oTimers[e['keyCode']]);
                if (!document['fullscreenElement']) {
                    document['localVideo'].requestFullscreen().catch(() => {
                        document['localVideo']['style']['width'] = "100%";
                        document['localVideo']['style']['height'] = "100%";
                        document['body']['style']['margin'] = "0px";
                    });
                }
                else {
                    document.exitFullscreen().catch(() => {
                    });
                }
                break;
            case 32: // Space
            case 75: // K
                clearInterval(this.oTimers[e['keyCode']]);
                this.bIsPlaying = document['localVideo']['paused'];
                if (document['localVideo']['paused']) {
                    document['localVideo'].play();
                }
                else {
                    document['localVideo'].pause();
                }
                break;
            case 77: // M
                clearInterval(this.oTimers[e['keyCode']]);
                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:
                clearInterval(this.oTimers[e['keyCode']]);
                let fDuration = document['localVideo']['duration'];
                let iSection = (e['keyCode'] + (e['keyCode'] < 96 ? 2 : 4)) % 10;

                document['localVideo']['currentTime'] = fDuration / 10 * iSection;
                break;

        }
    }

    async handleLocalVideo() {
        let video = await this.waitForElement('html head ~ body video').catch(() => {
        });

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

        document['localVideo'] = video;
        video.addEventListener('loadeddata', () => {
            this.applyShortcuts();
            video.addEventListener('play', () => {
                this.bIsPlaying = true;
                let warningWindow = document.getElementById('xtrars-warning-window');
                if (warningWindow) {
                    warningWindow['style']['display'] = "none";
                }
            });

            if (GM_getValue('bSkipStart') && GM_getValue('bSkipStartTime')) {
                video['currentTime'] = GM_getValue('bSkipStartTime');
            }


            // Ende überspringen
            video.addEventListener('timeupdate', () => {
                if (video['currentTime'] + (GM_getValue('bSkipEndTime') ?? 1) >= video['duration']) {
                    GM_setValue('isLocalVideoEnded', true);
                    window.close();
                }
            });

            if (!GM_getValue('bSkipEnd') || GM_getValue('bSkipEndTime') >= video['duration']) {
                video.addEventListener('waiting', () => {
                    if (video['currentTime'] + 1 >= video['duration']) {
                        setTimeout(() => {
                            GM_setValue('isLocalVideoEnded', true);
                            window.close();
                        }, 2e3);
                    }
                });
            }
        });


        video['style']['width'] = "100%";
        video['style']['height'] = "100%";
        document.body['style']['margin'] = "0px";
        document.body['style']['background-color'] = "black";
        video.requestFullscreen().catch(() => {
        });

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

    async setStreamBehavior(oHoster, video) {
        let aMatch = typeof video['src'] === 'undefined' ? null : video['src'].match(/^blob:https:\/\//g);
        if (aMatch !== null) {
            this.appendOwnStyle();

            // Extract m3u8 video url and then
            video['src'] = Array.from(document.querySelectorAll('script')).filter(item => {
                let match = item['text'].match(oHoster['m3u8Regex']);
                return match && match['length'];
            }).map(item => item['text'].match(oHoster['m3u8Regex'])[0]);


            // if (oHoster['hoster'] === this.getHoster(0, true)) {
            /*if (Hls.isSupported()) {

                let eVideo = document.createElement('video');
                eVideo['id'] = 'xtrars-video';
                let videoSrc = video['src'];
                document['body']['innerHTML'] = '';
                document['body'].appendChild(eVideo);

                const config = {
                    enableWorker: false,
                };
                let hls = new Hls(config);
                hls.loadSource(videoSrc);
                hls.attachMedia(eVideo);

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

                document['body']['style']['cssText'] = 'margin: 0; height: 100%; overflow: hidden';
                eVideo['style']['cssText'] = 'width: 100%; height: 100%; background-color: black;';
                eVideo['autoplay'] = true;
                eVideo['controls'] = true;
            }
            return;*/
            // }
        }

        if (oHoster['hoster'] === this.getHoster(1, true)) {
            await new Promise(resolve => {
                document.addEventListener('DOMContentLoaded', () => resolve(), false);
            });
            video['src'] = 'https:/' + video['innerText'];
            if ((GM_getValue('bAutoplayVideo') || GM_getValue('bAutoplayNextEpisode')) && (!GM_getValue('bDownloadVideo') || GM_getValue('bDownloadType'))) {
                window['location'].replace(video['src']);
            }
        }
        else if (oHoster['hoster'] === this.getHoster(0, true)) {
            window['location'].replace(video['src']);
        }
        else if (oHoster['hoster'] === this.getHoster(2, true)) {
            if (/https:\/\/.*\.[a-z]{2,3}\/d\//.test(document['location']['href'])) {
                window['location'].replace(video['src']);
            }

            // im embedded mode
            await new Promise(resolve => {
                document.addEventListener('DOMContentLoaded', async () => {
                    video = await this.waitForElement('.video-js > video').catch();
                    resolve();
                }, false);
            });

            // Seite bereinigen
            document['body']['innerHTML'] = '';
            document['body'].appendChild(video);
            window.addEventListener('click', (event) => {
                event.stopImmediatePropagation();
                event.preventDefault();
            }, true);

            video['controls'] = true;
            video['preload'] = true;
            video['autoplay'] = true;
        }
    }

    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+OIRECdz3F7oDMLjGUQ90nVhXPdPqjO6qzZT1ce4PgLBnCOpka6NDetdnZ2dnMCfR3IxMISHDec4cOHDhw3mzZzhw1ClzAaK8XAxRS1TshQjJQtuWM2kOB9PAlUy0siCULAOD5fPmWGG9KRwjAo4bfg+8TKdObA8ZUZRm0SIM/7leW+k4l4TxffcNuYuyddFnvcIfTI1X1G0KrJabUJvC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AAAAAAAAAAA=" 
                    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 warningWindow = document.createElement("div");
        warningWindow['id'] = 'xtrars-warning-window';
        warningWindow['innerHTML'] = oContent[oContent['aliases'][this.detectBrowser()]];
        warningWindow['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;
        `;
        document['body'].appendChild(warningWindow);

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

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


(async function () {
    'use strict';

    let bsHandler = new BurningSeriesHandler();
    let streamingHandler = new StreamingHandler();

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

    bsHandler.initGMVariables();

    if (bsHandler.isEpisode()) {
        bsHandler.appendOwnStyle();
        await bsHandler.buildButton();
        bsHandler.buildSettingsWindow();
        bsHandler.initEvents();

        if (GM_getValue('bActivateEnhancer') &&
            !bsHandler.hasAnotherHoster() &&
            !bsHandler.hasUrl(['/' + bsHandler.getHoster(0)]) &&
            !bsHandler.hasUrl(['/' + bsHandler.getHoster(1)]) &&
            !bsHandler.hasUrl(['/' + bsHandler.getHoster(2)])) {

            if (GM_getValue('bSelectHoster') === bsHandler.getHoster(0, true)) {
                await bsHandler.skipUnavailable([bsHandler.getHoster(0), bsHandler.getHoster(1), bsHandler.getHoster(2)]);
            }
            else if (GM_getValue('bSelectHoster') === bsHandler.getHoster(1, true)) {
                await bsHandler.skipUnavailable([bsHandler.getHoster(1), bsHandler.getHoster(0), bsHandler.getHoster(2)]);
            }
            else if (GM_getValue('bSelectHoster') === bsHandler.getHoster(2, true)) {
                await bsHandler.skipUnavailable([bsHandler.getHoster(2), bsHandler.getHoster(1), bsHandler.getHoster(0)]);
            }
        }

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

    if (GM_getValue('bActivateEnhancer') && (GM_getValue('bAutoplayNextEpisode') || GM_getValue('bAutoplayVideo'))) {
        const aHoster = [{
            regex: /^(https:\/\/(v-*o-*e|[-unblock\d]){1,15}\.[a-z]{2,3}\/.*)|(https:\/\/321naturelikefurfuroid\.com\/.*)/g,
            selector: '#voe-player',
            detailSelector: '[src]',
            hoster: bsHandler.getHoster(0, true),
            m3u8Regex: /(?<=sources = {([ \n]|.)*?mp4': ')https:\/\/.*(?=',)/g,
        }, {
            regex: /^https:\/\/dood\.[a-z]{2,3}\//g,
            selector: '#os_player > iframe, #video_player_html5_api',
            detailSelector: '',
            hoster: bsHandler.getHoster(2, true),
        }, {
            regex: /^https:\/\/streamtape\.[a-z]{2,3}\//g,
            selector: '#robotlink',
            detailSelector: '',
            hoster: bsHandler.getHoster(1, true),
        }];

        await streamingHandler.findOutStreamingHoster(aHoster);
        await streamingHandler.handleLocalVideo();
    }
})();