// ==UserScript== // @name aniSearch Enhancer // @namespace http://git.nivram.io/marvinlehmann/ani-search-enhancer // @version 1.90 // @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 // @include /^https?://www.anisearch.de/anime/.*$/ // @connect animepahe.com // @connect twist.moe // @downloadURL http://git.nivram.io/marvinlehmann/ani-search-enhancer/raw/master/ani-search-enhancer.user.js // @supportURL http://git.nivram.io/marvinlehmann/ani-search-enhancer/issues // ==/UserScript== (function () { 'use strict'; document.head.insertAdjacentHTML("beforeend", //html ``); const animeTitle = document.getElementById("htitle").textContent; const animeReleaseYear = document.querySelector("header .release_year").textContent.match(/\d+/); if (animeTitle) { const encodedTitle = encodeURI(animeTitle).replace(/'/g, "%27"); if (!document.getElementById("page-action")) { document.getElementById("htitle").insertAdjacentHTML("beforeend", /*html*/ ``); } document.getElementById("page-action").insertAdjacentHTML("beforeend", //html `
  • `); const stream_links = document.getElementById("stream-links"); const page_action_stream = document.getElementById("page-action-stream"); const clickHandler = function (e) { if (e.target === e.currentTarget) { const targetUrl = stream_links.value; if (targetUrl) { window.open(targetUrl, "_blank"); } } }; page_action_stream.onclick = clickHandler; /** @param {HTMLOptionElement} option */ const stylized = (option, styles) => { Object.assign(option.style, styles); return option; } stream_links.insertAdjacentElement("beforeend", stylized(new Option("Piracy Index", "https://piracy.moe/"), { direction: "rtl", fontWeight: "bold" })); stream_links.insertAdjacentElement("beforeend", new Option("AniCloud", "https://anicloud.io/search?q=" + encodedTitle)); stream_links.insertAdjacentElement("beforeend", new Option("AnimeUltima", "https://www16.animeultima.eu/search?search=" + encodedTitle)); stream_links.insertAdjacentElement("beforeend", stylized(new Option("Twist.moe", "http://twist.moe"), { fontStyle: "italic", color: "lightgray" })); GM_xmlhttpRequest({ method: "GET", url: "https://animepahe.com/api?m=search&l=3&q=" + encodedTitle, responseType: "json", onload: function (resp) { if (resp.response.total > 0) { const firstResult = resp.response.data[0]; const targetPage = "https://animepahe.com/anime/" + firstResult.session; stream_links.insertAdjacentElement("beforeend", new Option("AnimePahe", targetPage)); // Did we possibly get the wrong one? // if (!firstResult.started_airing_date.includes(animeReleaseYear)) { // $masteraniButton.prop('title', 'Target page may be incorrect.'); // $masteraniButton.css('opacity', 0.5); // } } else { stream_links.insertAdjacentElement("beforeend", stylized(new Option("AnimePahe", "https://animepahe.com"), { fontStyle: "italic", color: "gray" })); } } }); } })();