LezhinKO AP Features

Adds search on AP and grabbing vertical cover for Lezhin manhwa

As of 25.04.2021. See ბოლო ვერსია.

// ==UserScript==
// @name         LezhinKO AP Features
// @namespace    https://greasyfork.org/en/users/689482-quin15
// @version      1.0.0
// @description  Adds search on AP and grabbing vertical cover for Lezhin manhwa
// @author       Quin15
// @match        https://www.lezhin.com/ko/comic/*
// @icon         https://www.google.com/s2/favicons?domain=lezhin.com
// @grant        none
// ==/UserScript==

var checkElems = function() {if (document.querySelector('.episode__img img')) {setTimeout(appendButtons, 1000)} else {setTimeout(checkElems, 100);}};
checkElems();

var appendButtons = function() {
    var btnCont = document.createElement('div');
    btnCont.className = "comicInfo__btns";
    document.querySelector('.comicInfo__detail').appendChild(btnCont);

    var searchAP = document.createElement('a')
    searchAP.className = "comicInfo__btnView";
    searchAP.style = "flex:none;margin-left:0px;width:138px;padding:0px 8px 0px 8px;cursor:pointer;";
    searchAP.innerHTML = `<img src="https://www.anime-planet.com/favicon.ico" style="float:left;height:30px;margin-top:6px"><p style="font-size: 14px;white-space: break-spaces;line-height: 1;margin-top: 8px;">Search On AP</p>`;
    btnCont.appendChild(searchAP);
    searchAP.addEventListener("click", function() {open(encodeURI("https://www.anime-planet.com/manga/all?name=" + document.querySelector('h2.comicInfo__title').innerText), "")});

    var coverImg = document.createElement('a')
    coverImg.className = "comicInfo__btnView";
    coverImg.style = "flex:none;width:138px;padding:0px 8px 0px 8px;cursor:pointer;";
    coverImg.innerHTML = `<img src="` + document.querySelector('picture img').srcset.replace(" 2x", '') + `" style="float:left;height:30px;margin-top:6px"><p style="font-size: 14px;white-space: break-spaces;line-height: 1;margin-top: 8px;">Open Cover Image</p>`;
    btnCont.appendChild(coverImg);
    coverImg.addEventListener("click", function() {open(document.querySelector('picture img').srcset.replace(" 2x", ''), "")});
}