Greasy Fork

Greasy Fork is available in English.

HDrezka Cleanup

Cleanup HDrezka: change content width, change player size, remove blocks (telegram, social, support, vk, etc), restyle blocks (cover, status, rating, etc)

当前为 2022-06-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            HDrezka Cleanup
// @name:en         HDrezka Cleanup
// @namespace       http://tampermonkey.net/
// @version         0.43
// @description     Cleanup HDrezka: change content width, change player size, remove blocks (telegram, social, support, vk, etc), restyle blocks (cover, status, rating, etc)
// @description:en  Cleanup HDrezka: change content width, change player size, remove blocks (telegram, social, support, vk, etc), restyle blocks (cover, status, rating, etc)
// @author          rub4ek
// @match           https://hdrezka.me/*
// @match           https://hdrezka.ag/*
// @match           https://hdrezka.club/*
// @match           https://rezka.ag/*
// @match           https://rezkify.com/*
// @match           https://kinopub.me/*
// @match           http://hdrezka.tv/*
// @match           http://hdrezka.co/*
// @match           http://hdrezka.ink/*
// @match           http://hdrezka.buzz/*
// @match           http://hdrezka.loan/*
// @match           http://hdrezka.center/*
// @match           http://hdrezka.city/*
// @match           http://hdrezka.fyi/*
// @match           http://hdrezka.run/*
// @match           http://hdrezka.today/*
// @match           http://hdrezka.win/*
// @match           http://hdrezka.tips/*
// @match           http://hdrezka.vip/*
// @match           http://hdrezka.solutions/*
// @icon            https://www.google.com/s2/favicons?domain=rezka.ag
// @grant           GM_addStyle
// @grant           GM_xmlhttpRequest
// @run-at          document-body
// @license         MIT
// ==/UserScript==

