HdFull Season Button

Añade un botón para poder desmarcar los episodios marcados como vistos

当前为 2020-12-09 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         HdFull Season Button
// @namespace    https://greasyfork.org
// @version      0.1
// @description  Añade un botón para poder desmarcar los episodios marcados como vistos
// @author       Jeau
// @include      https://hdfull.*/serie/*/temporada-*
// @grant        none
// ==/UserScript==

if (document.getElementById('header-signin') == null) {

    var seasonButtons = document.getElementsByClassName('season-mark-view');

    // Oculta el botón original de HdFull
    seasonButtons[0].style.display = 'none';

    var newButtonsHTML = `
        <div class="season-mark-view" style="display: block;">
            <ul class="filter">
                <li class="current">
                    <a href="#" onclick="
                        var addWatchSeason = function() {
                            var ids = [];
                            $('.show-view').each(function() {
                                ids.push($(this).data('episode'));
                            });
                            addMultipleWatch(ids,3);
                            $('.seen-box').show();
                            $('.season-mark-view')[1].style.display = 'none';
                            $('.season-mark-view')[2].style.display = 'block';
                        }

                        var addMultipleWatch = function(ids,type){
                            if($.isArray(ids)) {
                                $.post(baseurl+'/a/status',{
                                    target_id: ids.join(),
                                    target_type: type,
                                    target_status: 1
                                },function(resp) {
                                    $.each(ids,function(idx, id) {
                                        updateStatus(type, id, 1);
                                    });
                                });
                            }
                        }
                        addWatchSeason();
                    ">Marcar todos como vistos</a>
                </li>
            </ul>
        </div>
        <div class="season-mark-view" style="display: none;">
            <ul class="filter">
                <li class="current">
                    <a href="#" onclick="
                        var removeWatchSeason = function() {
                            var ids = [];
                            $('.show-view').each(function() {
                                ids.push($(this).data('episode'));
                            });
                            removeMultipleWatch(ids,3);
                            $('.seen-box').hide();
                            $('.season-mark-view')[1].style.display = 'block';
                            $('.season-mark-view')[2].style.display = 'none';
                        }

                        var removeMultipleWatch = function(ids,type){
                            if($.isArray(ids)) {
                                $.post(baseurl+'/a/status',{
                                    target_id: ids.join(),
                                    target_type: type,
                                    target_status: 0
                                },function(resp) {
                                    $.each(ids,function(idx, id) {
                                        updateStatus(type, id, 0);
                                    });
                                });
                            }
                        }
                        removeWatchSeason();
                    ">Desmarcar todos como vistos</a>
                </li>
            </ul>
        </div>`;

    seasonButtons[0].insertAdjacentHTML('afterend', newButtonsHTML);

    // Actualiza el botón de marcar/desmarcar al estado actual adeacuado
    var checkWatched = function() {
        var countUnwatched = 0;
        document.querySelectorAll(".seen-box").forEach(function(currentValue) {
            if (currentValue.style.display == "" || currentValue.style.display == 'none') {
                ++countUnwatched;
            }
        });

        if (countUnwatched != 0) {
            // Muestra el botón 'Marcar' y oculta el botón 'Desmarcar'
            seasonButtons[1].style.display = 'block';
            seasonButtons[2].style.display = 'none';
        } else {
            // Oculta el botón 'Marcar' y muestra el botón 'Desmarcar'
            seasonButtons[1].style.display = 'none';
            seasonButtons[2].style.display = 'block';
        }
    }

    window.onload = function() {
        setTimeout(function() {
            checkWatched();

            document.querySelectorAll(".actions-seen").forEach(function(c) {
                c.onclick = function(){
                    setTimeout(function() {
                        checkWatched();
                    }, 700);
                }
            });
        }, 700);
    }
}