Files
ani-search-enhancer/ani-search-enhancer.user.js

95 lines
3.8 KiB
JavaScript

// ==UserScript==
// @name aniSearch Enhancer
// @namespace http://git.nivram.io/marvinlehmann/ani-search-enhancer
// @version 1.71
// @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
// @require http://code.jquery.com/jquery-latest.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
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
$(function () {
$('head').append(`
<style>
#page-action-stream:before {
content:"\\f002";
}
#stream-links {
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
border: none;
background-color: transparent;
color: #fff;
}
</style>`);
const animeTitle = $('#htitle > span[itemprop=name]').text();
const animeReleaseYear = $('#htitle > span.release_year').text().replace(/\(|\)/g, '');
if (animeTitle) {
const encodedTitle = encodeURI(animeTitle).replace(/'/g, "%27");
if ($('#page-action').length === 0) {
$('#htitle').after('<ul id="page-action" class="inline"></ul>');
}
$('#page-action').append(`
<li id="page-action-stream">
<span>
<select id="stream-links">
<option value="">Stream wählen</option>
</select>
</span>
</li>`);
const $stream_links = $('#stream-links');
const $page_action_stream = $('#page-action-stream')
const clickHandler = function (e) {
console.log(e);
if (e.target === e.currentTarget) {
console.log("test");
const targetUrl = $stream_links.val();
console.log(targetUrl);
if (targetUrl) {
window.open(targetUrl, '_blank');
}
}
};
// $stream_links.change(clickHandler) ;
$page_action_stream.click(clickHandler);
$stream_links.append(new Option("> Stream List", "https://www.reddit.com/r/animepiracy/wiki/animestreamlist"));
$stream_links.append(new Option("@ 9anime", "https://9anime.to/search?keyword=" + encodedTitle));
$stream_links.append(new Option("@ AnimeVibe", "https://animevibe.xyz/?s=" + encodedTitle));
$stream_links.append(new Option("@ KissAnime", "http://kissanime.ru/Search/Anime?keyword=" + encodedTitle));
$stream_links.append(new Option("@ Proxer", "https://proxer.me/search?s=search&name=" + encodedTitle + "&typ=all-anime#top"));
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.slug;
$stream_links.append(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);
// }
}
}
});
}
});