Greasy Fork

Anime-Planet Show New Release

Shows an icon for number of new releases for a certain manga

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

// ==UserScript==
// @name         Anime-Planet Show New Release
// @namespace    https://greasyfork.org/en/users/689482-quin15
// @version      0.1
// @description  Shows an icon for number of new releases for a certain manga
// @author       Quin15
// @match        https://www.anime-planet.com/*
// @grant        none

// ==/UserScript==

$(document).ready(function() {
    if (document.querySelector('li[data-type="manga"] a')) {
        var entries = document.querySelectorAll('li[data-type="manga"] a');
        for (var i = 0; i < entries.length; i++) {
            var ongoingColour = "#6F99E4"
            var releasedNo = $(entries[i].title).find("li.iconVol")[0].innerText.replace("Ch: ", "");
            if (releasedNo.includes(';')) {
                releasedNo = releasedNo.substring(releasedNo.lastIndexOf(";") + 1);
            };
            if (releasedNo.includes('+')) {
                ongoingColour = "#8DEA43";
                releasedNo = releasedNo.replace("+", "");
            }
            releasedNo = parseInt(releasedNo);
            var readNo = parseInt(document.querySelectorAll('li[data-type="manga"] a div.statusArea')[i].innerText.replace(/\n.*/, "").replace(" chs", ""))
            if (releasedNo != readNo && !(isNaN(readNo))) {
                var tag = document.createElement("label");
                tag.setAttribute("style", "width: 30px; height: 30px; position: absolute; background: " + ongoingColour + "; z-index: 12; border-radius: 15px; margin-left: calc(50% - 20px); top: -10px; line-height: 28px; color: #fff; text-shadow: 0px 0px 3px #000, 0px 0px 3px #000, 0px 0px 3px #000, 0px 0px 3px #000, 0px 0px 3px #000, 0px 0px 3px #000;")
                tag.setAttribute("class", "NewReleaseLabel")
                tag.innerText = releasedNo - readNo;
                entries[i].appendChild(tag);
                tag.parentElement.style = "overflow: visible";
                tag.parentElement.parentElement.style = "overflow: visible";
            };
        };
    };
});