MyAnimeList(MAL) - Recommendations direct link

When you click on a recommendation picture in a anime/manga page, you go directly to the anime/manga and not the recommendation page.

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           MyAnimeList(MAL) - Recommendations direct link
// @version        1.0.6
// @description    When you click on a recommendation picture in a anime/manga page, you go directly to the anime/manga and not the recommendation page.
// @author         Cpt_mathix
// @match          https://myanimelist.net/anime/*
// @match          https://myanimelist.net/manga/*
// @match          https://myanimelist.net/anime.php?*
// @match          https://myanimelist.net/manga.php?*
// @exclude        /^https?:\/\/myanimelist\.net\/(anime|manga)\/[^0-9]+/
// @exclude        /^https?:\/\/myanimelist\.net\/(anime|manga)\/\d+\/.+\/.+/
// @grant          none
// @namespace https://greasyfork.org/users/16080
// ==/UserScript==

var type = 'anime';
if (/^https?:\/\/myanimelist\.net\/manga*/.test(document.location.href)) {
	type = 'manga';
}

var allElements;
allElements = document.evaluate(
    '//*[@id="' + type + '_recommendation"]/div[3]/ul/li[*]',
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

for (var i = 0; i < allElements.snapshotLength; i++) {
    var linkEl = allElements.snapshotItem(i).firstChild;
    var href = linkEl.href;
    var id = href.match(/\d+/g);
    var self = document.location.href.match(/\d+/g)[0];
    linkEl.href = href.replace(self,'').replace('-','').replace('\/recommendations','');
}