WeComics AP Features

Implements various features and fixes for WeComics

当前为 2021-04-24 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         WeComics AP Features
// @namespace    https://greasyfork.org/en/users/689482-quin15
// @version      1.0.1
// @description  Implements various features and fixes for WeComics
// @author       Quin15
// @match        https://m.wecomics.com/comic/index*
// @icon         https://www.google.com/s2/favicons?domain=wecomics.com
// @grant        unsafeWindow
// ==/UserScript==

fetch("https://m.wecomics.com/h5/comic/detail/id/" + location.search.split('=')[1].split('&')[0] + "?plain=1",
      {"body": null,"method": "GET"
      }).then((response) => {
    response.json().then((data) => {
        data.data.chapter_list.reverse();
        unsafeWindow.data = data;

        var searchAP = document.createElement('div');
        searchAP.style = "float:left;width:100px;height:50px;background:#ff8c75;border-radius:4px;cursor:pointer;box-shadow:rgb(255 140 117 / 60%) 0rem 0.425rem 0.425rem 0rem;"
        searchAP.innerHTML = `<img src="https://www.anime-planet.com/favicon.ico" style="float:left;height:30px;margin:10px 0px 0px 10px;"><p style="font-size:14px;text-align:center;padding:11px;color:#fff">Search On AP</p>`;
        document.querySelector('.comic-detail .contents').appendChild(searchAP)
        searchAP.addEventListener("click", function() {open(encodeURI("https://www.anime-planet.com/manga/all?name=" + document.querySelector('.comic-detail .comic-info h2').innerText), "")});

        var coverImg = document.createElement('div');
        coverImg.style = "float:left;width:100px;height:50px;background:#ff8c75;border-radius:4px;cursor:pointer;box-shadow:rgb(255 140 117 / 60%) 0rem 0.425rem 0.425rem 0rem;margin-left:10px"
        coverImg.innerHTML = `<img src="` + data.data.comic.cover_v_url + `" style="float:left;height:30px;margin:10px 0px 0px 10px;"><p style="font-size:14px;text-align:center;padding:3px;color:#fff">Open Cover Image</p>`;
        document.querySelector('.comic-detail .contents').appendChild(coverImg)
        coverImg.addEventListener("click", function() {open(data.data.comic.cover_v_url, "")});

        var checkElems = function() {if (document.querySelectorAll('.chapter-box .chapter-list .chapter-item')[16]) {setTimeout(addListeners(), 1000)} else {setTimeout(checkElems, 100);}};
        checkElems();
    });
});

var addListeners = function() {
    document.querySelector('.comic-detail').style = "overflow:hidden;margin-bottom:20px;"
    document.querySelector('.comic-detail .contents p').style = "user-select:text;overflow:visible;text-overflow:unset;-webkit-line-clamp:unset;";
    document.querySelector('.chapter a').addEventListener("click", function() {populateTitles()});
    document.querySelectorAll('.chapter a')[1].addEventListener("click", function() {populateTitles()});
    document.querySelectorAll('.chapter-list .chapter-item')[16].addEventListener("click", function() {populateTitles()});
    populateTitles();
}

unsafeWindow.populateTitles = function() {
    setTimeout(function() {
        var textNodes = document.querySelectorAll('.chapter-box .chapter-list .chapter-item');
        for (var i = 0; i < textNodes.length; i++) {
            var chapNum = parseInt(textNodes[i].firstElementChild.innerText);
            if (!isNaN(chapNum)) {
                textNodes[i].setAttribute("title", unsafeWindow.data.data.chapter_list[chapNum-1].publish_date + "   " + unsafeWindow.data.data.chapter_list[chapNum-1].title);
            }
        }
    }, 200);
}