(function () {
    "use strict";

    /* ------------------------------------------------- */
    /* --------------GLOBAL----------------------------- */
    /* ------------------------------------------------- */

    let hc = {};

    const arrowImageURL =
        "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAYAAAA4qEECAAAABmJLR0QA/wD/AP+gvaeTAAABa0lEQVR4nO3awUrDQBSF4dMuGhc+uF0puK/v4KL4RPoARbLUxTRQi5nMJDPJvcn/gRsp5NyfWgSVAAAAAAAAAAAAAAAAAACYXSPpKOlL0qekp+v3UNBB0rukn7uvD0kPC+5alb7IxC5oKDKxC0iNTOwJciMTe4SxkYmdoZF0VjzkOfE1/OrXI+Wd3L1bc16LG2PCETvTlGDETlQiFLEHlAxE7B41whD7Ts0gxL6aI8TmY88ZYLOxlzh8c7GXPHgzsS0camFDVZYOtLSlKIuHWdw0ieWDLG/L4uEQDxujPB3gaesfHoe72+xu8A03290MjTB/g/mBGczeYnbYBOZuSv2XAI9/7jd126uVIZWkxH6pPWIv6TsywHvkzlDsi6RdzQF7SW3Pw9cSuROL3Sq0qOrtnwevLXKnL/Zpjoc/KsRuFX6EnrXOyJ1G4TP5onDzSaHBbKp+Rhm00/ZuBgAAAAAAAAAAAAAAAODKL8SQFSF3JeZKAAAAAElFTkSuQmCC";

    /* ------------------------------------------------- */
    /* --------------GLOBAL-STYLES---------------------- */
    /* ------------------------------------------------- */

    GM_addStyle(`

    /* css */

    /* Padding for content */
    .b-wrapper {
        padding-left: 30px !important;
        padding-right: 30px !important;
    }
    .b-search__form.focused,
    .search-results {
        width: calc(100% - 60px);
        left: 30px;
    }

    /* Remove extra right padding for content page */
    .b-content__columns {
        padding-right: 0 !important;
    }

    /* Remove extra right padding on main content listing */
    .b-content__inline_inner_mainprobar {
        padding-right: 0 !important;
    }
    .b-content__inline_inner_mainprobar .b-content__inline_item {
        margin-left: 16px !important;
    }

    /* Active brand fixes */
    body.active-brand,
    body.active-brand.pp {
        padding-top: 0 !important;
    }
    .active-brand #wrapper {
        width: auto !important;
    }

    /* Style status */
    .b-post__status_wrapper {
        width: auto !important;
        margin: 0px 10px 0px 13px !important;
    }

    /* Style and resize rating block */
    .b-post__rating_table {
        width: 100% !important;
    }
    .b-post__rating_table td > * {
        float: right !important;
    }
    .b-post__rating_table .label {
        display: none !important;
    }

    /* Hide last episode info */
    .b-post__lastepisodeout {
        display: none !important;
    }

    /* Hide support block */
    .b-post__support_holder {
        display: none !important;
    }
    .b-post__support_holder_report .append {
        display: none !important;
    }

    /* Hide share label */
    .b-post__social_holder_wrapper .share-label {
        display: none !important;
    }

    /* Hide mixedtext */
    .b-post__mixedtext {
        text-indent: -9999px !important;
        padding: 0 !important;
    }

    /* !css */

    `);

    /* ------------------------------------------------- */
    /* --------------HIDE-ADS--------------------------- */
    /* ------------------------------------------------- */

    function initHideAds() {
        GM_addStyle(`

        /* css */

        /* Hide some ads containers */

        body.hc-hide-ads .b-content__main > .b-post__mixedtext + div[style],
        body.hc-hide-ads .b-content__main > .b-post__rating_table + div[style],
        body.hc-hide-ads .b-content__main > div > .b-player > .b-player__network_issues_holder + div[style],
        body.hc-hide-ads .b-content__main > div > .b-player > a[target='_blank'],
        body.hc-hide-ads .b-content__main + div,
        body.hc-hide-ads .b-wrapper .nopadd,
        body.hc-hide-ads .b-seriesupdate__block_list > .b-seriesupdate__block_list_item[data-url=''] {
            display: none !important;
        }

        /* !css */

        `);

        resolve();
        document.addEventListener("DOMContentLoaded", settings);

        function resolve() {
            if (!document.body) return;

            if (enabled()) {
                document.body.classList.add("hc-hide-ads");
            } else {
                document.body.classList.remove("hc-hide-ads");
            }
        }

        function enabled() {
            return localStorage.getItem("hc-hide-ads") != "false";
        }

        function toggle() {
            localStorage.setItem("hc-hide-ads", !enabled());
            resolve();
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(
                    toggle,
                    "hide-ads",
                    ["hc-on-of-tumbler"],
                    ["hc-hide-ads"],
                    "Скрыть рекламные блоки",
                    ["Выкл", "Вкл"]
                );
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------STYLE-IMPROVEMENTS----------------- */
    /* ------------------------------------------------- */

    function initStyleImprovements() {
        GM_addStyle(`

        /* css */

        /* Standard theme */

        body.hc-style .b-content__inline_item .info {
            background-color: #6f6f6f;
            color: #fff;
        }

        /* Night theme */

        body.hc-style.b-theme__template__night .b-content__main a {
            color: #fff;
        }

        body.hc-style.b-theme__template__night .b-content__main a:visited {
            color: #fff;
        }

        body.hc-style.b-theme__template__night .b-post__info a {
            color: #fff;
        }

        body.hc-style.b-theme__template__night .persons-list-holder .person-name-item a {
            color: #fff !important;
            border-color: #fff;
        }

        body.hc-style.b-theme__template__night .b-newest_slider__title span {
            border-color: #fff;
            color: #fff;
        }

        body.hc-style.b-theme__template__night .b-content__inline_item .cat {
            background-color: #060f13 !important;
        }

        body.hc-style.b-theme__template__night .b-content__inline_item .b-content__inline_item-link a,
        body.hc-style.b-theme__template__night .b-content__inline_item .b-content__inline_item-link a:visited {
            color: #fff;
        }

        /* Content items */

        body.hc-style .b-content__inline_item {
            width: 166px;
            margin-right: 10px;
        }

        body.hc-style .b-content__inline_item .cat {
            position: relative;
        }

        body.hc-style .b-content__inline_item .cat .entity {
            display: inline-block !important;
            margin-right: -8px;
            position: absolute;
            left: 0;
            right: 0;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        body.hc-style .b-content__inline_item:hover .cat .entity,
        body.hc-style .b-content__inline_item.active .cat .entity {
            display: none !important;
            margin-right: -10px;
            position: absolute;
            left: 0;
            right: 0;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        body.hc-style .b-content__inline_item-cover {
            padding: 0;
            border: 0;
        }

        body.hc-style .b-content__inline_item .cat {
            position: relative;
            top: unset;
            bottom: 0;
            right: 0;
            border-radius: 0;
            width: 100%;
        }

        body.hc-style .b-content__inline_item .info {
            border-radius: 0 !important;
            box-sizing: border-box;
            width: 100%;
            margin-bottom: 26px;
        }

        body.hc-style .b-content__inline_item .trailer {
            display: none !important;
            left: 0;
        }

        body.hc-style .b-newest_slider__list .b-content__inline_item {
            width: 92px;
            margin-right: 8px;
        }

        body.hc-style .b-sidelist .b-content__inline_item {
            width: 92px;
            margin-right: 8px;
        }

        /* Сontent page */

        body.hc-style .b-sidecover {
            background: none;
            border: none;
            padding: 0;
            overflow: hidden;
            border-radius: 4px;
        }

        body.hc-style .b-post .b-sidetitle,
        body.hc-style .b-post .b-post__mtitle {
            font-size: 16px;
            font-weight: bold;
            line-height: 18px;
            overflow: hidden;
            padding: 10px 18px;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        body.hc-style .b-post .b-post__actions .btn,
        body.hc-style .b-post .b-sidetitle,
        body.hc-style .b-post .b-post__schedule_block_title,
        body.hc-style .b-post .b-post__schedule_more,
        body.hc-style .b-post .b-post__mtitle {
            background: #ddd;
        }
        body.hc-style .b-post .b-post__actions .btn,
        body.hc-style .b-post .b-sidetitle,
        body.hc-style .b-post .b-post__schedule_block_title .title,
        body.hc-style .b-post .b-post__schedule_more .title,
        body.hc-style .b-post .b-post__mtitle {
            color: #000;
        }
        body.hc-style.b-theme__template__night .b-post .b-post__actions .btn,
        body.hc-style.b-theme__template__night .b-post .b-sidetitle,
        body.hc-style.b-theme__template__night .b-post .b-post__schedule_block_title,
        body.hc-style.b-theme__template__night .b-post .b-post__schedule_more,
        body.hc-style.b-theme__template__night .b-post .b-post__mtitle {
            background: #192125;
        }
        body.hc-style.b-theme__template__night .b-post .b-post__actions .btn,
        body.hc-style.b-theme__template__night .b-post .b-sidetitle,
        body.hc-style.b-theme__template__night .b-post .b-post__schedule_block_title .title,
        body.hc-style.b-theme__template__night .b-post .b-post__schedule_more .title,
        body.hc-style.b-theme__template__night .b-post .b-post__mtitle {
            color: #fff;
        }
        body.hc-style .b-post .b-post__schedule .b-sidetitle {
            display: none;
        }
        body.hc-style .b-post .b-post__partcontent {
            margin-top: 0;
        }
        body.hc-style .b-post .b-post__actions .btn {
            border: 0;
            border-radius: 0;
        }
        body.hc-style .b-post .b-post__social_holder {
            background: #1f1f1f;
        }

        /* Rating stars */

        body.hc-style .b-post__rating .b-post__rating_layer_current {
            filter: grayscale(100%) !important;
        }
        body.hc-style.b-theme__template__night .b-post__rating .b-post__rating_layer_current {
            filter: grayscale(100%) brightness(200%) !important;
        }

        .b-post__rating .num {
            color: inherit !important;;
        }

        /* Misc */

        body.hc-style .b-newest_slider__title {
            padding-bottom: 20px;
        }

        /* !css */

        `);

        resolve();
        document.addEventListener("DOMContentLoaded", settings);

        function resolve() {
            if (!document.body) return;

            if (enabled()) {
                document.body.classList.add("hc-style");
            } else {
                document.body.classList.remove("hc-style");
            }
        }

        function enabled() {
            return localStorage.getItem("hc-style-improvements") == "true";
        }

        function toggle() {
            localStorage.setItem("hc-style-improvements", !enabled());
            resolve();
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(
                    toggle,
                    "styles",
                    ["hc-on-of-tumbler"],
                    ["hc-style"],
                    "Декоративные изменения",
                    ["Выкл", "Вкл"]
                );
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------RESIZE-PLAYER---------------------- */
    /* ------------------------------------------------- */

    GM_addStyle(`

    /* css */

    /* Style player */

    .b-player {
        padding-top: 0;
    }
    .b-player #cdnplayer-preloader {
        height: 100%;
        width: 100%;
    }
    .b-player .b-simple_seasons__list {
        padding: 10px;
    }
    .b-player .b-player__holder_cdn {
        height: auto !important;
    }
    .b-player .b-player__container_cdn {
        resize: vertical;
        overflow: auto;
        width: 100% !important;
    }

    /* !css */
    
    `);

    function resizePlayer() {
        const playerHolderElem = document.querySelector(".b-player__holder_cdn");
        if (!playerHolderElem) return;

        const playerContainerElem = document.querySelector(".b-player__container_cdn");
        if (!playerContainerElem) return;

        const contentMainElem = document.querySelector(".b-content__main");
        if (!contentMainElem) return;

        const initialWidth = playerHolderElem.offsetWidth;
        const initialHeight = playerHolderElem.offsetHeight;
        let resizedWidth = contentMainElem.offsetWidth;
        let windowHeight = window.innerHeight;

        if (initialHeight > 0 && initialWidth !== resizedWidth) {
            let ratio = initialWidth / initialHeight;
            let resizedHeight = resizedWidth / ratio;
            if (resizedHeight > windowHeight) {
                resizedHeight = windowHeight;
                resizedWidth = windowHeight * ratio;
            }
            playerHolderElem.style.width = resizedWidth + "px";
            playerContainerElem.style.height = resizedHeight + "px";
            console.log(
                `HDrezka Cleanup: player resized ` +
                    `from ${initialWidth}x${initialHeight} ` +
                    `to ${resizedWidth}x${resizedHeight}.`
            );
        }
    }

    /* ------------------------------------------------- */
    /* --------------SIZE-TUMBLER----------------------- */
    /* ------------------------------------------------- */

    function initContentSizeTumbler() {
        GM_addStyle(`

        /* css */

        /* Content Size Tumbler */

        .hc-tumbler-content-size {
            width: 78px !important;
        }
        .hc-tumbler-content-size .hc-tumbler-point:nth-child(1) {
            border-width: 8px;
        }
        .hc-tumbler-content-size .hc-tumbler-point:nth-child(2) {
            border-width: 7px;
        }
        .hc-tumbler-content-size .hc-tumbler-point:nth-child(3) {
            border-width: 6px;
        }
        .hc-tumbler-content-size .hc-tumbler-point:nth-child(4) {
            border-width: 5px;
        }

        /* Content Sizes */


        body {
            min-width: 1020px;
        }
        body.hc-content-size-wide .b-wrapper {
            width: auto;
            min-width: 960px;
            max-width: 1150px;
        }
        body.hc-content-size-ultrawide .b-wrapper {
            width: auto;
            min-width: 960px;
            max-width: 1340px;
        }
        body.hc-content-size-full .b-wrapper {
            min-width: 960px;
            width: auto;
        }
        body.hc-content-size-full .glory {
            width: auto;
        }

        /* !css */

        `);

        resolve();
        document.addEventListener("DOMContentLoaded", resizePlayer);
        document.addEventListener("DOMContentLoaded", settings);

        function getSize() {
            return localStorage.getItem("hc-content-size");
        }

        function setSize(value) {
            return localStorage.setItem("hc-content-size", value);
        }

        function rotate() {
            let size = getSize();
            switch (size) {
                case "normal":
                    size = "wide";
                    break;
                case "wide":
                    size = "ultrawide";
                    break;
                case "ultrawide":
                    size = "full";
                    break;
                case "full":
                    size = "normal";
                    break;
                default:
                    size = "wide";
                    break;
            }
            setSize(size);
            resolve();
        }

        function resolve() {
            if (!document.body) return;

            document.body.classList.remove("hc-content-size-wide");
            document.body.classList.remove("hc-content-size-ultrawide");
            document.body.classList.remove("hc-content-size-full");
            window.removeEventListener("resize", resizePlayer);

            switch (getSize()) {
                case "wide":
                    document.body.classList.add("hc-content-size-wide");
                    window.addEventListener("resize", resizePlayer);
                    break;
                case "ultrawide":
                    document.body.classList.add("hc-content-size-ultrawide");
                    window.addEventListener("resize", resizePlayer);
                    break;
                case "full":
                    document.body.classList.add("hc-content-size-full");
                    window.addEventListener("resize", resizePlayer);
                    break;
            }

            resizePlayer();
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(
                    rotate,
                    "content-size",
                    [],
                    ["hc-content-size-wide", "hc-content-size-ultrawide", "hc-content-size-full"],
                    "Ширина контента",
                    ["960 px", "1150 px", "1340 px", "100 %"]
                );
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------HIDE-INFO-------------------------- */
    /* ------------------------------------------------- */

    function initHideInfoButton() {
        GM_addStyle(`

        /* css */

        /* Content hide info (button) */

        .hc-hide-info-button {
            content: '';
            width: 25px;
            height: 25px;
            margin-right: 5px;
            background-size: 25px 25px;
            background-repeat: no-repeat;
            background-image: url(${arrowImageURL});
            cursor: pointer;
        }
        body.hc-hide-info .hc-hide-info-button {
            transform: rotate(180deg);
        }

        /* Content hide info (hidden styles) */

        body.hc-hide-info .b-post__infotable,
        body.hc-hide-info .b-post__description,
        body.hc-hide-info .b-post__infolast{
            display: none !important;
        }

        /* Content hide info (night theme) */

        body.b-theme__template__night .hc-hide-info-button {
            filter: invert(100%) sepia(95%) saturate(21%) hue-rotate(280deg) brightness(106%) contrast(106%);
        }

        /* !css */

        `);

        resolve();
        document.addEventListener("DOMContentLoaded", setup);
        document.addEventListener("DOMContentLoaded", settings);

        function setup() {
            const title = document.querySelector(".b-post__title");
            if (!title) return;

            if (title.querySelector(".hc-hide-info-button")) return;

            const button = document.createElement("div");
            button.classList.add("pull-right");
            button.classList.add("hc-hide-info-button");
            button.addEventListener("click", change);
            title.insertBefore(button, title.firstChild);
        }

        function change() {
            document.body.classList.toggle("hc-hide-info");
        }

        function resolve() {
            if (!document.body) return;

            if (enabled()) {
                document.body.classList.add("hc-hide-info");
                document.body.classList.add("hc-hide-info-enabled");
            } else {
                document.body.classList.remove("hc-hide-info");
                document.body.classList.remove("hc-hide-info-enabled");
            }
        }

        function enabled() {
            return localStorage.getItem("hc-hide-info") == "true";
        }

        function toggle() {
            localStorage.setItem("hc-hide-info", !enabled());
            resolve();
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(
                    toggle,
                    "hide-info",
                    ["hc-tumbler", "hc-on-of-tumbler"],
                    ["hc-hide-info-enabled"],
                    "Сворачивать описание контента",
                    ["Выкл", "Вкл"]
                );
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------HIDE-COMMENTS---------------------- */
    /* ------------------------------------------------- */

    function initHideComments() {
        GM_addStyle(`

        /* css */

        body.hc-comments-hide #hd-comments-list,
        body.hc-comments-hide #hd-comments-navigation {
            display: none;
        }

        .hc-comments-title {
            margin-bottom: 13px;
            overflow: hidden;
        }

        .hc-comments-title .title {
            font-size: 16px;
            font-weight: bold;
            line-height: 18px;
            overflow: hidden;
            padding: 10px 18px;
            text-overflow: ellipsis;
            white-space: nowrap;
            width: 520px;
            float: left;
        }

        .hc-comments-title {
            background: #ddd;
        }
        .hc-comments-title .title {
            color: #000;
        }
        body.b-theme__template__night .hc-comments-title {
            background: #192125;
        }
        body.b-theme__template__night .hc-comments-title .title {
            color: #fff;
        }

        .hc-act {
            color: #878586;
            cursor: pointer;
            float: right;
            font-size: 12px;
            margin-top: 8px;
            margin-right: 18px;
        }

        .hc-act:hover {
            text-decoration: underline;
        }

        .hc-act-show {
            display: none;
        }

        .hc-act-hide {
            display: block;
        }

        body.hc-comments-hide .hc-act-show {
            display: block;
        }

        body.hc-comments-hide .hc-act-hide {
            display: none;
        }

        .b-content__crumbs {
            margin-top: 30px;
        }

        /* !css */

        `);

        resolve();
        document.addEventListener("DOMContentLoaded", setup);
        document.addEventListener("DOMContentLoaded", settings);

        function setup() {
            const commentsList = document.querySelector("#hd-comments-list");
            if (!commentsList) return;

            const commentsTitle = document.createElement("div");
            commentsTitle.classList.add("hc-comments-title");
            commentsTitle.addEventListener("click", change);

            const title = document.createElement("div");
            title.innerText = "Отзывы";
            title.classList.add("title");
            commentsTitle.appendChild(title);

            const actShow = document.createElement("div");
            actShow.classList.add("hc-act");
            actShow.classList.add("hc-act-show");
            actShow.innerText = "развернуть";
            commentsTitle.appendChild(actShow);

            const actHide = document.createElement("div");
            actHide.classList.add("hc-act");
            actHide.classList.add("hc-act-hide");
            actHide.innerText = "свернуть";
            commentsTitle.appendChild(actHide);

            commentsList.parentNode.insertBefore(commentsTitle, commentsList);
        }

        function change() {
            document.body.classList.toggle("hc-comments-hide");
        }

        function resolve() {
            if (!document.body) return;

            if (enabled()) {
                document.body.classList.add("hc-comments-hide");
                document.body.classList.add("hc-comments-hide-enabled");
            } else {
                document.body.classList.remove("hc-comments-hide");
                document.body.classList.remove("hc-comments-hide-enabled");
            }
        }

        function enabled() {
            return localStorage.getItem("hc-comments-hide") == "true";
        }

        function toggle() {
            localStorage.setItem("hc-comments-hide", !enabled());
            resolve();
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(
                    toggle,
                    "comments-hide",
                    ["hc-tumbler", "hc-on-of-tumbler"],
                    ["hc-comments-hide-enabled"],
                    "Сворачивать отзывы",
                    ["Выкл", "Вкл"]
                );
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------PLAYER-COVER----------------------- */
    /* ------------------------------------------------- */

    function initPlayerCover() {
        resolve();
        document.addEventListener("DOMContentLoaded", () => {
            setTimeout(setup, 1000);
        });
        document.addEventListener("DOMContentLoaded", settings);

        function setup() {
            const cover = document.querySelector(".b-sidecover");
            if (!cover) return;

            const imgURL = cover.querySelector("img").src;

            GM_addStyle(`

            /* css */

            body.hc-player-cover #cdnplayer [style*='hc-poster'] {
                background-image: 
                    linear-gradient(
                        to left, 
                        rgba(0,0,0,1) 0%, 
                        rgba(0,0,0,1) 30%, 
                        rgba(0,0,0,.8) 50%, 
                        rgba(0,0,0,1) 70%, 
                        rgba(0,0,0,1) 100%
                    ), 
                    url('${imgURL}') !important;
                background-size: auto 100% !important;
                background-position: center !important;
                background-repeat: no-repeat !important;
            }
            
            /* !css */

            `);
        }

        function resolve() {
            if (!document.body) return;

            if (enabled()) {
                document.body.classList.add("hc-player-cover");
            } else {
                document.body.classList.remove("hc-player-cover");
            }
        }

        function enabled() {
            return localStorage.getItem("hc-player-cover") != "false";
        }

        function toggle() {
            localStorage.setItem("hc-player-cover", !enabled());
            resolve();
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(
                    toggle,
                    "player-cover",
                    ["hc-on-of-tumbler"],
                    ["hc-player-cover"],
                    "Отображать обложку в плеере",
                    ["Выкл", "Вкл"]
                );
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------TRANSLATORS------------------------ */
    /* ------------------------------------------------- */

    function initHideTranslatorsButton() {
        GM_addStyle(`

        /* css */

        /* Content hide translators */

        .b-translator__item.active {
            cursor: pointer;
        }
        .hc-toggle-translators-button {
            content: '';
            float: left;
            width: 20px;
            height: 20px;
            margin-right: 3px;
            margin-top: 8px;
            margin-left: 5px;
            background-size: 20px 20px;
            background-repeat: no-repeat;
            background-image: url(${arrowImageURL});
            filter: invert(100%) sepia(95%) saturate(21%) hue-rotate(280deg) brightness(106%) contrast(106%);
            transform: rotate(90deg);
            cursor: pointer;
        }
        .hc-show-translators .hc-toggle-translators-button {
            transform: rotate(-90deg);
        }
        .b-translator__item:not(.active):not(.hc-toggle-translators-button) {
            display: none;
        }
        .b-translators__title {
            display: none;
        }
        .hc-show-translators .b-translator__item:not(.active):not(.hc-toggle-translators-button) {
            display: block;
        }
        .hc-show-translators .b-translators__title {
            display: block;
        }

        /* !css */

        `);

        document.addEventListener("DOMContentLoaded", setup);

        function setup() {
            const translators = document.querySelector(".b-translators__block");
            if (!translators) return;

            const translatorsList = translators.querySelector(".b-translators__list");
            if (!translatorsList) return;

            const toggler = document.createElement("li");
            toggler.classList.add("hc-toggle-translators-button");
            toggler.addEventListener("click", toggle);
            translatorsList.appendChild(toggler);

            translatorsList.querySelectorAll(".b-translator__item").forEach((button) => {
                button.addEventListener("click", function () {
                    if (this.classList.contains("active")) {
                        toggle();
                    }
                });
            });
        }

        function toggle() {
            document.querySelector(".b-translators__block").classList.toggle("hc-show-translators");
        }
    }

    /* ------------------------------------------------- */
    /* --------------HIDE-RUSSIAN----------------------- */
    /* ------------------------------------------------- */

    function initHideRussian() {
        GM_addStyle(`

        /* css */

        /* Main */

        .hc-hide-russian .hc-russian {
            display: none;
        }

        /* !css */
        
        `);

        resolve();
        document.addEventListener("DOMContentLoaded", setup);
        document.addEventListener("DOMContentLoaded", settings);

        function setup() {
            document.querySelectorAll(".b-content__inline_item").forEach((elem) => {
                if (elem.textContent.includes("Россия,") && !elem.classList.contains("hc-russian")) {
                    elem.classList.add("hc-russian");
                    const info = elem
                        .querySelector(".b-content__inline_item-link")
                        .textContent.replace(/(\r\n|\n|\r)/gm, "")
                        .trim();
                    console.debug(`HDrezka Cleanup: mark russian ${info}`);
                }
            });
        }

        function resolve() {
            if (!document.body) return;

            if (enabled()) {
                document.body.classList.add("hc-hide-russian");
            } else {
                document.body.classList.remove("hc-hide-russian");
            }
        }

        function enabled() {
            return localStorage.getItem("hc-hide-russian") == "true";
        }

        function toggle() {
            localStorage.setItem("hc-hide-russian", !enabled());
            resolve();
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(
                    toggle,
                    "hide-russian",
                    ["hc-on-of-tumbler"],
                    ["hc-hide-russian"],
                    "Скрыть контент из страны-агрессора",
                    ["Выкл", "Вкл"]
                );
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------IMDB-RATING------------------------ */
    /* ------------------------------------------------- */

    function initIMDbRating() {
        GM_addStyle(`

        /* css */

        /* Rating */

        .b-content__inline_item-link > .rating {
            position: relative;
            line-height: 15px;
            font-size: 11px;
            font-weight: normal;
            display: block;
            margin-top: 3px;
        }
        .b-content__inline_item-link > .rating .rating-votes {
            font-size: 9px;
        }
        .b-content__inline_item-link > .rating .rating-value {
            margin-left: 29px;
            color: #f09a20;
        }
        .b-content__inline_item-link > .rating:before {
            content: '';
            position: absolute;
            width: 26px;
            height: 100%;
            background-size: auto 24px;
            background-position: center -4px;
            background-repeat: no-repeat;

            /* https://icons8.com/icon/V0AXUEQxEIf5/imdb */
            background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QA/wD/AP+gvaeTAAAEu0lEQVR4nO2czYscRRiHn+nxY7ORdc1ulGgQYoxGNwbEKIoHDxpQNGxEURQPQQ34D/gRCFE8hJCDIIoHz7noRTeCB4MmB0OMHxFRE0wkStCIGM0SV1fDJuOhetze2uqu/piZ7u35PfAyzLxVv3q73uma6uquASGEEEIIIYQQQgghhBBCCCGEEEIIIUTdaCT4LgM2AuPAamA5sLgXQdWAv4CfgCPAbuBd4HTayouALcAk0JJ1xE4DLwADvs6/Evi0AgHX1b4Erk7q/BMVCLLudiLs6zksAj6rQHD9YgcJh6NmmIDngSfsrIiucRUwBexvYGY7PwCXlhpS/zEJXBMAD6LOL4NhYDwANpQdSR+zIQDGyo6ijxlrAH8Cl5QdSZ8y1cBMi7LyD7ATM3W9DXiWuVd508AO4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af9vU42ijdq9MedG7WgSDlYgyLraIRL+qqDNAGbjdkfWOmS0wr58DrjY7uyk9ZJhzF/VjGMeOFqONvOlZYrZv6uZCG2y1IiEEEIIIYQQQgghhBBCCCGEEEIIIYQQPeM/uURowB/mrvMAAAAASUVORK5CYII=");

            /* https://codepen.io/sosuke/pen/Pjoqqp */
            filter: invert(66%) sepia(77%) saturate(1448%) hue-rotate(347deg) brightness(99%) contrast(91%);
        }

        /* !css */
        
        `);

        document.addEventListener("DOMContentLoaded", setup);
        document.addEventListener("DOMContentLoaded", settings);

        function setWithExpiry(key, value, ttl) {
            const now = new Date();

            // `item` is an object which contains the original value
            // as well as the time when it's supposed to expire
            const item = {
                value: value,
                expiry: now.getTime() + ttl,
            };
            localStorage.setItem(key, JSON.stringify(item));
        }

        function getWithExpiry(key) {
            const itemStr = localStorage.getItem(key);
            // if the item doesn't exist, return null
            if (!itemStr) {
                return null;
            }
            const item = JSON.parse(itemStr);
            const now = new Date();
            // compare the expiry time of the item with the current time
            if (now.getTime() > item.expiry) {
                // If the item is expired, delete the item from storage
                // and return null
                localStorage.removeItem(key);
                return null;
            }
            return item.value;
        }

        function getRating(id) {
            return new Promise((resolve) => {
                console.debug(`HDrezka IMDB Rating: request quick content for id=${id}.`);
                GM_xmlhttpRequest({
                    method: "POST",
                    url: "/engine/ajax/quick_content.php",
                    data: `id=${id}&is_touch=1`,
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded",
                    },
                    onload: (response) => {
                        // One weak ttl in ms
                        const ttl = 7 * 24 * 60 * 60 * 1000;
                        if (response.status === 200) {
                            // Is 200 status code
                            // Find IMDb block
                            const ratingHTML = /<span class="imdb">IMDb: <b>.{1,60}\)<\/i><\/span>/.exec(
                                response.responseText
                            );
                            if (ratingHTML) {
                                // IMDb block found
                                let rating;
                                let votes;
                                try {
                                    // Get actual rating
                                    const rating = /(<b>)(.*)(<\/b>)/.exec(ratingHTML[0])[2];
                                    // Get actual votes count
                                    const votes = /(<i>)\((.*)\)(<\/i>)/.exec(ratingHTML[0])[2];
                                    // Save real rating to Storage
                                    // Resolve with real rating
                                    const data = {
                                        rating: rating,
                                        votes: votes,
                                        id: id,
                                    };
                                    setWithExpiry(id, data, ttl);
                                    resolve(data);
                                    console.debug(`HDrezka IMDB Rating: request quick content for id=${id} success.`);
                                    return;
                                } catch (err) {
                                    console.debug(err);
                                }
                            }
                            // IMDb block not found
                            // Save empty rating to storage to not make new request in next page load
                            // Resolve with empty rating
                            const data = { rating: "", votes: "", id: id };
                            setWithExpiry(id, data, ttl);
                            resolve(data);
                            console.debug(
                                `HDrezka IMDB Rating: request quick content for id=${id} success, but no correct data found.`
                            );
                        } else {
                            console.debug(
                                `HDrezka IMDB Rating: request quick content for id=${id} failed with ${response.status} status code.`
                            );
                            // Isn't 200 status code
                            // Don't save any rating so it will be requsted again in next page load
                            // Resolve with null rating
                            resolve({ rating: null, votes: null, id: id });
                        }
                    },
                    onerror: () => {
                        console.debug(`HDrezka IMDB Rating: request quick content for id=${id} failed.`);
                        // Request failed
                        // Don't save any rating so it will be requsted again in next page load
                        // Resolve with null rating
                        resolve({ rating: null, votes: null, id: id });
                    },
                });
            });
        }

        function showRating(ratingObject) {
            if (
                ratingObject &&
                ratingObject.id !== null &&
                ratingObject.rating !== null &&
                ratingObject.rating !== ""
            ) {
                // Got rating
                // Find related elements to append rating
                document
                    .querySelectorAll(`[data-id="${ratingObject.id}"] .b-content__inline_item-link`)
                    .forEach((contentItemLinkElement) => {
                        // Check rating wasn't already appended
                        if (contentItemLinkElement && !contentItemLinkElement.querySelector(".rating")) {
                            // Append rating block
                            let votesText;
                            try {
                                votesText = `${parseInt(parseInt(ratingObject.votes.replace(/\s/g, "")) / 1000)}k`;
                            } catch (err) {
                                console.debug(err);
                                votesText = "";
                            }
                            contentItemLinkElement.innerHTML +=
                                /* html */
                                `
                                    <!-- html -->
                                    <span class="rating">
                                        <span class="rating-value"><b>${ratingObject.rating}</b></span>
                                        <span> / </span>
                                        <span class="rating-votes">${votesText}</span>
                                    </span>
                                    <!-- !html -->
                                `;
                        }
                    });
            }
        }

        function getAndShowRating(contentItemElement) {
            const id = contentItemElement.dataset.id;
            const ratingObject = getWithExpiry(id);
            if (
                ratingObject !== null &&
                ratingObject.id != null &&
                ratingObject.rating != null &&
                ratingObject.votes != null
            ) {
                // Found vaid saved rating in storage
                // Show rating from storage
                return showRating(ratingObject);
            }
            // Rating not found in storage
            // Request rating and then show
            return getRating(id).then(showRating);
        }

        function setup() {
            if (!document.body) return;

            resolve();

            if (document.body.classList.contains("hc-imdb")) {
                document.querySelectorAll(".b-content__inline_item").forEach(getAndShowRating);
            }
        }

        function resolve() {
            if (!document.body) return;

            if (enabled()) {
                document.body.classList.add("hc-imdb");
            } else {
                document.body.classList.remove("hc-imdb");
            }
        }

        function enabled() {
            return localStorage.getItem("hc-imdb") == "true";
        }

        function toggle() {
            localStorage.setItem("hc-imdb", !enabled());
            document.location.reload();
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(toggle, "imdb", ["hc-on-of-tumbler"], ["hc-imdb"], "Рейтинг IMDb", [
                    "Выкл",
                    "Вкл",
                ]);
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------PLAYER----------------------------- */
    /* ------------------------------------------------- */

    function initPlayer() {
        hc.player = {};
        hc.player.start = start;
        hc.player.play = play;
        hc.player.pause = pause;
        hc.player.stop = stop;
        hc.player.next = next;
        hc.player.prev = prev;
        hc.player.space = space;
        hc.player.fullscreen = fullscreen;
        hc.player.poster = poster;

        window.addEventListener("message", function (event) {
            if (event.data && event.data.event == "inited") {
                poster("hc-poster");
            }
        });

        function start() {
            if (!CDNPlayer) return;
            sof.tv.buildCDNPlayer("autoplay");
        }

        function play() {
            if (!CDNPlayer) return;
            CDNPlayer.api("play");
        }

        function pause() {
            if (!CDNPlayer) return;
            CDNPlayer.api("pause");
        }

        function stop() {
            if (!CDNPlayer) return;
            CDNPlayer.api("stop");
        }

        function toggle() {
            if (!CDNPlayer) return;
            CDNPlayer.api("toggle");
        }

        function fullscreen() {
            if (!CDNPlayer) return;
            CDNPlayer.api("fullscreen");
        }

        function poster(poster) {
            if (!CDNPlayer) return;
            CDNPlayer.api("poster", poster);
        }

        function space() {
            if (!CDNPlayer) return;
            if (!CDNPlayer.api("started")) {
                play();
            } else {
                if (!hc.player.hotkeys) {
                    toggle();
                }
            }
        }

        function sibling(direction) {
            const activeEpisode = document.querySelector(".b-simple_episode__item.active");
            if (activeEpisode && activeEpisode[direction]) {
                activeEpisode[direction].click();
                setTimeout(start, 1000);
            } else {
                const activeSeason = document.querySelector(".b-simple_season__item.active");
                if (activeSeason && activeSeason[direction]) {
                    activeSeason[direction].click();
                    setTimeout(start, 1000);
                }
            }
        }

        function next() {
            if (!CDNPlayer) return;
            sibling("nextElementSibling");
        }

        function prev() {
            if (!CDNPlayer) return;
            sibling("previousElementSibling");
        }
    }

    /* ------------------------------------------------- */
    /* --------------PLAYER-AUTO-PLAY-NEXT-------------- */
    /* ------------------------------------------------- */

    function initAutoPlayNext() {
        resolve();
        document.addEventListener("DOMContentLoaded", setup);
        document.addEventListener("DOMContentLoaded", settings);

        function setup() {
            window.addEventListener("message", function (event) {
                if (event.data && event.data.event == "ended") {
                    if (getValue() == "enabled") {
                        hc.player.next();
                    }
                }
                if (
                    event.data &&
                    event.data.event == "time" &&
                    event.data.data != 0 &&
                    event.data.data >= event.data.duration - 1
                ) {
                    if (getValue() == "disabled") {
                        hc.player.stop();
                    }
                }
            });
        }

        function resolve() {
            if (!document.body) return;

            if (enabled()) {
                document.body.classList.add("hc-auto-play-next");
            } else {
                document.body.classList.remove("hc-auto-play-next");
            }
        }

        function enabled() {
            return getValue() == "enabled";
        }

        function getValue() {
            return localStorage.getItem("hc-auto-play-next");
        }

        function setValue(value) {
            return localStorage.setItem("hc-auto-play-next", value);
        }

        function rotate() {
            let value = getValue();
            switch (value) {
                case "default":
                    value = "enabled";
                    break;
                case "enabled":
                    value = "disabled";
                    break;
                case "disabled":
                    value = "default";
                    break;
                default:
                    value = "enabled";
                    break;
            }
            setValue(value);
            resolve();
        }

        function resolve() {
            if (!document.body) return;

            document.body.classList.remove("hc-auto-play-next-enabled");
            document.body.classList.remove("hc-auto-play-next-disabled");

            switch (getValue()) {
                case "enabled":
                    document.body.classList.add("hc-auto-play-next-enabled");
                    break;
                case "disabled":
                    document.body.classList.add("hc-auto-play-next-disabled");
                    break;
            }
        }

        function settings() {
            if (hc.settings) {
                hc.settings.createSettingTumbler(
                    rotate,
                    "auto-play-next",
                    [],
                    ["hc-auto-play-next-enabled", "hc-auto-play-next-disabled"],
                    "Автопереключение серий и сезонов",
                    ["Только эпизодов (поведение по умолчанию)", "Эпизодов и сезонов", "Выкл"]
                );
            }
        }
    }

    /* ------------------------------------------------- */
    /* --------------HOTKEYS---------------------------- */
    /* ------------------------------------------------- */

    function initHotkeys() {
        document.addEventListener("DOMContentLoaded", setup);

        function setup() {
            window.addEventListener("keydown", function (e) {
                // Disable scroll
                if (e.code == "Space" && e.target == document.body) {
                    e.preventDefault();
                }
            });

            hc.player.hotkeys = false;

            const cdnplayer = document.querySelector("#cdnplayer");

            cdnplayer.addEventListener("mouseover", function (e) {
                hc.player.hotkeys = true;
            });

            cdnplayer.addEventListener("mouseleave", function (e) {
                setTimeout(() => {
                    hc.player.hotkeys = false;
                }, 10000);
            });
        }

        document.onkeyup = function (e) {
            switch (e.code) {
                case "KeyN":
                    hc.player.next();
                    break;
                case "KeyP":
                    hc.player.prev();
                    break;
                case "KeyF":
                    hc.player.fullscreen();
                    break;
                case "Space":
                    hc.player.space();
                    break;
            }
        };
    }

    /* ------------------------------------------------- */
    /* --------------SETTINGS--------------------------- */
    /* ------------------------------------------------- */

    function initSettings() {
        const settingsOpenImgURL =
            "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABmJLR0QA/wD/AP+gvaeTAAAHl0lEQVRoge2ZbWydZRnHf//ntD1th0EYGa0b48UQJtMRI6LQntEomnQ9H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KEW2B+lQCNpRq3EWrMxvzKQImw2rytMv6Gihu/+cems683d2yfHF6WzXDiAzajEu65N71/bvqbtusPeo8IfK2I1gXsOl2wtrf3TakP0fCqKPi/C5vd39L9Vb0jX43cUTjB+d6W7FyDy3nJPv3jRUb35md++niP41lUXyYKErd3GSgphsswunzBOgU7EvzTexH9d/GfnuTUMqTwjWZCMRGNl+mPLG0YyGqCeSiEguBBiLJ7YKnzJqhHRRZnf27qQ2GiEzmL1b5iOUR4iIE5Ou2YONkFjIwcseexfzzHTmmIKZL3Nv5+DGLyS1U42V+ewXEfdQFlKWoq1nDlyR+3dSO3OqIxGf5ao23tAu66nV+d6eRmFWF+4Lq3dl7wrmSaYq9wxkBwV/cC7cEgu58PU7WiV9ui5TqSMS78/ks4OZfPbK2Wx1vpq9KpMfykdxH1UiZhD57IoDfbXtfQMkPiHOH0rfYuSGddJaAL4Ea0cmn33Hkecjajm5V21aO3dlH1XgOttLQPM5XdaUlS4euwV4PAm/RKGw8tXeD4fgA8x+81FuOdqc0FRhxDAm0VLnhHkaEz5WimFlvXamGomMhsAOneYG0VLtjYkJJ0VMkaKtnoi6a2egjhD8QiKOSSaJ+JxhvGp0GDOM+FWI3iIoVtSZ2WBGBUXZPzE8hxk2Gq6cwrjwtmQcEyKT73kAqyfRJbY4t7KdqfA4YnMkFbVlzONPnrzEXnGgryWMHbspOD4EocN4HHmg0DVw7/sqBGYus9czObmucPmjR+pOMlq1O/sHm8ug6kBml1B4pdDV/4lGFTvzxzvOJZ3eYXhuX3fuvqTcmvIxdGV+YyY4vEJ1arWLli7f153b9377bMoXq/1djxQQh2seSIebIQKa+A1RZgdlvZmlGNH2ZvlrmpAoHwLNdL+ySwEfapa/pn1nTwW2x5LPEQoAxjGkqDnZncEZnMH/B/8BEF4sAc9T0RMAAAAASUVORK5CYII=";

        GM_addStyle(`
        /* css */

        /* Settings */

        .hc-settings {
            position: relative;
        }

        /* Tumbler */

        .hc-tumbler {
            width: 38px;
            height: 30px;
            background-color: #000;
            border: #1d92b2;
            border-radius: 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 6px;
            cursor: pointer;
            position: relative;
        }
        .hc-tumbler-point {
            background-size: 15px 15px;
            background-repeat: no-repeat;
            background-position: center;
            border-radius: 50%;
            content: '';
            display: block;
            height: 20px;
            width: 20px;
            background-color: #999;
            background-clip: content-box;
            box-sizing: border-box;
            border-color: transparent;
            border-style: solid;
            border-width: 3px;
        }
        .hc-tumbler > .hc-tumbler-dot {
            position: absolute;
            height: 20px;
            width: 20px;
            border-radius: 50%;
            background-color: #fff;
            transition: transform .5s,background-color .5s;
            will-change: transform;
            z-index: 2;
        }
        body.b-theme__template__night .hc-tumbler {
            background: #222d33;
        }

        /* On-Off Tumbler */

        .hc-on-of-tumbler .hc-tumbler-point:nth-child(1) {
            background-color: green;
        }
        .hc-on-of-tumbler .hc-tumbler-point:nth-child(2) {
            background-color: indianred;
        }

        /* Settings */

        .hc-settings ul {
            width: 400px;
            display: none;
            background: #313131;
            border-top: 0;
            position: absolute;
            top: 40px;
            left: 0px;
            white-space: nowrap;
            box-shadow: 0 5px 20px 0px rgb(0 0 0 / 70%);
            border-color: #222d33;
            border-style: solid;
            border-width: 0 3px 3px 3px;
        }
        body.hc-settings-active .hc-settings ul {
            display: block !important;
        }
        .hc-settings ul li {
            white-space: nowrap;
            color: #777;
            font-size: 10px;
            font-weight: bold;
            margin: 0 !important;
            padding: 5px 10px;
            height: 30px;
        }
        .hc-settings ul li .hc-tumbler {
            float: right;
        }
        .hc-settings .hc-setting-text-value {
            display: none;
            opacity: .5;
        }
        .hc-settings .hc-setting-text-block {
            float: left;
            padding-top: 5px;
        }

        body.b-theme__template__night .hc-settings ul {
            background: #060f13;
        }

        /* Settings tumbler */

        .hc-tumbler-settings {
            margin-top: 5px;
            margin-left: 10px;
        }
        .hc-tumbler-settings .hc-tumbler-point:nth-child(1) {
            background-image: url('${settingsOpenImgURL}');
            background-color: transparent !important;
        }
        .hc-tumbler-settings .hc-tumbler-point:nth-child(2) {
            background-image: url('${settingsCloseImgURL}');
            background-color: transparent !important;
        }

        /* !css */
        `);

        hc.settings = {};
        hc.settings.createSettingTumbler = createSettingTumbler;

        document.addEventListener("DOMContentLoaded", setup);

        function setup() {
            const tophead = document.querySelector(".b-tophead-left");
            if (!tophead) return;

            const tumblerWrapper = buildTumbler(toggle, "settings", [], ["hc-settings-active"]);
            tumblerWrapper.classList.add("hc-settings");
            tumblerWrapper.classList.add("pull-left");
            const tumblerUL = document.createElement("ul");
            tumblerWrapper.appendChild(tumblerUL);

            document.addEventListener("click", close);

            tophead.appendChild(tumblerWrapper);
        }

        function toggle(event) {
            document.body.classList.toggle("hc-settings-active");
            event.stopPropagation();
        }

        function close(event) {
            if (!event.target.closest(".hc-settings")) {
                document.body.classList.remove("hc-settings-active");
            }
        }

        function addSettingTumbler(element) {
            const tophead = document.querySelector(".b-tophead-left");
            if (!tophead) return;

            const dropdown = tophead.querySelector(".hc-settings ul");
            if (!dropdown) return;

            const item = document.createElement("li");
            item.appendChild(element);
            dropdown.appendChild(item);
        }

        function buildTumbler(onClick, classSuffix, tumblerClassNames, enabledClassNames) {
            const ponitsCount = enabledClassNames.length + 1;
            const tumblerClassName = "hc-tumbler-" + classSuffix;
            GM_addStyle(`
            /* css */

            .${tumblerClassName} {
                width: ${ponitsCount * 15 + ponitsCount * 5}px !important;
            }
    
            /* !css */
            `);

            const tumblerWrapper = document.createElement("div");
            tumblerWrapper.classList.add("hc-tumbler-wrapper");

            const tumbler = document.createElement("div");
            tumbler.classList.add("hc-tumbler");
            tumbler.classList.add(tumblerClassName);
            tumbler.className += " " + tumblerClassNames.join(" ");
            tumbler.addEventListener("click", onClick);

            for (let pointIndex = 0; pointIndex < ponitsCount; pointIndex++) {
                const tumblerPoint = document.createElement("div");
                tumblerPoint.classList.add("hc-tumbler-point");
                tumbler.appendChild(tumblerPoint);

                if (pointIndex > 0) {
                    // Add dot move style for all points except initial
                    const enabledClassName = enabledClassNames[pointIndex - 1];

                    GM_addStyle(`
                    /* css */
            
                    .${enabledClassName} .${tumblerClassName} .hc-tumbler-dot {
                        transform: translateX(${pointIndex * 100}%);
                    }

                    /* !css */
                    `);
                }
            }

            const tumblerDot = document.createElement("div");
            tumblerDot.classList.add("hc-tumbler-dot");
            tumbler.appendChild(tumblerDot);

            tumblerWrapper.appendChild(tumbler);

            return tumblerWrapper;
        }

        function buildSettingTumbler(
            actionFunc,
            classSuffix,
            tumblerClassNames,
            enabledClassNames,
            textLabel,
            textValues
        ) {
            const tumblerWrapper = buildTumbler(actionFunc, classSuffix, tumblerClassNames, enabledClassNames);
            const settingClass = "hc-setting-" + classSuffix;
            tumblerWrapper.classList.add(settingClass);

            const settingTextBlock = document.createElement("div");
            settingTextBlock.classList.add("hc-setting-text-block");

            const textLabelSpan = document.createElement("span");
            textLabelSpan.classList.add("hc-setting-label");
            textLabelSpan.innerText = textLabel;

            settingTextBlock.appendChild(textLabelSpan);

            const textValuesCount = textValues.length;
            for (let textValueIndex = 0; textValueIndex < textValuesCount; textValueIndex++) {
                // Add dot move style for all points except initial
                const textValue = textValues[textValueIndex];
                const textValueClass = "hc-setting-text-value-" + (textValueIndex + 1);

                const textValueSpan = document.createElement("span");
                textValueSpan.classList.add("hc-setting-text-value");
                textValueSpan.classList.add(textValueClass);
                textValueSpan.innerText = textValue;
                settingTextBlock.appendChild(textValueSpan);

                if (textValueIndex == 0) {
                    const textValueSelector = "body:not(." + enabledClassNames.join("):not(.") + ")";
                    GM_addStyle(`
                    /* css */
            
                    ${textValueSelector} .${settingClass} .${textValueClass} {
                        display: block !important;
                    }
        
                    /* !css */
                    `);
                } else {
                    const enabledClassName = enabledClassNames[textValueIndex - 1];
                    GM_addStyle(`
                    /* css */
            
                    .${enabledClassName} .${settingClass} .${textValueClass} {
                        display: block !important;
                    }
    
                    /* !css */
                    `);
                }
            }

            tumblerWrapper.appendChild(settingTextBlock);

            return tumblerWrapper;
        }

        function createSettingTumbler(
            actionFunc,
            classSuffix,
            tumblerClassNames,
            enabledClassNames,
            textLabel,
            textValues
        ) {
            const tumblerWrapper = buildSettingTumbler(
                actionFunc,
                classSuffix,
                tumblerClassNames,
                enabledClassNames,
                textLabel,
                textValues
            );
            addSettingTumbler(tumblerWrapper);
        }
    }

    /* ------------------------------------------------- */
    /* --------------DOCUMENT--------------------------- */
    /* ------------------------------------------------- */

    function onDocumentStart() {
        initSettings();
        initPlayer();
        initContentSizeTumbler();
        initHideAds();
        initStyleImprovements();
        initHideInfoButton();
        initHideComments();
        initHideTranslatorsButton();
        initPlayerCover();
        initIMDbRating();
        initAutoPlayNext();
        initHideRussian();
        initHotkeys();
    }

    function onDocumentEnd() {}

    document.addEventListener("DOMContentLoaded", onDocumentEnd);

    onDocumentStart();
})();