iQiyi Get Chapter Date V2

Fetches and displays the chapter dates for iqiyi manhua

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         iQiyi Get Chapter Date V2
// @namespace    https://greasyfork.org/en/users/689482-quin15
// @version      1.1.12
// @description  Fetches and displays the chapter dates for iqiyi manhua
// @author       Quin15
// @match        https://www.iqiyi.com/manhua/detai*
// @icon         https://www.google.com/s2/favicons?domain=iqiyi.com
// @grant        GM_xmlhttpRequest
// @grant        unsafeWindow
// ==/UserScript==

GM_xmlhttpRequest ({
    method:     'GET',
    url:        "https://www.iqiyi.com/manhua/catalog/" + location.pathname.split('detail_')[1].split('.')[0],
    onload:     function(responseDetails) {
        unsafeWindow.episodeList = JSON.parse(responseDetails.responseText).data.episodes;
        var checkElems = function() {if (document.querySelector('.chapter-container ol li')) {unsafeWindow.injectDates()} else {setTimeout(checkElems, 100);}};
        checkElems();
    }
});

unsafeWindow.injectDates = function() {
    var DOMEpisodeList = document.querySelectorAll('.chapter-fixhei li')
    for (var i = 0; i < DOMEpisodeList.length; i++) {
        var episodeNum = parseInt(DOMEpisodeList[i].querySelector('.itemcata-order').innerText);
        for (var e = 0; e < episodeList.length; e++) {
            if (episodeList[e].episodeOrder == episodeNum) {
                var episodeDate = (new Intl.DateTimeFormat('en-GB', {timeZone: "Asia/Hong_Kong"}).format(new Date(parseInt(episodeList[e].lastUpdateTime)))).split('/').reverse().join('-');
                if (!(DOMEpisodeList[i].querySelector('.DateElem'))) {
                    var dateElem = document.createElement('div');
                    dateElem.className = "DateElem";
                    dateElem.style = "width: 100%; color: #888; font-size: 12px; margin-top: 20px; position:absolute;";
                    dateElem.innerText = episodeDate;
                    DOMEpisodeList[i].appendChild(dateElem)
                }
            };
        };
    };
};

var comicTitle = document.querySelector('.detail-info .detail-tit h1').innerText;

var searchAP = document.createElement('div');
searchAP.className = "btn-detail detail-read J_readFromStart";
searchAP.style = "margin-left: 30px; position: absolute; cursor: pointer;"
searchAP.innerHTML = `<img src="https://www.anime-planet.com/favicon.ico" style="float: left;height: 30px;top: 8px; position: relative; margin-left: 20px"><p style="font-size: 16px">Search on AP</p>`;
document.querySelector('.detail-info').insertBefore(searchAP, document.querySelector('.detail-info').lastElementChild);
searchAP.addEventListener("click", function() {open(encodeURI("https://www.anime-planet.com/manga/all?name=" + comicTitle), "")});

var coverImg = document.createElement('div');
coverImg.className = "btn-detail detail-read J_readFromStart";
coverImg.style = "margin-left: 260px; position: absolute; cursor: pointer;"
coverImg.innerHTML = `<img src="` + document.querySelector('.detail-cover img').src + `" style="float: left;height: 30px;top: 8px; position: relative; margin-left: 20px"><p style="font-size: 16px">Open Cover Image</p>`;
document.querySelector('.detail-info').insertBefore(coverImg, document.querySelector('.detail-info').lastElementChild);
coverImg.addEventListener("click", function() {open(document.querySelector('.detail-cover img').src, "")});

document.querySelector('.catalogPageList.clearfix').addEventListener("click", function() {{setTimeout(injectDates, 50)}}, true);
document.querySelector('.chapter-page-more').addEventListener("click", function() {{setTimeout(injectDates, 50)}}, true);