[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.

Από την 13/05/2017. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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();
})();