adapted to new AniSearch design

- removed jQuery
- removed defunct and bad websites
- added anicloud
This commit is contained in:
2021-07-20 19:21:25 +02:00
parent 6c9b58c56c
commit d82d6ccc35

View File

@@ -1,48 +1,57 @@
// ==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 1.82 // @version 1.90
// @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
// @include /^https?://www.anisearch.de/anime/.*$/ // @include /^https?://www.anisearch.de/anime/.*$/
// @connect animepahe.com // @connect animepahe.com
// @connect twist.moe // @connect twist.moe
// @require http://code.jquery.com/jquery-latest.js
// @downloadURL http://git.nivram.io/marvinlehmann/ani-search-enhancer/raw/master/ani-search-enhancer.user.js // @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 // @supportURL http://git.nivram.io/marvinlehmann/ani-search-enhancer/issues
// ==/UserScript== // ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true); (function () {
'use strict';
$(function () { document.head.insertAdjacentHTML("beforeend", //html
$('head').append(` `<style>
<style>
#page-action-stream:before { #page-action-stream:before {
content:"\\f002"; content:"\\f002";
} }
#page-action-stream:hover {
background-color: #58626b !important;
}
#stream-links { #stream-links {
-moz-appearance: none; -moz-appearance: none;
-webkit-appearance: none; -webkit-appearance: none;
appearance: none; appearance: none;
border: none; border: none;
background-color: transparent;
color: #fff; background-color: #58626b;
color: #e6e6e6;
box-shadow: none;
}
#stream-links > option {
direction: ltr;
} }
</style>`); </style>`);
const animeTitle = $('#htitle > span[itemprop=name]').text(); const animeTitle = document.getElementById("htitle").textContent;
const animeReleaseYear = $('#htitle > span.release_year').text().replace(/\(|\)/g, ''); const animeReleaseYear = document.querySelector("header .release_year").textContent.match(/\d+/);
if (animeTitle) { if (animeTitle) {
const encodedTitle = encodeURI(animeTitle).replace(/'/g, "%27"); const encodedTitle = encodeURI(animeTitle).replace(/'/g, "%27");
if ($('#page-action').length === 0) { if (!document.getElementById("page-action")) {
$('#htitle').after('<ul id="page-action" class="inline"></ul>'); document.getElementById("htitle").insertAdjacentHTML("beforeend", /*html*/ `<ul id="page-action" class="inline"></ul>`);
} }
$('#page-action').append(` document.getElementById("page-action").insertAdjacentHTML("beforeend", //html
<li id="page-action-stream"> `<li id="page-action-stream">
<span> <span>
<select id="stream-links"> <select id="stream-links">
<option value="">Stream wählen</option> <option value="">Stream wählen</option>
@@ -50,37 +59,40 @@ $(function () {
</span> </span>
</li>`); </li>`);
const $stream_links = $('#stream-links'); const stream_links = document.getElementById("stream-links");
const $page_action_stream = $('#page-action-stream') const page_action_stream = document.getElementById("page-action-stream");
const clickHandler = function (e) { const clickHandler = function (e) {
if (e.target === e.currentTarget) { if (e.target === e.currentTarget) {
const targetUrl = $stream_links.val(); const targetUrl = stream_links.value;
if (targetUrl) { if (targetUrl) {
window.open(targetUrl, '_blank'); window.open(targetUrl, "_blank");
} }
} }
}; };
// $stream_links.change(clickHandler) ; page_action_stream.onclick = clickHandler;
$page_action_stream.click(clickHandler);
$stream_links.append(new Option("> Stream List", "https://www.reddit.com/r/animepiracy/wiki/animestreamlist")); /** @param {HTMLOptionElement} option */
$stream_links.append(new Option("@ 9anime", "https://9anime.to/search?keyword=" + encodedTitle)); const stylized = (option, styles) => {
$stream_links.append(new Option("@ AnimeVibe", "https://animevibe.xyz/?s=" + encodedTitle)); Object.assign(option.style, styles);
$stream_links.append(new Option("@ Proxer", "https://proxer.me/search?s=search&name=" + encodedTitle + "&typ=all-anime#top")); return option;
$stream_links.append(new Option("@ AnimeUltima", "https://www16.animeultima.eu/search?search=" + encodedTitle)); }
$stream_links.append(new Option("@ Twist.moe (?)", "http://twist.moe"));
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({ GM_xmlhttpRequest({
method: 'GET', method: "GET",
url: 'https://animepahe.com/api?m=search&l=3&q=' + encodedTitle, url: "https://animepahe.com/api?m=search&l=3&q=" + encodedTitle,
responseType: 'json', responseType: "json",
onload: function (resp) { onload: function (resp) {
if (resp.response.total > 0) { if (resp.response.total > 0) {
const firstResult = resp.response.data[0]; const firstResult = resp.response.data[0];
const targetPage = 'https://animepahe.com/anime/' + firstResult.session; const targetPage = "https://animepahe.com/anime/" + firstResult.session;
$stream_links.append(new Option("@ AnimePahe", targetPage)); stream_links.insertAdjacentElement("beforeend", new Option("AnimePahe", targetPage));
// Did we possibly get the wrong one? // Did we possibly get the wrong one?
// if (!firstResult.started_airing_date.includes(animeReleaseYear)) { // if (!firstResult.started_airing_date.includes(animeReleaseYear)) {
@@ -88,9 +100,9 @@ $(function () {
// $masteraniButton.css('opacity', 0.5); // $masteraniButton.css('opacity', 0.5);
// } // }
} else { } else {
$stream_links.append(new Option("@ AnimePahe (?)", "https://animepahe.com")); stream_links.insertAdjacentElement("beforeend", stylized(new Option("AnimePahe", "https://animepahe.com"), { fontStyle: "italic", color: "gray" }));
} }
} }
}); });
} }
}); })();