diff --git a/ani-search-enhancer.user.js b/ani-search-enhancer.user.js index 5d8a586..27652e0 100644 --- a/ani-search-enhancer.user.js +++ b/ani-search-enhancer.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name aniSearch Enhancer // @namespace http://git.nivram.io/marvinlehmann/ani-search-enhancer -// @version 1.90 +// @version 2.0 // @description Adds buttons to the info site of an anime on aniSearch which links you directly to various streaming portals. // @author Marvin Lehmann // @grant GM_xmlhttpRequest @@ -20,8 +20,16 @@ content:"\\f002"; } + #page-action-stream { + background-color: #ee8600 !important; + } + #page-action-stream:hover { - background-color: #58626b !important; + background-color: #ee8600 !important; + } + + #page-action-stream span { + line-height: 26px !important; } #stream-links { @@ -29,29 +37,76 @@ -webkit-appearance: none; appearance: none; border: none; - - - background-color: #58626b; + background-color: #ee8600; color: #e6e6e6; box-shadow: none; + padding: 0 5px; } #stream-links > option { direction: ltr; + font-weight: bold; } `); + class AnimePaheSearchResult { + constructor() { + /** @type {number} */ + this.episodes = 0; + /** @type {number} */ + this.id = 0; + /** @type {string} */ + this.poster = ""; + /** @type {string} */ + this.relevance = ""; + /** @type {number} */ + this.score = 0; + /** @type {string} */ + this.season = ""; + /** @type {string} */ + this.slug = ""; + /** @type {string} */ + this.session = ""; + /** @type {string} */ + this.status = ""; + /** @type {string} */ + this.title = ""; + /** @type {string} */ + this.type = ""; + /** @type {number} */ + this.year = 0; + } + } + + function getElementByXpath(path) { + return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + } + const animeTitle = document.getElementById("htitle").textContent; - const animeReleaseYear = document.querySelector("header .release_year").textContent.match(/\d+/); + /** @type {number} */ + let animeReleaseYear = null; + let anime_release_year = document.querySelector("header .release_year"); + if (anime_release_year) { + animeReleaseYear = parseInt(anime_release_year.textContent.match(/\d{4}/)); + } else { + let tmp = document.getElementById("htitle").textContent.match(/\((\d{4})\)/); + if (tmp) { + animeReleaseYear = parseInt(tmp[1]); + } + } + let animeStatus = document.querySelector('#information [lang=ja] ~ .status').textContent.split(": ")[1]; + let animeType = getElementByXpath('//*[@id="infodetails"]//span[text()="Typ"]/../text()').textContent; if (animeTitle) { const encodedTitle = encodeURI(animeTitle).replace(/'/g, "%27"); + const encodedTitleWithoutYear = encodeURI(animeTitle.replace(/ \(\d{4}\)/g, "")).replace(/'/g, "%27"); + if (!document.getElementById("page-action")) { document.getElementById("htitle").insertAdjacentHTML("beforeend", /*html*/ ``); } document.getElementById("page-action").insertAdjacentHTML("beforeend", //html - `
  • + `