Pocket Comics AP Features

Adds search on AP and grabbing vertical cover for Pocket Comics series (via Search). Based on Quin15 scripts.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Pocket Comics AP Features
// @namespace    https://greasyfork.org/en/users/787696-kpossibles
// @version      1.0.3
// @description  Adds search on AP and grabbing vertical cover for Pocket Comics series (via Search). Based on Quin15 scripts.
// @author       kpossibles
// @match        https://www.pocketcomics.com/comic/*
// @match        https://www.pocketcomics.com/search/*
// @icon         https://www.google.com/s2/favicons?domain=pocketcomics.com
// @grant        none
// ==/UserScript==

var appendButtons = function() {
    var btnCont = document.createElement('div');
    // use button container class from website
    btnCont.className = "add_product";
    btnCont.style = "margin-top:10px";
    // where you want the buttons to appear
    if (location.href.match(/search/)) {
        document.querySelector('.list_comic').appendChild(btnCont);
    } else {
        document.querySelector('.info_product').appendChild(btnCont);
    }
    
    var searchAP = document.createElement('a')
    // use button class style from website
    searchAP.className = "btn_info";
    searchAP.style = "height: 50px;overflow-wrap: normal;overflow: auto;white-space: pre-wrap;cursor: pointer;background-color:#FC5342;";
    searchAP.innerHTML = `<img src="https://www.anime-planet.com/favicon.ico" style="float:left;height:30px;margin:10px 10px 0px 0px;"><p style="font-size: 14px;white-space: break-spaces;vertical-align: middle;display: inline-block;">Search On AP</p>`;
    btnCont.appendChild(searchAP);
    var ENtitle = "";
    if (location.href.match(/search/)) {
        ENtitle = document.querySelector('strong.tit_comic').innerText;
    } else {
        ENtitle = document.querySelector('strong.tit_product').innerText;
    }
    searchAP.addEventListener("click", function() {open(encodeURI("https://www.anime-planet.com/manga/all?name=" + ENtitle), "")});

    var coverImg = document.createElement('a')
    // use button class style from website
    coverImg.className = "btn_info";
    var imgSrc = "";
    if (location.href.match(/search/)) {
        imgSrc = document.querySelectorAll(".img_thumb")[0].src;
    } else {
        imgSrc = document.querySelector('div.thumb_comic.thumb_keyvisual img').src;
    }
    coverImg.style = "height: 50px;overflow-wrap: normal;overflow: auto;white-space: pre-wrap;cursor: pointer;background-color:#193767;'";
    coverImg.innerHTML = `<img src="` + imgSrc + `" style="float:left;height:30px;margin:10px 10px 0px 0px;"><p style="font-size: 14px;white-space: break-spaces;line-height: 15px;vertical-align: middle;display: inline-block;">Open Cover Image</p>`;
    btnCont.appendChild(coverImg);
    coverImg.addEventListener("click", function() {open(imgSrc, "")});

    var searchMU = document.createElement('a')
    searchMU.className = "link_first";
    searchMU.style = "height: 50px;overflow-wrap: normal;overflow: auto;white-space: pre-wrap;cursor: pointer; border:1px solid gray;";
    searchMU.innerHTML = `<img src="https://www.mangaupdates.com/images/manga-updates.svg" style="float:left;height:30px;margin:10px 10px 0px 0px;"><p style="font-size: 14px;white-space: break-spaces;vertical-align: middle;display: inline-block;">Search On MU</p>`;
    btnCont.appendChild(searchMU);
    searchMU.addEventListener("click", function() {
        open(encodeURI("https://www.mangaupdates.com/site/search/result?search=" + ENtitle), "")
    });
}

var checkElems = function() {
    if (document.querySelector('.txt_info')) {
        setTimeout(appendButtons, 1000);
    } else if (document.querySelector('div.thumb_comic.thumb_keyvisual')) {
        setTimeout(appendButtons, 1000);
    } else {
        setTimeout(checkElems, 100);
    };
};

checkElems();