[MAL] Additional features

Adds image and torrent search for each anime / manga entry, removes search results already on the user's list and removes a few adds.

Verze ze dne 13. 05. 2017. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         [MAL] Additional features
// @description  Adds image and torrent search for each anime / manga entry, removes search results already on the user's list and removes a few adds.
// @version      1.0.1
// @author       MetalTxus

// @include      https://myanimelist.net/topanime.php?*
// @include      https://myanimelist.net/topmanga.php?*
// @include      https://myanimelist.net/anime*
// @include      https://myanimelist.net/manga*

// @icon         https://dl.dropbox.com/s/8m20m7iqc5bz1ke/mal.png
// @namespace    https://greasyfork.org/users/8682
// ==/UserScript==

(function() {
    'use strict';

	var MEDIA_TYPE = {
        anime: { id: '1_2', label: 'anime' },
        manga: { id: '3_1', label: 'manga'}
    }, CSS =
        '<style>' +
            '.custom-search-wrapper a { text-decoration: none; font-size: 16px; transition: .3s;}' +
            '.custom-search-wrapper a:hover { color: rgba(80,116,200,.9); }' +
            '.fa-magnet::before { content: "\\f076" }' +
            '.fa-picture-o::before { content: "\\f03e" }' +
        '</style>';

	function removeResultsInOwnList () {
		$('.ranking-list .btn-anime-watch-status:not(.notinmylist)').parents('.ranking-list').remove();
		$('.js-block-list [title="Completed"],' +
		  '.js-block-list [title="Dropped"],' +
		  '.js-block-list [title="Plan to Watch"]'
		 ).parents('.js-seasonal-anime, tr').remove();
	}

	function addLinkToSearch () {
		$('#contentWrapper h1 span[itemprop="name"]').each(function (i, element) {
			element = $(element);

			var mediaType = location.href.indexOf('https://myanimelist.net/anime') > -1 ? MEDIA_TYPE.anime : MEDIA_TYPE.manga,
				title = element.text();

            var searchWrapper = $('<span class="custom-search-wrapper"></span>');

            var picturesAnchor = $('<a href="https://www.google.es/search?tbm=isch&q=' + encodeURI(title) + ' ' + mediaType.label + '"></a>');
            var picturesIcon = $('<i class="fa fa-picture-o" title="Search for pictures"></i>');
            picturesAnchor.append(picturesIcon);
			searchWrapper.append(' ', picturesAnchor);

            var torrentAnchor = $('<a href="https://nyaa.si/?f=0&s=seeders&o=desc&c=' + mediaType.id + '&q=' + encodeURI(title) + '"></a>');
            var torrentIcon = $('<i class="fa fa-magnet" title="Search for torrents"></i>');
            torrentAnchor.append(torrentIcon);
			searchWrapper.append(' ', torrentAnchor);

			element.append(searchWrapper);
		});
	}

    function removeAdds () {
        $('[href^="/membership?"]').each(element => $(element).parents('div').eq(0).remove());
        $('._unit').each(element => $(element).remove());
    }

    $(CSS).appendTo('head');
    setTimeout(removeAdds, 1000);
	removeResultsInOwnList();
	addLinkToSearch();
})();