New airing anime fix - MAL

Open the anime entry page instead of the season page for "The anime you plan to watch will begin airing on..." notifications.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         New airing anime fix - MAL
// @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
// @version      3
// @description  Open the anime entry page instead of the season page for "The anime you plan to watch will begin airing on..." notifications.
// @author       hacker09
// @match        https://myanimelist.net/*
// @icon         https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
// @run-at       document-end
// @grant        none
// ==/UserScript==

setTimeout(() => {
  'use strict';
  new MutationObserver(function() { //Creates a new mutation observer
    setTimeout(() => { //Delay execution of forEach loop
      document.querySelectorAll('.header-notification-dropdown > div > div > ol > li > a').forEach(function(el) { //For each notification
        if (el.href === 'https://myanimelist.net/anime/season') //If the notification has the anime season link
        { //Starts the if condition
          el.href = el.parentNode.querySelector('div > div > span > span > a').href; //Replace the anime season link with the entry link
        } //Finishes the if condition
      }); //Finishes the for each loop
    }, 1000); //Finishes the setTimeout function
  }).observe(document.querySelector('.header-notification-dropdown'), { attributes: true, attributeFilter: ['style'] }); //Declare changes to be observed
}, 0);