Adapt to new site structure

This commit is contained in:
2022-10-04 20:07:47 +02:00
parent 285d9d031a
commit 906cf1065f

View File

@@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name aniSearch Enhancer // @name aniSearch Enhancer
// @namespace http://git.nivram.io/marvinlehmann/ani-search-enhancer // @namespace http://git.nivram.io/marvinlehmann/ani-search-enhancer
// @version 2.0 // @version 2.1
// @description Adds buttons to the info site of an anime on aniSearch which links you directly to various streaming portals. // @description Adds buttons to the info site of an anime on aniSearch which links you directly to various streaming portals.
// @author Marvin Lehmann // @author Marvin Lehmann
// @grant GM_xmlhttpRequest // @grant GM_xmlhttpRequest
@@ -17,7 +17,7 @@
document.head.insertAdjacentHTML("beforeend", //html document.head.insertAdjacentHTML("beforeend", //html
`<style> `<style>
#page-action-stream:before { #page-action-stream:before {
content:"\\f002"; content:"";
} }
#page-action-stream { #page-action-stream {
@@ -78,10 +78,6 @@
} }
} }
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
const animeTitle = document.getElementById("htitle").textContent; const animeTitle = document.getElementById("htitle").textContent;
/** @type {number} */ /** @type {number} */
let animeReleaseYear = null; let animeReleaseYear = null;
@@ -95,7 +91,7 @@
} }
} }
let animeStatus = document.querySelector('#information [lang=ja] ~ .status').textContent.split(": ")[1]; let animeStatus = document.querySelector('#information [lang=ja] ~ .status').textContent.split(": ")[1];
let animeType = getElementByXpath('//*[@id="infodetails"]//span[text()="Typ"]/../text()').textContent; let animeType = document.querySelector("#information .type").childNodes[1].textContent.trim().split(',')[0]
if (animeTitle) { if (animeTitle) {
const encodedTitle = encodeURI(animeTitle).replace(/'/g, "%27"); const encodedTitle = encodeURI(animeTitle).replace(/'/g, "%27");
@@ -134,16 +130,11 @@
return option; return option;
} }
stream_links.insertAdjacentElement("beforeend", stylized(new Option("Piracy Index", "https://piracy.moe/"), { stream_links.insertAdjacentElement("beforeend", stylized(new Option("Piracy Index", "https://theindex.moe/"), {
direction: "rtl", direction: "rtl",
fontWeight: "bold" fontWeight: "bold"
})); }));
stream_links.insertAdjacentElement("beforeend", new Option("AniCloud", "https://anicloud.io/search?q=" + encodedTitleWithoutYear)); stream_links.insertAdjacentElement("beforeend", new Option("AniCloud", "https://anicloud.io/search?q=" + encodedTitleWithoutYear));
stream_links.insertAdjacentElement("beforeend", new Option("AnimeUltima", "https://www16.animeultima.eu/search?search=" + encodedTitleWithoutYear));
stream_links.insertAdjacentElement("beforeend", stylized(new Option("Twist.moe", "http://twist.moe"), {
fontStyle: "italic",
color: "#DDD"
}));
GM_xmlhttpRequest({ GM_xmlhttpRequest({
method: "GET", method: "GET",