108 lines
4.4 KiB
JavaScript
108 lines
4.4 KiB
JavaScript
// ==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
|
|
`<style>
|
|
#page-action-stream:before {
|
|
content:"\\f002";
|
|
}
|
|
|
|
#page-action-stream:hover {
|
|
background-color: #58626b !important;
|
|
}
|
|
|
|
#stream-links {
|
|
-moz-appearance: none;
|
|
-webkit-appearance: none;
|
|
appearance: none;
|
|
border: none;
|
|
|
|
|
|
background-color: #58626b;
|
|
color: #e6e6e6;
|
|
box-shadow: none;
|
|
}
|
|
|
|
#stream-links > option {
|
|
direction: ltr;
|
|
}
|
|
</style>`);
|
|
|
|
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*/ `<ul id="page-action" class="inline"></ul>`);
|
|
}
|
|
|
|
document.getElementById("page-action").insertAdjacentHTML("beforeend", //html
|
|
`<li id="page-action-stream">
|
|
<span>
|
|
<select id="stream-links">
|
|
<option value="">Stream wählen</option>
|
|
</select>
|
|
</span>
|
|
</li>`);
|
|
|
|
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" }));
|
|
}
|
|
}
|
|
});
|
|
}
|
|
})(); |